summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiccardo Pittau <elfosardo@gmail.com>2019-11-29 10:16:28 +0100
committerRiccardo Pittau <elfosardo@gmail.com>2019-12-23 09:38:25 +0100
commit78c121a5d7b6efc84d541ea4de98aa910255884e (patch)
treef60d0b75107c58f14ed99f81ef9c6831ecb2feea
parent67f5a6bf5c8922a56d70daae023a004e672a88db (diff)
downloadironic-78c121a5d7b6efc84d541ea4de98aa910255884e.tar.gz
Stop using six library
Since we've dropped support for Python 2.7, it's time to look at the bright future that Python 3.x will bring and stop forcing compatibility with older versions. This patch removes the six library from requirements, not looking back. Change-Id: Ib546f16965475c32b2f8caabd560e2c7d382ac5a
-rw-r--r--ironic/api/controllers/v1/allocation.py2
-rw-r--r--ironic/api/controllers/v1/chassis.py2
-rw-r--r--ironic/api/controllers/v1/deploy_template.py2
-rw-r--r--ironic/api/controllers/v1/driver.py3
-rw-r--r--ironic/api/controllers/v1/event.py3
-rw-r--r--ironic/api/controllers/v1/node.py2
-rw-r--r--ironic/api/controllers/v1/port.py2
-rw-r--r--ironic/api/controllers/v1/portgroup.py2
-rw-r--r--ironic/api/controllers/v1/ramdisk.py3
-rw-r--r--ironic/api/controllers/v1/types.py7
-rw-r--r--ironic/api/controllers/v1/utils.py7
-rw-r--r--ironic/api/controllers/v1/volume.py3
-rw-r--r--ironic/api/controllers/v1/volume_connector.py5
-rw-r--r--ironic/api/controllers/v1/volume_target.py5
-rw-r--r--ironic/api/hooks.py5
-rw-r--r--ironic/api/middleware/parsable_error.py7
-rw-r--r--ironic/common/exception.py3
-rw-r--r--ironic/common/fsm.py9
-rw-r--r--ironic/common/glance_service/image_service.py8
-rw-r--r--ironic/common/glance_service/service_utils.py7
-rw-r--r--ironic/common/image_service.py16
-rw-r--r--ironic/common/keystone.py11
-rw-r--r--ironic/common/swift.py19
-rw-r--r--ironic/common/utils.py20
-rw-r--r--ironic/conductor/base_manager.py3
-rw-r--r--ironic/conductor/manager.py2
-rw-r--r--ironic/conductor/task_manager.py6
-rw-r--r--ironic/conductor/utils.py3
-rw-r--r--ironic/db/api.py4
-rw-r--r--ironic/db/sqlalchemy/models.py2
-rw-r--r--ironic/dhcp/base.py4
-rw-r--r--ironic/drivers/base.py14
-rw-r--r--ironic/drivers/hardware_type.py5
-rw-r--r--ironic/drivers/modules/agent.py3
-rw-r--r--ironic/drivers/modules/agent_client.py3
-rw-r--r--ironic/drivers/modules/ansible/deploy.py5
-rw-r--r--ironic/drivers/modules/ansible/playbooks/callback_plugins/ironic_log.py2
-rw-r--r--ironic/drivers/modules/deploy_utils.py3
-rw-r--r--ironic/drivers/modules/ibmc/utils.py6
-rw-r--r--ironic/drivers/modules/ilo/boot.py2
-rw-r--r--ironic/drivers/modules/ilo/common.py10
-rw-r--r--ironic/drivers/modules/ilo/firmware_processor.py6
-rw-r--r--ironic/drivers/modules/ilo/management.py6
-rw-r--r--ironic/drivers/modules/image_cache.py7
-rw-r--r--ironic/drivers/modules/ipmitool.py5
-rw-r--r--ironic/drivers/modules/irmc/boot.py2
-rw-r--r--ironic/drivers/modules/irmc/common.py5
-rw-r--r--ironic/drivers/modules/irmc/raid.py3
-rw-r--r--ironic/drivers/modules/iscsi_deploy.py5
-rw-r--r--ironic/drivers/modules/redfish/boot.py2
-rw-r--r--ironic/drivers/modules/redfish/utils.py7
-rw-r--r--ironic/drivers/modules/snmp.py4
-rw-r--r--ironic/drivers/utils.py3
-rw-r--r--ironic/objects/fields.py3
-rw-r--r--ironic/objects/node.py3
-rw-r--r--ironic/tests/unit/api/base.py3
-rw-r--r--ironic/tests/unit/api/controllers/test_base.py3
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_allocation.py7
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_chassis.py7
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_conductor.py2
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_deploy_template.py7
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_driver.py2
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_event.py3
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_node.py11
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_port.py7
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_portgroup.py7
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_ramdisk.py3
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_types.py7
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_utils.py3
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_volume.py2
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_volume_connector.py7
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_volume_target.py7
-rw-r--r--ironic/tests/unit/api/test_acl.py3
-rw-r--r--ironic/tests/unit/api/test_hooks.py5
-rw-r--r--ironic/tests/unit/api/test_middleware.py3
-rw-r--r--ironic/tests/unit/api/test_root.py2
-rw-r--r--ironic/tests/unit/common/test_cinder.py2
-rw-r--r--ironic/tests/unit/common/test_image_service.py46
-rw-r--r--ironic/tests/unit/common/test_images.py56
-rw-r--r--ironic/tests/unit/common/test_pxe_utils.py15
-rw-r--r--ironic/tests/unit/common/test_release_mappings.py7
-rw-r--r--ironic/tests/unit/common/test_states.py4
-rw-r--r--ironic/tests/unit/common/test_swift.py21
-rw-r--r--ironic/tests/unit/conductor/test_manager.py11
-rw-r--r--ironic/tests/unit/db/test_chassis.py5
-rw-r--r--ironic/tests/unit/db/test_deploy_templates.py9
-rw-r--r--ironic/tests/unit/db/test_nodes.py5
-rw-r--r--ironic/tests/unit/db/test_portgroups.py9
-rw-r--r--ironic/tests/unit/db/test_ports.py11
-rw-r--r--ironic/tests/unit/db/test_volume_connectors.py7
-rw-r--r--ironic/tests/unit/db/test_volume_targets.py7
-rw-r--r--ironic/tests/unit/dhcp/test_factory.py3
-rw-r--r--ironic/tests/unit/drivers/modules/ansible/test_deploy.py15
-rw-r--r--ironic/tests/unit/drivers/modules/ilo/test_boot.py18
-rw-r--r--ironic/tests/unit/drivers/modules/ilo/test_common.py25
-rw-r--r--ironic/tests/unit/drivers/modules/ilo/test_console.py6
-rw-r--r--ironic/tests/unit/drivers/modules/ilo/test_firmware_processor.py13
-rw-r--r--ironic/tests/unit/drivers/modules/ilo/test_inspect.py3
-rw-r--r--ironic/tests/unit/drivers/modules/irmc/test_boot.py10
-rw-r--r--ironic/tests/unit/drivers/modules/test_agent_client.py5
-rw-r--r--ironic/tests/unit/drivers/modules/test_image_cache.py7
-rw-r--r--ironic/tests/unit/drivers/modules/test_ipmitool.py14
-rw-r--r--ironic/tests/unit/drivers/modules/xclarity/test_management.py6
-rw-r--r--ironic/tests/unit/drivers/modules/xclarity/test_power.py6
-rw-r--r--ironic/tests/unit/drivers/third_party_driver_mocks.py18
-rw-r--r--ironic/tests/unit/objects/test_objects.py3
-rw-r--r--ironic/tests/unit/objects/utils.py6
-rw-r--r--lower-constraints.txt1
-rw-r--r--requirements.txt1
109 files changed, 334 insertions, 433 deletions
diff --git a/ironic/api/controllers/v1/allocation.py b/ironic/api/controllers/v1/allocation.py
index 8022a077a..0e305dc3d 100644
--- a/ironic/api/controllers/v1/allocation.py
+++ b/ironic/api/controllers/v1/allocation.py
@@ -11,11 +11,11 @@
# under the License.
import datetime
+from http import client as http_client
from ironic_lib import metrics_utils
from oslo_utils import uuidutils
import pecan
-from six.moves import http_client
from webob import exc as webob_exc
import wsme
from wsme import types as wtypes
diff --git a/ironic/api/controllers/v1/chassis.py b/ironic/api/controllers/v1/chassis.py
index b446d815e..91c776e8e 100644
--- a/ironic/api/controllers/v1/chassis.py
+++ b/ironic/api/controllers/v1/chassis.py
@@ -14,11 +14,11 @@
# under the License.
import datetime
+from http import client as http_client
from ironic_lib import metrics_utils
from oslo_utils import uuidutils
from pecan import rest
-from six.moves import http_client
import wsme
from wsme import types as wtypes
diff --git a/ironic/api/controllers/v1/deploy_template.py b/ironic/api/controllers/v1/deploy_template.py
index bc713d97c..ccd0b74b3 100644
--- a/ironic/api/controllers/v1/deploy_template.py
+++ b/ironic/api/controllers/v1/deploy_template.py
@@ -12,6 +12,7 @@
import collections
import datetime
+from http import client as http_client
from ironic_lib import metrics_utils
from oslo_log import log
@@ -19,7 +20,6 @@ from oslo_utils import strutils
from oslo_utils import uuidutils
import pecan
from pecan import rest
-from six.moves import http_client
from webob import exc as webob_exc
import wsme
from wsme import types as wtypes
diff --git a/ironic/api/controllers/v1/driver.py b/ironic/api/controllers/v1/driver.py
index 9a6672cd7..c4e4c936d 100644
--- a/ironic/api/controllers/v1/driver.py
+++ b/ironic/api/controllers/v1/driver.py
@@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from http import client as http_client
+
from ironic_lib import metrics_utils
from pecan import rest
-from six.moves import http_client
import wsme
from wsme import types as wtypes
diff --git a/ironic/api/controllers/v1/event.py b/ironic/api/controllers/v1/event.py
index 5a133f2dd..477c57b90 100644
--- a/ironic/api/controllers/v1/event.py
+++ b/ironic/api/controllers/v1/event.py
@@ -10,10 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from http import client as http_client
+
from ironic_lib import metrics_utils
from oslo_log import log
import pecan
-from six.moves import http_client
from ironic import api
from ironic.api.controllers.v1 import collection
diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py
index 3c168a6d1..305b88a22 100644
--- a/ironic/api/controllers/v1/node.py
+++ b/ironic/api/controllers/v1/node.py
@@ -14,6 +14,7 @@
# under the License.
import datetime
+from http import client as http_client
from ironic_lib import metrics_utils
import jsonschema
@@ -22,7 +23,6 @@ from oslo_utils import strutils
from oslo_utils import uuidutils
import pecan
from pecan import rest
-from six.moves import http_client
import wsme
from wsme import types as wtypes
diff --git a/ironic/api/controllers/v1/port.py b/ironic/api/controllers/v1/port.py
index e824be8b1..982ac6572 100644
--- a/ironic/api/controllers/v1/port.py
+++ b/ironic/api/controllers/v1/port.py
@@ -14,12 +14,12 @@
# under the License.
import datetime
+from http import client as http_client
from ironic_lib import metrics_utils
from oslo_log import log
from oslo_utils import uuidutils
from pecan import rest
-from six.moves import http_client
import wsme
from wsme import types as wtypes
diff --git a/ironic/api/controllers/v1/portgroup.py b/ironic/api/controllers/v1/portgroup.py
index 27a21e089..6fa1dec44 100644
--- a/ironic/api/controllers/v1/portgroup.py
+++ b/ironic/api/controllers/v1/portgroup.py
@@ -11,11 +11,11 @@
# under the License.
import datetime
+from http import client as http_client
from ironic_lib import metrics_utils
from oslo_utils import uuidutils
import pecan
-from six.moves import http_client
import wsme
from wsme import types as wtypes
diff --git a/ironic/api/controllers/v1/ramdisk.py b/ironic/api/controllers/v1/ramdisk.py
index cab6ef28c..56c182e8b 100644
--- a/ironic/api/controllers/v1/ramdisk.py
+++ b/ironic/api/controllers/v1/ramdisk.py
@@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from http import client as http_client
+
from oslo_config import cfg
from oslo_log import log
from pecan import rest
-from six.moves import http_client
from wsme import types as wtypes
from ironic import api
diff --git a/ironic/api/controllers/v1/types.py b/ironic/api/controllers/v1/types.py
index c478c2817..d7cf999fe 100644
--- a/ironic/api/controllers/v1/types.py
+++ b/ironic/api/controllers/v1/types.py
@@ -21,7 +21,6 @@ import json
from oslo_log import log
from oslo_utils import strutils
from oslo_utils import uuidutils
-import six
import wsme
from wsme import types as wtypes
@@ -121,7 +120,7 @@ class BooleanType(wtypes.UserType):
return strutils.bool_from_string(value, strict=True)
except ValueError as e:
# raise Invalid to return 400 (BadRequest) in the API
- raise exception.Invalid(six.text_type(e))
+ raise exception.Invalid(str(e))
@staticmethod
def frombasetype(value):
@@ -138,7 +137,7 @@ class JsonType(wtypes.UserType):
def __str__(self):
# These are the json serializable native types
- return ' | '.join(map(str, (wtypes.text, six.integer_types, float,
+ return ' | '.join(map(str, (wtypes.text, int, float,
BooleanType, list, dict, None)))
@staticmethod
@@ -170,7 +169,7 @@ class ListType(wtypes.UserType):
same order
"""
items = []
- for v in six.text_type(value).split(','):
+ for v in str(value).split(','):
v_norm = v.strip().lower()
if v_norm and v_norm not in items:
items.append(v_norm)
diff --git a/ironic/api/controllers/v1/utils.py b/ironic/api/controllers/v1/utils.py
index cb8156db8..158468423 100644
--- a/ironic/api/controllers/v1/utils.py
+++ b/ironic/api/controllers/v1/utils.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from http import client as http_client
import inspect
import re
@@ -23,8 +24,6 @@ import os_traits
from oslo_config import cfg
from oslo_utils import uuidutils
from pecan import rest
-import six
-from six.moves import http_client
from webob import static
import wsme
@@ -103,7 +102,7 @@ def validate_trait(trait, error_prefix=_('Invalid trait')):
'A custom trait must start with the prefix CUSTOM_ and use '
'the following characters: A-Z, 0-9 and _') %
{'error_prefix': error_prefix})
- if not isinstance(trait, six.string_types):
+ if not isinstance(trait, str):
raise error
if len(trait) > 255 or len(trait) < 1:
@@ -422,7 +421,7 @@ def vendor_passthru(ident, method, topic, data=None, driver_passthru=False):
# Attach the return value to the response object
if response.get('attach'):
- if isinstance(return_value, six.text_type):
+ if isinstance(return_value, str):
# If unicode, convert to bytes
return_value = return_value.encode('utf-8')
file_ = wsme.types.File(content=return_value)
diff --git a/ironic/api/controllers/v1/volume.py b/ironic/api/controllers/v1/volume.py
index 4e9f6aef2..50843066a 100644
--- a/ironic/api/controllers/v1/volume.py
+++ b/ironic/api/controllers/v1/volume.py
@@ -12,9 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from http import client as http_client
+
import pecan
from pecan import rest
-from six.moves import http_client
import wsme
from ironic import api
diff --git a/ironic/api/controllers/v1/volume_connector.py b/ironic/api/controllers/v1/volume_connector.py
index 8dcb36619..af19f1922 100644
--- a/ironic/api/controllers/v1/volume_connector.py
+++ b/ironic/api/controllers/v1/volume_connector.py
@@ -13,12 +13,11 @@
# under the License.
import datetime
+from http import client as http_client
from ironic_lib import metrics_utils
from oslo_utils import uuidutils
from pecan import rest
-import six
-from six.moves import http_client
import wsme
from wsme import types as wtypes
@@ -417,7 +416,7 @@ class VolumeConnectorsController(rest.RestController):
for value in values:
if not uuidutils.is_uuid_like(value):
message = _("Expected a UUID for node_uuid, but received "
- "%(uuid)s.") % {'uuid': six.text_type(value)}
+ "%(uuid)s.") % {'uuid': str(value)}
raise exception.InvalidUUID(message=message)
rpc_connector = objects.VolumeConnector.get_by_uuid(context,
diff --git a/ironic/api/controllers/v1/volume_target.py b/ironic/api/controllers/v1/volume_target.py
index 63afd35af..b4c2f89f6 100644
--- a/ironic/api/controllers/v1/volume_target.py
+++ b/ironic/api/controllers/v1/volume_target.py
@@ -13,12 +13,11 @@
# under the License.
import datetime
+from http import client as http_client
from ironic_lib import metrics_utils
from oslo_utils import uuidutils
from pecan import rest
-import six
-from six.moves import http_client
import wsme
from wsme import types as wtypes
@@ -429,7 +428,7 @@ class VolumeTargetsController(rest.RestController):
for value in values:
if not uuidutils.is_uuid_like(value):
message = _("Expected a UUID for node_uuid, but received "
- "%(uuid)s.") % {'uuid': six.text_type(value)}
+ "%(uuid)s.") % {'uuid': str(value)}
raise exception.InvalidUUID(message=message)
rpc_target = objects.VolumeTarget.get_by_uuid(context, target_uuid)
diff --git a/ironic/api/hooks.py b/ironic/api/hooks.py
index 9ce7b0f79..2e7cc9e7a 100644
--- a/ironic/api/hooks.py
+++ b/ironic/api/hooks.py
@@ -14,13 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from http import client as http_client
import re
from oslo_config import cfg
from oslo_log import log
from pecan import hooks
-import six
-from six.moves import http_client
from ironic.common import context
from ironic.common import policy
@@ -48,7 +47,7 @@ def policy_deprecation_check():
}
policy_rules = enforcer.file_rules.values()
for rule in policy_rules:
- str_rule = six.text_type(rule)
+ str_rule = str(rule)
for deprecated, replacement in substitution_dict.items():
if re.search(r'\b%s\b' % deprecated, str_rule):
LOG.warning(
diff --git a/ironic/api/middleware/parsable_error.py b/ironic/api/middleware/parsable_error.py
index 88208aa63..cc02ab464 100644
--- a/ironic/api/middleware/parsable_error.py
+++ b/ironic/api/middleware/parsable_error.py
@@ -23,7 +23,6 @@ Based on pecan.middleware.errordocument
import json
from oslo_log import log
-import six
from ironic.common.i18n import _
@@ -69,11 +68,9 @@ class ParsableErrorMiddleware(object):
app_iter = self.app(environ, replacement_start_response)
if (state['status_code'] // 100) not in (2, 3):
- if six.PY3:
- app_iter = [i.decode('utf-8') for i in app_iter]
+ app_iter = [i.decode('utf-8') for i in app_iter]
body = [json.dumps({'error_message': '\n'.join(app_iter)})]
- if six.PY3:
- body = [item.encode('utf-8') for item in body]
+ body = [item.encode('utf-8') for item in body]
state['headers'].append(('Content-Type', 'application/json'))
state['headers'].append(('Content-Length', str(len(body[0]))))
else:
diff --git a/ironic/common/exception.py b/ironic/common/exception.py
index b03e4a87f..1d100f832 100644
--- a/ironic/common/exception.py
+++ b/ironic/common/exception.py
@@ -16,9 +16,10 @@
"""Ironic specific exceptions list."""
+from http import client as http_client
+
from ironic_lib.exception import IronicException
from oslo_log import log as logging
-from six.moves import http_client
from ironic.common.i18n import _
diff --git a/ironic/common/fsm.py b/ironic/common/fsm.py
index 7f1e193bd..7dcc30ab8 100644
--- a/ironic/common/fsm.py
+++ b/ironic/common/fsm.py
@@ -12,9 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+import functools
+
from automaton import exceptions as automaton_exceptions
from automaton import machines
-import six
"""State machine modelling.
@@ -31,7 +32,7 @@ from ironic.common.i18n import _
def _translate_excp(func):
"""Decorator to translate automaton exceptions into ironic exceptions."""
- @six.wraps(func)
+ @functools.wraps(func)
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
@@ -39,9 +40,9 @@ def _translate_excp(func):
automaton_exceptions.NotInitialized,
automaton_exceptions.FrozenMachine,
automaton_exceptions.NotFound) as e:
- raise excp.InvalidState(six.text_type(e))
+ raise excp.InvalidState(str(e))
except automaton_exceptions.Duplicate as e:
- raise excp.Duplicate(six.text_type(e))
+ raise excp.Duplicate(str(e))
return wrapper
diff --git a/ironic/common/glance_service/image_service.py b/ironic/common/glance_service/image_service.py
index e3d74d38c..e1a9bbf87 100644
--- a/ironic/common/glance_service/image_service.py
+++ b/ironic/common/glance_service/image_service.py
@@ -14,18 +14,18 @@
# under the License.
import collections
+import functools
import os
import re
import sys
import time
+from urllib import parse as urlparse
from glanceclient import client
from glanceclient import exc as glance_exc
from oslo_log import log
from oslo_utils import uuidutils
import sendfile
-import six
-from six.moves.urllib import parse as urlparse
from swiftclient import utils as swift_utils
from ironic.common import exception
@@ -56,7 +56,7 @@ def _translate_image_exception(image_id, exc_value):
def check_image_service(func):
"""Creates a glance client if doesn't exists and calls the function."""
- @six.wraps(func)
+ @functools.wraps(func)
def wrapper(self, *args, **kwargs):
"""Wrapper around methods calls.
@@ -153,7 +153,7 @@ class GlanceImageService(object):
exc_type, exc_value, exc_trace = sys.exc_info()
new_exc = _translate_image_exception(
args[0], exc_value)
- six.reraise(type(new_exc), new_exc, exc_trace)
+ raise type(new_exc)(new_exc).with_traceback(exc_trace)
@check_image_service
def show(self, image_href):
diff --git a/ironic/common/glance_service/service_utils.py b/ironic/common/glance_service/service_utils.py
index 601895e01..d7a702285 100644
--- a/ironic/common/glance_service/service_utils.py
+++ b/ironic/common/glance_service/service_utils.py
@@ -19,7 +19,6 @@ import copy
from oslo_serialization import jsonutils
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
from ironic.common import exception
@@ -70,7 +69,7 @@ def _convert(metadata):
for attr in _CONVERT_PROPS:
if attr in properties:
prop = properties[attr]
- if isinstance(prop, six.string_types):
+ if isinstance(prop, str):
properties[attr] = jsonutils.loads(prop)
return metadata
@@ -83,7 +82,7 @@ def parse_image_id(image_href):
:raises InvalidImageRef: when input image href is invalid
"""
- image_href = six.text_type(image_href)
+ image_href = str(image_href)
if uuidutils.is_uuid_like(image_href):
image_id = image_href
elif image_href.startswith('glance://'):
@@ -130,7 +129,7 @@ def is_image_active(image):
def is_glance_image(image_href):
- if not isinstance(image_href, six.string_types):
+ if not isinstance(image_href, str):
return False
return (image_href.startswith('glance://')
or uuidutils.is_uuid_like(image_href))
diff --git a/ironic/common/image_service.py b/ironic/common/image_service.py
index bde9173d0..c9c7026af 100644
--- a/ironic/common/image_service.py
+++ b/ironic/common/image_service.py
@@ -17,16 +17,15 @@
import abc
import datetime
+from http import client as http_client
import os
import shutil
+from urllib import parse as urlparse
from oslo_log import log
from oslo_utils import uuidutils
import requests
import sendfile
-import six
-from six.moves import http_client
-import six.moves.urllib.parse as urlparse
from ironic.common import exception
from ironic.common.glance_service import image_service
@@ -45,8 +44,7 @@ LOG = log.getLogger(__name__)
GlanceImageService = image_service.GlanceImageService
-@six.add_metaclass(abc.ABCMeta)
-class BaseImageService(object):
+class BaseImageService(object, metaclass=abc.ABCMeta):
"""Provides retrieval of disk images."""
@abc.abstractmethod
@@ -103,7 +101,7 @@ class HttpImageService(BaseImageService):
"HEAD request.") % response.status_code)
except requests.RequestException as e:
raise exception.ImageRefValidationFailed(image_href=output_url,
- reason=six.text_type(e))
+ reason=str(e))
return response
def download(self, image_href, image_file):
@@ -128,7 +126,7 @@ class HttpImageService(BaseImageService):
shutil.copyfileobj(input_img, image_file, IMAGE_CHUNK_SIZE)
except (requests.RequestException, IOError) as e:
raise exception.ImageDownloadFailed(image_href=image_href,
- reason=six.text_type(e))
+ reason=str(e))
def show(self, image_href):
"""Get dictionary of image properties.
@@ -228,7 +226,7 @@ class FileImageService(BaseImageService):
offset += nbytes_out
except Exception as e:
raise exception.ImageDownloadFailed(image_href=image_href,
- reason=six.text_type(e))
+ reason=str(e))
def show(self, image_href):
"""Get dictionary of image properties.
@@ -272,7 +270,7 @@ def get_image_service(image_href, client=None, context=None):
scheme = urlparse.urlparse(image_href).scheme.lower()
if not scheme:
- if uuidutils.is_uuid_like(six.text_type(image_href)):
+ if uuidutils.is_uuid_like(str(image_href)):
cls = GlanceImageService
else:
raise exception.ImageRefValidationFailed(
diff --git a/ironic/common/keystone.py b/ironic/common/keystone.py
index 90645e168..233533b55 100644
--- a/ironic/common/keystone.py
+++ b/ironic/common/keystone.py
@@ -14,12 +14,13 @@
"""Central place for handling Keystone authorization and service lookup."""
+import functools
+
from keystoneauth1 import exceptions as kaexception
from keystoneauth1 import loading as kaloading
from keystoneauth1 import service_token
from keystoneauth1 import token_endpoint
from oslo_log import log as logging
-import six
from ironic.common import exception
from ironic.conf import CONF
@@ -30,7 +31,7 @@ LOG = logging.getLogger(__name__)
def ks_exceptions(f):
"""Wraps keystoneclient functions and centralizes exception handling."""
- @six.wraps(f)
+ @functools.wraps(f)
def wrapper(*args, **kwargs):
try:
return f(*args, **kwargs)
@@ -43,11 +44,11 @@ def ks_exceptions(f):
raise exception.KeystoneUnauthorized()
except (kaexception.NoMatchingPlugin,
kaexception.MissingRequiredOptions) as e:
- raise exception.ConfigInvalid(six.text_type(e))
+ raise exception.ConfigInvalid(str(e))
except Exception as e:
LOG.exception('Keystone request failed: %(msg)s',
- {'msg': six.text_type(e)})
- raise exception.KeystoneFailure(six.text_type(e))
+ {'msg': str(e)})
+ raise exception.KeystoneFailure(str(e))
return wrapper
diff --git a/ironic/common/swift.py b/ironic/common/swift.py
index b1f5dec34..7340912d6 100644
--- a/ironic/common/swift.py
+++ b/ironic/common/swift.py
@@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
-from six.moves import http_client
-from six.moves.urllib import parse
+from http import client as http_client
+from urllib import parse as urlparse
+
from swiftclient import client as swift_client
from swiftclient import exceptions as swift_exceptions
from swiftclient import utils as swift_utils
@@ -69,7 +69,7 @@ class SwiftAPI(object):
params['timeout'] = session.timeout
if session.verify is False:
params['insecure'] = True
- elif isinstance(session.verify, six.string_types):
+ elif isinstance(session.verify, str):
params['cacert'] = session.verify
if session.cert:
# NOTE(pas-ha) although setting cert as path to single file
@@ -129,17 +129,14 @@ class SwiftAPI(object):
raise exception.SwiftOperationError(operation=operation,
error=e)
- parse_result = parse.urlparse(self.connection.url)
+ parse_result = urlparse.urlparse(self.connection.url)
swift_object_path = '/'.join((parse_result.path, container, obj))
temp_url_key = account_info['x-account-meta-temp-url-key']
url_path = swift_utils.generate_temp_url(swift_object_path, timeout,
temp_url_key, 'GET')
- return parse.urlunparse((parse_result.scheme,
- parse_result.netloc,
- url_path,
- None,
- None,
- None))
+ return urlparse.urlunparse(
+ (parse_result.scheme, parse_result.netloc, url_path,
+ None, None, None))
def delete_object(self, container, obj):
"""Deletes the given Swift object.
diff --git a/ironic/common/utils.py b/ironic/common/utils.py
index f170dabdf..16453d74e 100644
--- a/ironic/common/utils.py
+++ b/ironic/common/utils.py
@@ -35,7 +35,6 @@ from oslo_utils import fileutils
from oslo_utils import netutils
from oslo_utils import timeutils
import pytz
-import six
from ironic.common import exception
from ironic.common.i18n import _
@@ -92,7 +91,7 @@ def is_valid_datapath_id(datapath_id):
"""
m = "^[0-9a-f]{16}$"
- return (isinstance(datapath_id, six.string_types)
+ return (isinstance(datapath_id, str)
and re.match(m, datapath_id.lower()))
@@ -114,7 +113,7 @@ def is_valid_logical_name(hostname):
ALPHA / DIGIT / "-" / "." / "_" / "~"
"""
- if not isinstance(hostname, six.string_types) or len(hostname) > 255:
+ if not isinstance(hostname, str) or len(hostname) > 255:
return False
return _is_valid_logical_name_re.match(hostname) is not None
@@ -136,7 +135,7 @@ def is_hostname_safe(hostname):
:param hostname: The hostname to be validated.
:returns: True if valid. False if not.
"""
- if not isinstance(hostname, six.string_types) or len(hostname) > 255:
+ if not isinstance(hostname, str) or len(hostname) > 255:
return False
return _is_hostname_safe_re.match(hostname) is not None
@@ -153,7 +152,7 @@ def is_valid_no_proxy(no_proxy):
(with optional :port).
:returns: True if no_proxy is valid, False otherwise.
"""
- if not isinstance(no_proxy, six.string_types):
+ if not isinstance(no_proxy, str):
return False
hostname_re = re.compile('(?!-)[A-Z\\d-]{1,63}(?<!-)$', re.IGNORECASE)
for hostname in no_proxy.split(','):
@@ -219,8 +218,7 @@ def _get_hash_object(hash_algo_name):
:raises: InvalidParameterValue, on unsupported or invalid input.
:returns: a hash object based on the given named algorithm.
"""
- algorithms = (hashlib.algorithms_guaranteed if six.PY3
- else hashlib.algorithms)
+ algorithms = hashlib.algorithms_guaranteed
if hash_algo_name not in algorithms:
msg = (_("Unsupported/Invalid hash name '%s' provided.")
% hash_algo_name)
@@ -242,7 +240,7 @@ def file_has_content(path, content, hash_algo='md5'):
file_hash_hex = fileutils.compute_file_checksum(path, algorithm=hash_algo)
ref_hash = _get_hash_object(hash_algo)
encoded_content = (content.encode(encoding='utf-8')
- if isinstance(content, six.string_types) else content)
+ if isinstance(content, str) else content)
ref_hash.update(encoded_content)
return file_hash_hex == ref_hash.hexdigest()
@@ -294,7 +292,7 @@ def safe_rstrip(value, chars=None):
:return: Stripped value.
"""
- if not isinstance(value, six.string_types):
+ if not isinstance(value, str):
LOG.warning("Failed to remove trailing character. Returning "
"original object. Supplied object is not a string: "
"%s,", value)
@@ -515,7 +513,7 @@ def parse_instance_info_capabilities(node):
raise exception.InvalidParameterValue(error_msg)
capabilities = node.instance_info.get('capabilities', {})
- if isinstance(capabilities, six.string_types):
+ if isinstance(capabilities, str):
try:
capabilities = jsonutils.loads(capabilities)
except (ValueError, TypeError):
@@ -528,7 +526,7 @@ def parse_instance_info_capabilities(node):
def validate_conductor_group(conductor_group):
- if not isinstance(conductor_group, six.string_types):
+ if not isinstance(conductor_group, str):
raise exception.InvalidConductorGroup(group=conductor_group)
if not re.match(r'^[a-zA-Z0-9_\-\.]*$', conductor_group):
raise exception.InvalidConductorGroup(group=conductor_group)
diff --git a/ironic/conductor/base_manager.py b/ironic/conductor/base_manager.py
index c89599df8..d610d2163 100644
--- a/ironic/conductor/base_manager.py
+++ b/ironic/conductor/base_manager.py
@@ -24,7 +24,6 @@ from oslo_db import exception as db_exception
from oslo_log import log
from oslo_utils import excutils
from oslo_utils import versionutils
-import six
from ironic.common import context as ironic_context
from ironic.common import driver_factory
@@ -471,7 +470,7 @@ class BaseConductorManager(object):
fsm.
"""
- if isinstance(provision_state, six.string_types):
+ if isinstance(provision_state, str):
provision_state = {provision_state}
node_iter = self.iter_nodes(filters=filters,
diff --git a/ironic/conductor/manager.py b/ironic/conductor/manager.py
index f629f685f..8b4ab8dea 100644
--- a/ironic/conductor/manager.py
+++ b/ironic/conductor/manager.py
@@ -42,6 +42,7 @@ notifying Neutron of a change, etc.
import collections
import datetime
+import queue
import tempfile
import eventlet
@@ -54,7 +55,6 @@ import oslo_messaging as messaging
from oslo_utils import excutils
from oslo_utils import uuidutils
from oslo_utils import versionutils
-from six.moves import queue
from ironic.common import driver_factory
from ironic.common import exception
diff --git a/ironic/conductor/task_manager.py b/ironic/conductor/task_manager.py
index b99cd1084..09aeb6c65 100644
--- a/ironic/conductor/task_manager.py
+++ b/ironic/conductor/task_manager.py
@@ -101,6 +101,7 @@ raised in the background thread.):
"""
import copy
+import functools
import futurist
from oslo_config import cfg
@@ -108,7 +109,6 @@ from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import timeutils
import retrying
-import six
from ironic.common import driver_factory
from ironic.common import exception
@@ -131,7 +131,7 @@ def require_exclusive_lock(f):
as the first parameter after "self".
"""
- @six.wraps(f)
+ @functools.wraps(f)
def wrapper(*args, **kwargs):
# NOTE(dtantsur): this code could be written simpler, but then unit
# testing decorated functions is pretty hard, as we usually pass a Mock
@@ -378,7 +378,7 @@ class TaskManager(object):
if exc is not None:
msg = _("Async execution of %(method)s failed with error: "
"%(error)s") % {'method': method,
- 'error': six.text_type(exc)}
+ 'error': str(exc)}
node.last_error = msg
try:
node.save()
diff --git a/ironic/conductor/utils.py b/ironic/conductor/utils.py
index 5e213c5f4..907b2f991 100644
--- a/ironic/conductor/utils.py
+++ b/ironic/conductor/utils.py
@@ -23,7 +23,6 @@ from oslo_serialization import jsonutils
from oslo_service import loopingcall
from oslo_utils import excutils
from oslo_utils import timeutils
-import six
from ironic.common import boot_devices
from ironic.common import exception
@@ -731,7 +730,7 @@ def validate_instance_info_traits(node):
instance_traits = node.instance_info['traits']
if not isinstance(instance_traits, list):
invalid()
- if not all(isinstance(t, six.string_types) for t in instance_traits):
+ if not all(isinstance(t, str) for t in instance_traits):
invalid()
node_traits = node.traits.get_trait_names()
diff --git a/ironic/db/api.py b/ironic/db/api.py
index 73e47dae8..9ad5e2979 100644
--- a/ironic/db/api.py
+++ b/ironic/db/api.py
@@ -21,7 +21,6 @@ import abc
from oslo_config import cfg
from oslo_db import api as db_api
-import six
_BACKEND_MAPPING = {'sqlalchemy': 'ironic.db.sqlalchemy.api'}
@@ -34,8 +33,7 @@ def get_instance():
return IMPL
-@six.add_metaclass(abc.ABCMeta)
-class Connection(object):
+class Connection(object, metaclass=abc.ABCMeta):
"""Base class for storage system connections."""
@abc.abstractmethod
diff --git a/ironic/db/sqlalchemy/models.py b/ironic/db/sqlalchemy/models.py
index 4554eba90..dc5127e3e 100644
--- a/ironic/db/sqlalchemy/models.py
+++ b/ironic/db/sqlalchemy/models.py
@@ -19,11 +19,11 @@ SQLAlchemy models for baremetal data.
"""
from os import path
+from urllib import parse as urlparse
from oslo_db import options as db_options
from oslo_db.sqlalchemy import models
from oslo_db.sqlalchemy import types as db_types
-import six.moves.urllib.parse as urlparse
from sqlalchemy import Boolean, Column, DateTime, false, Index
from sqlalchemy import ForeignKey, Integer
from sqlalchemy import schema, String, Text
diff --git a/ironic/dhcp/base.py b/ironic/dhcp/base.py
index 39fa34c7c..8fad59ce7 100644
--- a/ironic/dhcp/base.py
+++ b/ironic/dhcp/base.py
@@ -20,13 +20,11 @@ Abstract base class for dhcp providers.
import abc
from oslo_log import log as logging
-import six
LOG = logging.getLogger(__name__)
-@six.add_metaclass(abc.ABCMeta)
-class BaseDHCP(object):
+class BaseDHCP(object, metaclass=abc.ABCMeta):
"""Base class for DHCP provider APIs."""
@abc.abstractmethod
diff --git a/ironic/drivers/base.py b/ironic/drivers/base.py
index 7508adbb8..a407cf536 100644
--- a/ironic/drivers/base.py
+++ b/ironic/drivers/base.py
@@ -20,13 +20,13 @@ Abstract base classes for drivers.
import abc
import collections
import copy
+import functools
import inspect
import json
import os
from oslo_log import log as logging
from oslo_utils import excutils
-import six
from ironic.common import exception
from ironic.common.i18n import _
@@ -189,8 +189,7 @@ ALL_INTERFACES = set(BareDriver().all_interfaces)
"""Constant holding all known interfaces."""
-@six.add_metaclass(abc.ABCMeta)
-class BaseInterface(object):
+class BaseInterface(object, metaclass=abc.ABCMeta):
"""A base interface implementing common functions for Driver Interfaces."""
supported = True
@@ -747,7 +746,7 @@ def _passthru(http_methods, method=None, async_call=True,
passthru_logmessage = 'vendor_passthru failed with method %s'
- @six.wraps(func)
+ @functools.wraps(func)
def passthru_handler(*args, **kwargs):
try:
return func(*args, **kwargs)
@@ -1138,7 +1137,7 @@ def cache_bios_settings(func):
:param func: Function or method to wrap.
"""
- @six.wraps(func)
+ @functools.wraps(func)
def wrapped(self, task, *args, **kwargs):
result = func(self, task, *args, **kwargs)
self.cache_bios_settings(task)
@@ -1545,8 +1544,7 @@ class NetworkInterface(BaseInterface):
return False
-@six.add_metaclass(abc.ABCMeta)
-class StorageInterface(BaseInterface):
+class StorageInterface(BaseInterface, metaclass=abc.ABCMeta):
"""Base class for storage interfaces."""
interface_type = 'storage'
@@ -1609,7 +1607,7 @@ def _validate_argsinfo(argsinfo):
has_description = False
for (key, value) in info.items():
if key == 'description':
- if not isinstance(value, six.string_types):
+ if not isinstance(value, str):
raise exception.InvalidParameterValue(
_('For argument "%(arg)s", "description" must be a '
'string value instead of "%(value)s".') %
diff --git a/ironic/drivers/hardware_type.py b/ironic/drivers/hardware_type.py
index ec42cb3bf..0ec71210e 100644
--- a/ironic/drivers/hardware_type.py
+++ b/ironic/drivers/hardware_type.py
@@ -18,8 +18,6 @@ Abstract base class for all hardware types.
import abc
-import six
-
from ironic.common import exception
from ironic.drivers import base as driver_base
from ironic.drivers.modules.network import noop as noop_net
@@ -27,8 +25,7 @@ from ironic.drivers.modules import noop
from ironic.drivers.modules.storage import noop as noop_storage
-@six.add_metaclass(abc.ABCMeta)
-class AbstractHardwareType(object):
+class AbstractHardwareType(object, metaclass=abc.ABCMeta):
"""Abstract base class for all hardware types.
Hardware type is a family of hardware supporting the same set of interfaces
diff --git a/ironic/drivers/modules/agent.py b/ironic/drivers/modules/agent.py
index 1154bdb14..5e7d18e04 100644
--- a/ironic/drivers/modules/agent.py
+++ b/ironic/drivers/modules/agent.py
@@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from urllib import parse as urlparse
+
from ironic_lib import metrics_utils
from ironic_lib import utils as il_utils
from oslo_log import log
from oslo_utils import excutils
from oslo_utils import units
-import six.moves.urllib_parse as urlparse
from ironic.common import dhcp_factory
from ironic.common import exception
diff --git a/ironic/drivers/modules/agent_client.py b/ironic/drivers/modules/agent_client.py
index 0e3fcb57b..d9d14c380 100644
--- a/ironic/drivers/modules/agent_client.py
+++ b/ironic/drivers/modules/agent_client.py
@@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from http import client as http_client
+
from ironic_lib import metrics_utils
from oslo_log import log
from oslo_serialization import jsonutils
import requests
import retrying
-from six.moves import http_client
from ironic.common import exception
from ironic.common.i18n import _
diff --git a/ironic/drivers/modules/ansible/deploy.py b/ironic/drivers/modules/ansible/deploy.py
index b40df6cf6..51d7f7b04 100644
--- a/ironic/drivers/modules/ansible/deploy.py
+++ b/ironic/drivers/modules/ansible/deploy.py
@@ -18,6 +18,7 @@ Ansible deploy interface
import json
import os
import shlex
+from urllib import parse as urlparse
from ironic_lib import metrics_utils
from ironic_lib import utils as irlib_utils
@@ -26,8 +27,6 @@ from oslo_log import log
from oslo_utils import strutils
from oslo_utils import units
import retrying
-import six
-import six.moves.urllib.parse as urlparse
import yaml
from ironic.common import dhcp_factory
@@ -242,7 +241,7 @@ def _parse_root_device_hints(node):
root_device_hints = {}
advanced = {}
for hint, value in parsed_hints.items():
- if isinstance(value, six.string_types):
+ if isinstance(value, str):
if value.startswith('== '):
root_device_hints[hint] = int(value[3:])
elif value.startswith('s== '):
diff --git a/ironic/drivers/modules/ansible/playbooks/callback_plugins/ironic_log.py b/ironic/drivers/modules/ansible/playbooks/callback_plugins/ironic_log.py
index fde84d4d9..b8e4c3c69 100644
--- a/ironic/drivers/modules/ansible/playbooks/callback_plugins/ironic_log.py
+++ b/ironic/drivers/modules/ansible/playbooks/callback_plugins/ironic_log.py
@@ -11,13 +11,13 @@
# License for the specific language governing permissions and limitations
# under the License.
+import configparser
import os
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import strutils
import pbr.version
-from six.moves import configparser
CONF = cfg.CONF
diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py
index e29b3668c..f8c972853 100644
--- a/ironic/drivers/modules/deploy_utils.py
+++ b/ironic/drivers/modules/deploy_utils.py
@@ -29,7 +29,6 @@ from oslo_utils import excutils
from oslo_utils import fileutils
from oslo_utils import netutils
from oslo_utils import strutils
-import six
from ironic.common import exception
from ironic.common import faults
@@ -126,7 +125,7 @@ def get_ironic_api_url():
raise exception.InvalidParameterValue(_(
"Couldn't get the URL of the Ironic API service from the "
"configuration file or keystone catalog. Keystone error: "
- "%s") % six.text_type(e))
+ "%s") % str(e))
# NOTE: we should strip '/' from the end because it might be used in
# hardcoded ramdisk script
ironic_api = ironic_api.rstrip('/')
diff --git a/ironic/drivers/modules/ibmc/utils.py b/ironic/drivers/modules/ibmc/utils.py
index 5813d65e4..ebe694440 100644
--- a/ironic/drivers/modules/ibmc/utils.py
+++ b/ironic/drivers/modules/ibmc/utils.py
@@ -14,6 +14,7 @@
iBMC Driver common utils
"""
+import functools
import os
from oslo_log import log
@@ -21,7 +22,6 @@ from oslo_utils import importutils
from oslo_utils import netutils
from oslo_utils import strutils
import retrying
-import six
from ironic.common import exception
from ironic.common.i18n import _
@@ -90,7 +90,7 @@ def parse_driver_info(node):
# Check if verify_ca is a Boolean or a file/directory in the file-system
verify_ca = driver_info.get('ibmc_verify_ca', True)
- if isinstance(verify_ca, six.string_types):
+ if isinstance(verify_ca, str):
if not os.path.exists(verify_ca):
try:
verify_ca = strutils.bool_from_string(verify_ca, strict=True)
@@ -138,7 +138,7 @@ def handle_ibmc_exception(action):
retry_on_exception=should_retry,
stop_max_attempt_number=CONF.ibmc.connection_attempts,
wait_fixed=CONF.ibmc.connection_retry_interval * 1000)
- @six.wraps(f)
+ @functools.wraps(f)
def wrapper(*args, **kwargs):
# NOTE(dtantsur): this code could be written simpler, but then unit
# testing decorated functions is pretty hard, as we usually pass a
diff --git a/ironic/drivers/modules/ilo/boot.py b/ironic/drivers/modules/ilo/boot.py
index a15a516c4..e5b8dc23a 100644
--- a/ironic/drivers/modules/ilo/boot.py
+++ b/ironic/drivers/modules/ilo/boot.py
@@ -17,13 +17,13 @@ Boot Interface for iLO drivers and its supporting methods.
import os
import tempfile
+from urllib import parse as urlparse
from ironic_lib import metrics_utils
from ironic_lib import utils as ironic_utils
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
-import six.moves.urllib.parse as urlparse
from ironic.common import boot_devices
from ironic.common import exception
diff --git a/ironic/drivers/modules/ilo/common.py b/ironic/drivers/modules/ilo/common.py
index 625be4dd6..62c6bbb23 100644
--- a/ironic/drivers/modules/ilo/common.py
+++ b/ironic/drivers/modules/ilo/common.py
@@ -19,14 +19,12 @@ Common functionalities shared between different iLO modules.
import os
import shutil
import tempfile
+from urllib import parse as urlparse
from ironic_lib import utils as ironic_utils
from oslo_log import log as logging
from oslo_utils import fileutils
from oslo_utils import importutils
-import six
-import six.moves.urllib.parse as urlparse
-from six.moves.urllib.parse import urljoin
from ironic.common import boot_devices
from ironic.common import exception
@@ -137,7 +135,7 @@ def copy_image_to_web_server(source_file_path, destination):
"""
- image_url = urljoin(CONF.deploy.http_url, destination)
+ image_url = urlparse.urljoin(CONF.deploy.http_url, destination)
image_path = os.path.join(CONF.deploy.http_root, destination)
try:
shutil.copyfile(source_file_path, image_path)
@@ -313,7 +311,7 @@ def _parse_snmp_driver_info(info):
for param in SNMP_OPTIONAL_PROPERTIES:
value = None
try:
- value = six.text_type(info[param]).upper()
+ value = str(info[param]).upper()
except KeyError:
pass
if value:
@@ -781,7 +779,7 @@ def remove_single_or_list_of_files(file_location):
for location in file_location:
ironic_utils.unlink_without_raise(location)
# file_location is a single file path
- elif isinstance(file_location, six.string_types):
+ elif isinstance(file_location, str):
ironic_utils.unlink_without_raise(file_location)
diff --git a/ironic/drivers/modules/ilo/firmware_processor.py b/ironic/drivers/modules/ilo/firmware_processor.py
index 45e3e86a7..53282311e 100644
--- a/ironic/drivers/modules/ilo/firmware_processor.py
+++ b/ironic/drivers/modules/ilo/firmware_processor.py
@@ -15,18 +15,18 @@
Firmware file processor
"""
+import functools
import os
import re
import shutil
import tempfile
import types
+from urllib import parse as urlparse
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import importutils
-import six
-import six.moves.urllib.parse as urlparse
from ironic.common import exception
from ironic.common.i18n import _
@@ -53,7 +53,7 @@ proliantutils_utils = importutils.try_import('proliantutils.utils')
def verify_firmware_update_args(func):
"""Verifies the firmware update arguments."""
- @six.wraps(func)
+ @functools.wraps(func)
def wrapper(self, task, **kwargs):
"""Wrapper around ``update_firmware`` call.
diff --git a/ironic/drivers/modules/ilo/management.py b/ironic/drivers/modules/ilo/management.py
index b8cf400d0..70725fc77 100644
--- a/ironic/drivers/modules/ilo/management.py
+++ b/ironic/drivers/modules/ilo/management.py
@@ -15,13 +15,13 @@
iLO Management Interface
"""
+from urllib import parse as urlparse
+
from ironic_lib import metrics_utils
from oslo_log import log as logging
from oslo_service import loopingcall
from oslo_utils import excutils
from oslo_utils import importutils
-import six
-import six.moves.urllib.parse as urlparse
from ironic.common import boot_devices
from ironic.common import exception
@@ -418,7 +418,7 @@ class IloManagement(base.ManagementInterface):
ilo_license_key = kwargs.get('ilo_license_key')
node = task.node
- if not isinstance(ilo_license_key, six.string_types):
+ if not isinstance(ilo_license_key, str):
msg = (_("Value of 'ilo_license_key' must be a string instead of "
"'%(value)s'. Step 'activate_license' is not executed "
"for %(node)s.")
diff --git a/ironic/drivers/modules/image_cache.py b/ironic/drivers/modules/image_cache.py
index 358a21581..b7ca62fc3 100644
--- a/ironic/drivers/modules/image_cache.py
+++ b/ironic/drivers/modules/image_cache.py
@@ -26,7 +26,6 @@ import uuid
from oslo_concurrency import lockutils
from oslo_log import log as logging
from oslo_utils import fileutils
-import six
from ironic.common import exception
from ironic.common.glance_service import service_utils
@@ -95,11 +94,7 @@ class ImageCache(object):
if service_utils.is_glance_image(href):
master_file_name = service_utils.parse_image_id(href)
else:
- # NOTE(vdrok): Doing conversion of href in case it's unicode
- # string, UUID cannot be generated for unicode strings on python 2.
- href_encoded = href.encode('utf-8') if six.PY2 else href
- master_file_name = str(uuid.uuid5(uuid.NAMESPACE_URL,
- href_encoded))
+ master_file_name = str(uuid.uuid5(uuid.NAMESPACE_URL, href))
# NOTE(kaifeng) The ".converted" suffix acts as an indicator that the
# image cached has gone through the conversion logic.
if force_raw:
diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py
index ffa9a1bae..16c7218f2 100644
--- a/ironic/drivers/modules/ipmitool.py
+++ b/ironic/drivers/modules/ipmitool.py
@@ -43,7 +43,6 @@ from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import strutils
-import six
from ironic.common import boot_devices
from ironic.common import exception
@@ -284,7 +283,7 @@ def _parse_driver_info(node):
address = info.get('ipmi_address')
username = info.get('ipmi_username')
- password = six.text_type(info.get('ipmi_password', ''))
+ password = str(info.get('ipmi_password', ''))
hex_kg_key = info.get('ipmi_hex_kg_key')
dest_port = info.get('ipmi_port')
port = info.get('ipmi_terminal_port')
@@ -528,7 +527,7 @@ def _exec_ipmitool(driver_info, command, check_exit_code=None,
x for x in (
IPMITOOL_RETRYABLE_FAILURES +
CONF.ipmi.additional_retryable_ipmi_errors)
- if x in six.text_type(e)]
+ if x in str(e)]
if ((time.time() > end_time)
or (num_tries == 0)
or not err_list):
diff --git a/ironic/drivers/modules/irmc/boot.py b/ironic/drivers/modules/irmc/boot.py
index 677f56048..76c1d00a2 100644
--- a/ironic/drivers/modules/irmc/boot.py
+++ b/ironic/drivers/modules/irmc/boot.py
@@ -19,12 +19,12 @@ iRMC Boot Driver
import os
import shutil
import tempfile
+from urllib import parse as urlparse
from ironic_lib import metrics_utils
from ironic_lib import utils as ironic_utils
from oslo_log import log as logging
from oslo_utils import importutils
-import six.moves.urllib.parse as urlparse
from ironic.common import boot_devices
from ironic.common import exception
diff --git a/ironic/drivers/modules/irmc/common.py b/ironic/drivers/modules/irmc/common.py
index 9f04d74e1..8f81f8cec 100644
--- a/ironic/drivers/modules/irmc/common.py
+++ b/ironic/drivers/modules/irmc/common.py
@@ -17,7 +17,6 @@ Common functionalities shared between different iRMC modules.
"""
from oslo_log import log as logging
from oslo_utils import importutils
-import six
from ironic.common import exception
from ironic.common.i18n import _
@@ -113,13 +112,13 @@ def parse_driver_info(node):
d_info['irmc_snmp_port'])
if (d_info['irmc_snmp_version'].lower() in ('v1', 'v2c')
and d_info['irmc_snmp_community']
- and not isinstance(d_info['irmc_snmp_community'], six.string_types)):
+ and not isinstance(d_info['irmc_snmp_community'], str)):
error_msgs.append(
_("Value '%s' is not a string for 'irmc_snmp_community'") %
d_info['irmc_snmp_community'])
if d_info['irmc_snmp_version'].lower() == 'v3':
if d_info['irmc_snmp_security']:
- if not isinstance(d_info['irmc_snmp_security'], six.string_types):
+ if not isinstance(d_info['irmc_snmp_security'], str):
error_msgs.append(
_("Value '%s' is not a string for "
"'irmc_snmp_security'") % d_info['irmc_snmp_security'])
diff --git a/ironic/drivers/modules/irmc/raid.py b/ironic/drivers/modules/irmc/raid.py
index e366732a3..901695632 100644
--- a/ironic/drivers/modules/irmc/raid.py
+++ b/ironic/drivers/modules/irmc/raid.py
@@ -19,7 +19,6 @@ from futurist import periodics
from ironic_lib import metrics_utils
from oslo_log import log as logging
from oslo_utils import importutils
-import six
from ironic.common import exception
from ironic.common import raid as raid_common
@@ -392,7 +391,7 @@ class IRMCRAID(base.RAIDInterface):
logical_disks = target_raid_config['logical_disks']
for log_disk in logical_disks:
if log_disk.get('raid_level'):
- log_disk['raid_level'] = six.text_type(
+ log_disk['raid_level'] = str(
log_disk['raid_level']).replace('+', '')
# Validate physical disks on Fujitsu BM Server
diff --git a/ironic/drivers/modules/iscsi_deploy.py b/ironic/drivers/modules/iscsi_deploy.py
index 692b16d20..89603a8e6 100644
--- a/ironic/drivers/modules/iscsi_deploy.py
+++ b/ironic/drivers/modules/iscsi_deploy.py
@@ -13,12 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
+from urllib import parse as urlparse
+
from ironic_lib import disk_utils
from ironic_lib import metrics_utils
from ironic_lib import utils as il_utils
from oslo_log import log as logging
from oslo_utils import excutils
-from six.moves.urllib import parse
from ironic.common import dhcp_factory
from ironic.common import exception
@@ -284,7 +285,7 @@ def do_agent_iscsi_deploy(task, agent_client):
deploy_utils.set_failed_state(task, msg)
raise exception.InstanceDeployFailure(reason=msg)
- address = parse.urlparse(node.driver_internal_info['agent_url'])
+ address = urlparse.urlparse(node.driver_internal_info['agent_url'])
address = address.hostname
uuid_dict_returned = continue_deploy(task, iqn=iqn, address=address,
diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py
index 2ae75b6aa..f3538b6eb 100644
--- a/ironic/drivers/modules/redfish/boot.py
+++ b/ironic/drivers/modules/redfish/boot.py
@@ -16,11 +16,11 @@
import os
import shutil
import tempfile
+from urllib import parse as urlparse
from ironic_lib import utils as ironic_utils
from oslo_log import log
from oslo_utils import importutils
-from six.moves.urllib import parse as urlparse
from ironic.common import boot_devices
from ironic.common import exception
diff --git a/ironic/drivers/modules/redfish/utils.py b/ironic/drivers/modules/redfish/utils.py
index 69be60918..fbf0a3b55 100644
--- a/ironic/drivers/modules/redfish/utils.py
+++ b/ironic/drivers/modules/redfish/utils.py
@@ -15,6 +15,7 @@
import collections
import os
+from urllib import parse as urlparse
from oslo_log import log
from oslo_utils import excutils
@@ -22,8 +23,6 @@ from oslo_utils import importutils
from oslo_utils import strutils
import retrying
import rfc3986
-import six
-from six.moves import urllib
from ironic.common import exception
from ironic.common.i18n import _
@@ -111,7 +110,7 @@ def parse_driver_info(node):
{'address': address, 'node': node.uuid})
try:
- system_id = urllib.parse.quote(driver_info['redfish_system_id'])
+ system_id = urlparse.quote(driver_info['redfish_system_id'])
except (TypeError, AttributeError):
raise exception.InvalidParameterValue(
_('Invalid value "%(value)s" set in '
@@ -123,7 +122,7 @@ def parse_driver_info(node):
# Check if verify_ca is a Boolean or a file/directory in the file-system
verify_ca = driver_info.get('redfish_verify_ca', True)
- if isinstance(verify_ca, six.string_types):
+ if isinstance(verify_ca, str):
if os.path.isdir(verify_ca) or os.path.isfile(verify_ca):
pass
else:
diff --git a/ironic/drivers/modules/snmp.py b/ironic/drivers/modules/snmp.py
index cd444305b..2a2155050 100644
--- a/ironic/drivers/modules/snmp.py
+++ b/ironic/drivers/modules/snmp.py
@@ -29,7 +29,6 @@ import time
from oslo_log import log as logging
from oslo_service import loopingcall
from oslo_utils import importutils
-import six
from ironic.common import exception
from ironic.common.i18n import _
@@ -430,8 +429,7 @@ def retry_on_outdated_cache(f):
return wrapper
-@six.add_metaclass(abc.ABCMeta)
-class SNMPDriverBase(object):
+class SNMPDriverBase(object, metaclass=abc.ABCMeta):
"""SNMP power driver base class.
The SNMPDriver class hierarchy implements manufacturer-specific MIB actions
diff --git a/ironic/drivers/utils.py b/ironic/drivers/utils.py
index e0c69aa81..99b2a7665 100644
--- a/ironic/drivers/utils.py
+++ b/ironic/drivers/utils.py
@@ -20,7 +20,6 @@ from oslo_log import log as logging
from oslo_serialization import base64
from oslo_utils import strutils
from oslo_utils import timeutils
-import six
from ironic.common import exception
from ironic.common.i18n import _
@@ -239,7 +238,7 @@ def capabilities_to_dict(capabilities):
"""
capabilities_dict = {}
if capabilities:
- if not isinstance(capabilities, six.string_types):
+ if not isinstance(capabilities, str):
raise exception.InvalidParameterValue(
_("Value of 'capabilities' must be string. Got %s")
% type(capabilities))
diff --git a/ironic/objects/fields.py b/ironic/objects/fields.py
index fad3ac74d..528e998b2 100644
--- a/ironic/objects/fields.py
+++ b/ironic/objects/fields.py
@@ -18,7 +18,6 @@ import hashlib
import inspect
from oslo_versionedobjects import fields as object_fields
-import six
from ironic.common import utils
@@ -89,7 +88,7 @@ class ListOfObjectsField(object_fields.ListOfObjectsField):
class FlexibleDict(object_fields.FieldType):
@staticmethod
def coerce(obj, attr, value):
- if isinstance(value, six.string_types):
+ if isinstance(value, str):
value = ast.literal_eval(value)
return dict(value)
diff --git a/ironic/objects/node.py b/ironic/objects/node.py
index 9c4b49c2a..c3d6e0104 100644
--- a/ironic/objects/node.py
+++ b/ironic/objects/node.py
@@ -18,7 +18,6 @@ from oslo_utils import strutils
from oslo_utils import uuidutils
from oslo_utils import versionutils
from oslo_versionedobjects import base as object_base
-import six
from ironic.common import exception
from ironic.common.i18n import _
@@ -424,7 +423,7 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
for attr_name in ('last_error', 'maintenance_reason'):
attr_value = getattr(self, attr_name, '')
- if (attr_value and isinstance(attr_value, six.string_types) and
+ if (attr_value and isinstance(attr_value, str) and
len(attr_value) > CONF.log_in_db_max_size):
LOG.info('Truncating too long %s to %s characters for node %s',
attr_name, CONF.log_in_db_max_size, self.uuid)
diff --git a/ironic/tests/unit/api/base.py b/ironic/tests/unit/api/base.py
index ed907f67d..d26308e82 100644
--- a/ironic/tests/unit/api/base.py
+++ b/ironic/tests/unit/api/base.py
@@ -20,11 +20,12 @@
# ceilometer/tests/api/__init__.py). This should be oslo'ified:
# https://bugs.launchpad.net/ironic/+bug/1255115.
+from urllib import parse as urlparse
+
import mock
from oslo_config import cfg
import pecan
import pecan.testing
-from six.moves.urllib import parse as urlparse
from ironic.tests.unit.db import base as db_base
diff --git a/ironic/tests/unit/api/controllers/test_base.py b/ironic/tests/unit/api/controllers/test_base.py
index 237076de6..423eaffa5 100644
--- a/ironic/tests/unit/api/controllers/test_base.py
+++ b/ironic/tests/unit/api/controllers/test_base.py
@@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from http import client as http_client
+
import mock
-from six.moves import http_client
from webob import exc
from ironic.api.controllers import base as cbase
diff --git a/ironic/tests/unit/api/controllers/v1/test_allocation.py b/ironic/tests/unit/api/controllers/v1/test_allocation.py
index faa7cf528..f0a3fbd21 100644
--- a/ironic/tests/unit/api/controllers/v1/test_allocation.py
+++ b/ironic/tests/unit/api/controllers/v1/test_allocation.py
@@ -14,15 +14,14 @@ Tests for the API /allocations/ methods.
"""
import datetime
+from http import client as http_client
+from urllib import parse as urlparse
import fixtures
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
-from six.moves import http_client
-from six.moves.urllib import parse as urlparse
from wsme import types as wtypes
from ironic.api.controllers import base as api_base
@@ -175,7 +174,7 @@ class TestListAllocations(test_api_base.BaseApiTest):
self.assertEqual(len(allocations), len(data['allocations']))
uuids = [n['uuid'] for n in data['allocations']]
- six.assertCountEqual(self, allocations, uuids)
+ self.assertCountEqual(allocations, uuids)
def test_links(self):
uuid = uuidutils.generate_uuid()
diff --git a/ironic/tests/unit/api/controllers/v1/test_chassis.py b/ironic/tests/unit/api/controllers/v1/test_chassis.py
index a46c3e48a..f2e11d9f4 100644
--- a/ironic/tests/unit/api/controllers/v1/test_chassis.py
+++ b/ironic/tests/unit/api/controllers/v1/test_chassis.py
@@ -16,14 +16,13 @@ Tests for the API /chassis/ methods.
"""
import datetime
+from http import client as http_client
+from urllib import parse as urlparse
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
-from six.moves import http_client
-from six.moves.urllib import parse as urlparse
from wsme import types as wtypes
from ironic.api.controllers import base as api_base
@@ -181,7 +180,7 @@ class TestListChassis(test_api_base.BaseApiTest):
data = self.get_json('/chassis')
self.assertEqual(len(ch_list), len(data['chassis']))
uuids = [n['uuid'] for n in data['chassis']]
- six.assertCountEqual(self, ch_list, uuids)
+ self.assertCountEqual(ch_list, uuids)
def _test_links(self, public_url=None):
cfg.CONF.set_override('public_endpoint', public_url, 'api')
diff --git a/ironic/tests/unit/api/controllers/v1/test_conductor.py b/ironic/tests/unit/api/controllers/v1/test_conductor.py
index 1a5905320..8a96a2faf 100644
--- a/ironic/tests/unit/api/controllers/v1/test_conductor.py
+++ b/ironic/tests/unit/api/controllers/v1/test_conductor.py
@@ -14,12 +14,12 @@ Tests for the API /conductors/ methods.
"""
import datetime
+from http import client as http_client
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils
-from six.moves import http_client
from ironic.api.controllers import base as api_base
from ironic.api.controllers import v1 as api_v1
diff --git a/ironic/tests/unit/api/controllers/v1/test_deploy_template.py b/ironic/tests/unit/api/controllers/v1/test_deploy_template.py
index 049a21f7b..96fd16ced 100644
--- a/ironic/tests/unit/api/controllers/v1/test_deploy_template.py
+++ b/ironic/tests/unit/api/controllers/v1/test_deploy_template.py
@@ -14,14 +14,13 @@ Tests for the API /deploy_templates/ methods.
"""
import datetime
+from http import client as http_client
+from urllib import parse as urlparse
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
-from six.moves import http_client
-from six.moves.urllib import parse as urlparse
from ironic.api.controllers import base as api_base
from ironic.api.controllers import v1 as api_v1
@@ -207,7 +206,7 @@ class TestListDeployTemplates(BaseDeployTemplatesAPITest):
self.assertEqual(len(templates), len(data['deploy_templates']))
uuids = [n['uuid'] for n in data['deploy_templates']]
- six.assertCountEqual(self, templates, uuids)
+ self.assertCountEqual(templates, uuids)
def test_links(self):
uuid = uuidutils.generate_uuid()
diff --git a/ironic/tests/unit/api/controllers/v1/test_driver.py b/ironic/tests/unit/api/controllers/v1/test_driver.py
index 601fde7d8..965c390f0 100644
--- a/ironic/tests/unit/api/controllers/v1/test_driver.py
+++ b/ironic/tests/unit/api/controllers/v1/test_driver.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from http import client as http_client
import json
import mock
from oslo_config import cfg
-from six.moves import http_client
from testtools import matchers
from ironic.api.controllers import base as api_base
diff --git a/ironic/tests/unit/api/controllers/v1/test_event.py b/ironic/tests/unit/api/controllers/v1/test_event.py
index 939e19821..082c74493 100644
--- a/ironic/tests/unit/api/controllers/v1/test_event.py
+++ b/ironic/tests/unit/api/controllers/v1/test_event.py
@@ -13,8 +13,9 @@
Tests for the API /events methods.
"""
+from http import client as http_client
+
import mock
-from six.moves import http_client
from ironic.api.controllers import base as api_base
from ironic.api.controllers.v1 import types
diff --git a/ironic/tests/unit/api/controllers/v1/test_node.py b/ironic/tests/unit/api/controllers/v1/test_node.py
index 4415ca508..b8f55464f 100644
--- a/ironic/tests/unit/api/controllers/v1/test_node.py
+++ b/ironic/tests/unit/api/controllers/v1/test_node.py
@@ -14,16 +14,15 @@ Tests for the API /nodes/ methods.
"""
import datetime
+from http import client as http_client
import json
+from urllib import parse as urlparse
import fixtures
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
-from six.moves import http_client
-from six.moves.urllib import parse as urlparse
from testtools import matchers
from wsme import types as wtypes
@@ -3476,8 +3475,7 @@ class TestPost(test_api_base.BaseApiTest):
is_async=True):
expected_status = http_client.ACCEPTED if is_async else http_client.OK
expected_return_value = json.dumps(return_value)
- if six.PY3:
- expected_return_value = expected_return_value.encode('utf-8')
+ expected_return_value = expected_return_value.encode('utf-8')
node = obj_utils.create_test_node(self.context)
info = {'foo': 'bar'}
@@ -3495,8 +3493,7 @@ class TestPost(test_api_base.BaseApiTest):
is_async=True):
expected_status = http_client.ACCEPTED if is_async else http_client.OK
expected_return_value = json.dumps(return_value)
- if six.PY3:
- expected_return_value = expected_return_value.encode('utf-8')
+ expected_return_value = expected_return_value.encode('utf-8')
node = obj_utils.create_test_node(self.context, name='node-109')
info = {'foo': 'bar'}
diff --git a/ironic/tests/unit/api/controllers/v1/test_port.py b/ironic/tests/unit/api/controllers/v1/test_port.py
index 630f66b9a..51a84209b 100644
--- a/ironic/tests/unit/api/controllers/v1/test_port.py
+++ b/ironic/tests/unit/api/controllers/v1/test_port.py
@@ -14,15 +14,14 @@ Tests for the API /ports/ methods.
"""
import datetime
+from http import client as http_client
import types
+from urllib import parse as urlparse
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
-from six.moves import http_client
-from six.moves.urllib import parse as urlparse
from testtools import matchers
from wsme import types as wtypes
@@ -580,7 +579,7 @@ class TestListPorts(test_api_base.BaseApiTest):
self.assertEqual(len(ports), len(data['ports']))
uuids = [n['uuid'] for n in data['ports']]
- six.assertCountEqual(self, ports, uuids)
+ self.assertCountEqual(ports, uuids)
def _test_links(self, public_url=None):
cfg.CONF.set_override('public_endpoint', public_url, 'api')
diff --git a/ironic/tests/unit/api/controllers/v1/test_portgroup.py b/ironic/tests/unit/api/controllers/v1/test_portgroup.py
index de2c13e6f..d0bcd62d0 100644
--- a/ironic/tests/unit/api/controllers/v1/test_portgroup.py
+++ b/ironic/tests/unit/api/controllers/v1/test_portgroup.py
@@ -14,14 +14,13 @@ Tests for the API /portgroups/ methods.
"""
import datetime
+from http import client as http_client
+from urllib import parse as urlparse
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
-from six.moves import http_client
-from six.moves.urllib import parse as urlparse
from testtools.matchers import HasLength
from wsme import types as wtypes
@@ -277,7 +276,7 @@ class TestListPortgroups(test_api_base.BaseApiTest):
self.assertEqual(len(portgroups), len(data['portgroups']))
uuids = [n['uuid'] for n in data['portgroups']]
- six.assertCountEqual(self, portgroups, uuids)
+ self.assertCountEqual(portgroups, uuids)
def test_links(self):
uuid = uuidutils.generate_uuid()
diff --git a/ironic/tests/unit/api/controllers/v1/test_ramdisk.py b/ironic/tests/unit/api/controllers/v1/test_ramdisk.py
index 0bdd9dfbe..086c3edf4 100644
--- a/ironic/tests/unit/api/controllers/v1/test_ramdisk.py
+++ b/ironic/tests/unit/api/controllers/v1/test_ramdisk.py
@@ -15,11 +15,12 @@
Tests for the API /lookup/ methods.
"""
+from http import client as http_client
+
import fixtures
import mock
from oslo_config import cfg
from oslo_utils import uuidutils
-from six.moves import http_client
from ironic.api.controllers import base as api_base
from ironic.api.controllers import v1 as api_v1
diff --git a/ironic/tests/unit/api/controllers/v1/test_types.py b/ironic/tests/unit/api/controllers/v1/test_types.py
index 9dccb2bb3..a16dd40a4 100644
--- a/ironic/tests/unit/api/controllers/v1/test_types.py
+++ b/ironic/tests/unit/api/controllers/v1/test_types.py
@@ -14,11 +14,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+
+from http import client as http_client
import platform
import mock
-import six
-from six.moves import http_client
import webtest
import wsme
from wsme import types as wtypes
@@ -264,8 +264,7 @@ class TestJsonType(base.TestCase):
def test_apimultitype_tostring(self):
vts = str(types.jsontype)
self.assertIn(str(wtypes.text), vts)
- for int_type in six.integer_types:
- self.assertIn(str(int_type), vts)
+ self.assertIn(str(int), vts)
self.assertIn(str(float), vts)
self.assertIn(str(types.BooleanType), vts)
self.assertIn(str(list), vts)
diff --git a/ironic/tests/unit/api/controllers/v1/test_utils.py b/ironic/tests/unit/api/controllers/v1/test_utils.py
index dd45bba7e..6495e26a9 100644
--- a/ironic/tests/unit/api/controllers/v1/test_utils.py
+++ b/ironic/tests/unit/api/controllers/v1/test_utils.py
@@ -14,11 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from http import client as http_client
+
import mock
import os_traits
from oslo_config import cfg
from oslo_utils import uuidutils
-from six.moves import http_client
from webob import static
import wsme
diff --git a/ironic/tests/unit/api/controllers/v1/test_volume.py b/ironic/tests/unit/api/controllers/v1/test_volume.py
index 13f17ac27..9bc50d52a 100644
--- a/ironic/tests/unit/api/controllers/v1/test_volume.py
+++ b/ironic/tests/unit/api/controllers/v1/test_volume.py
@@ -13,7 +13,7 @@
Tests for the API /volume/ methods.
"""
-from six.moves import http_client
+from http import client as http_client
from ironic.api.controllers import base as api_base
from ironic.api.controllers import v1 as api_v1
diff --git a/ironic/tests/unit/api/controllers/v1/test_volume_connector.py b/ironic/tests/unit/api/controllers/v1/test_volume_connector.py
index 3f58fae41..f168978cf 100644
--- a/ironic/tests/unit/api/controllers/v1/test_volume_connector.py
+++ b/ironic/tests/unit/api/controllers/v1/test_volume_connector.py
@@ -16,14 +16,13 @@ Tests for the API /volume connectors/ methods.
"""
import datetime
+from http import client as http_client
+from urllib import parse as urlparse
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
-from six.moves import http_client
-from six.moves.urllib import parse as urlparse
from wsme import types as wtypes
from ironic.api.controllers import base as api_base
@@ -222,7 +221,7 @@ class TestListVolumeConnectors(test_api_base.BaseApiTest):
self.assertEqual(len(connectors), len(data['connectors']))
uuids = [n['uuid'] for n in data['connectors']]
- six.assertCountEqual(self, connectors, uuids)
+ self.assertCountEqual(connectors, uuids)
def test_links(self):
uuid = uuidutils.generate_uuid()
diff --git a/ironic/tests/unit/api/controllers/v1/test_volume_target.py b/ironic/tests/unit/api/controllers/v1/test_volume_target.py
index cdd014af2..868627b61 100644
--- a/ironic/tests/unit/api/controllers/v1/test_volume_target.py
+++ b/ironic/tests/unit/api/controllers/v1/test_volume_target.py
@@ -16,14 +16,13 @@ Tests for the API /volume targets/ methods.
"""
import datetime
+from http import client as http_client
+from urllib import parse as urlparse
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
-from six.moves import http_client
-from six.moves.urllib import parse as urlparse
from wsme import types as wtypes
from ironic.api.controllers import base as api_base
@@ -212,7 +211,7 @@ class TestListVolumeTargets(test_api_base.BaseApiTest):
self.assertEqual(len(targets), len(data['targets']))
uuids = [n['uuid'] for n in data['targets']]
- six.assertCountEqual(self, targets, uuids)
+ self.assertCountEqual(targets, uuids)
def test_links(self):
uuid = uuidutils.generate_uuid()
diff --git a/ironic/tests/unit/api/test_acl.py b/ironic/tests/unit/api/test_acl.py
index fb1125009..c358f5a15 100644
--- a/ironic/tests/unit/api/test_acl.py
+++ b/ironic/tests/unit/api/test_acl.py
@@ -16,9 +16,10 @@ Tests for ACL. Checks whether certain kinds of requests
are blocked or allowed to be processed.
"""
+from http import client as http_client
+
import mock
from oslo_config import cfg
-from six.moves import http_client
from ironic.tests.unit.api import base
from ironic.tests.unit.api import utils
diff --git a/ironic/tests/unit/api/test_hooks.py b/ironic/tests/unit/api/test_hooks.py
index 08cdda30a..095d08a36 100644
--- a/ironic/tests/unit/api/test_hooks.py
+++ b/ironic/tests/unit/api/test_hooks.py
@@ -14,13 +14,12 @@
"""Tests for the Pecan API hooks."""
+from http import client as http_client
import json
import mock
from oslo_config import cfg
import oslo_messaging as messaging
-import six
-from six.moves import http_client
from ironic.api.controllers import root
from ironic.api import hooks
@@ -130,7 +129,7 @@ class TestNoExceptionTracebackHook(base.BaseApiTest):
# we don't care about this garbage.
expected_msg = ("Remote error: %s %s"
% (test_exc_type, self.MSG_WITHOUT_TRACE)
- + ("\n[u'" if six.PY2 else "\n['"))
+ + "\n['")
actual_msg = json.loads(response.json['error_message'])['faultstring']
self.assertEqual(expected_msg, actual_msg)
diff --git a/ironic/tests/unit/api/test_middleware.py b/ironic/tests/unit/api/test_middleware.py
index 495284a42..dfc7ed991 100644
--- a/ironic/tests/unit/api/test_middleware.py
+++ b/ironic/tests/unit/api/test_middleware.py
@@ -15,9 +15,10 @@
Tests to assert that various incorporated middleware works as expected.
"""
+from http import client as http_client
+
from oslo_config import cfg
import oslo_middleware.cors as cors_middleware
-from six.moves import http_client
from ironic.tests.unit.api import base
diff --git a/ironic/tests/unit/api/test_root.py b/ironic/tests/unit/api/test_root.py
index b0828f375..9a512d7ad 100644
--- a/ironic/tests/unit/api/test_root.py
+++ b/ironic/tests/unit/api/test_root.py
@@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from six.moves import http_client
+from http import client as http_client
from ironic.api.controllers.v1 import versions
from ironic.tests.unit.api import base
diff --git a/ironic/tests/unit/common/test_cinder.py b/ironic/tests/unit/common/test_cinder.py
index f289a0d82..db5a96fbb 100644
--- a/ironic/tests/unit/common/test_cinder.py
+++ b/ironic/tests/unit/common/test_cinder.py
@@ -12,13 +12,13 @@
# under the License.
import datetime
+from http import client as http_client
import json
from cinderclient import exceptions as cinder_exceptions
import cinderclient.v3 as cinderclient
import mock
from oslo_utils import uuidutils
-from six.moves import http_client
from ironic.common import cinder
from ironic.common import context
diff --git a/ironic/tests/unit/common/test_image_service.py b/ironic/tests/unit/common/test_image_service.py
index 243d4d90d..bc0d391b6 100644
--- a/ironic/tests/unit/common/test_image_service.py
+++ b/ironic/tests/unit/common/test_image_service.py
@@ -10,7 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+import builtins
import datetime
+from http import client as http_client
+import io
import os
import shutil
@@ -18,19 +21,12 @@ import mock
from oslo_utils import uuidutils
import requests
import sendfile
-import six
-import six.moves.builtins as __builtin__
-from six.moves import http_client
from ironic.common import exception
from ironic.common.glance_service import image_service as glance_v2_service
from ironic.common import image_service
from ironic.tests import base
-if six.PY3:
- import io
- file = io.BytesIO
-
class HttpImageServiceTestCase(base.TestCase):
def setUp(self):
@@ -74,8 +70,8 @@ class HttpImageServiceTestCase(base.TestCase):
self.service.validate_href,
self.href,
True)
- self.assertIn('secreturl', six.text_type(e))
- self.assertNotIn(self.href, six.text_type(e))
+ self.assertIn('secreturl', str(e))
+ self.assertNotIn(self.href, str(e))
head_mock.assert_called_once_with(self.href)
@mock.patch.object(requests, 'head', autospec=True)
@@ -115,8 +111,8 @@ class HttpImageServiceTestCase(base.TestCase):
def test_download_success(self, req_get_mock, shutil_mock):
response_mock = req_get_mock.return_value
response_mock.status_code = http_client.OK
- response_mock.raw = mock.MagicMock(spec=file)
- file_mock = mock.Mock(spec=file)
+ response_mock.raw = mock.MagicMock(spec=io.BytesIO)
+ file_mock = mock.Mock(spec=io.BytesIO)
self.service.download(self.href, file_mock)
shutil_mock.assert_called_once_with(
response_mock.raw.__enter__(), file_mock,
@@ -127,7 +123,7 @@ class HttpImageServiceTestCase(base.TestCase):
@mock.patch.object(requests, 'get', autospec=True)
def test_download_fail_connerror(self, req_get_mock):
req_get_mock.side_effect = requests.ConnectionError()
- file_mock = mock.Mock(spec=file)
+ file_mock = mock.Mock(spec=io.BytesIO)
self.assertRaises(exception.ImageDownloadFailed,
self.service.download, self.href, file_mock)
@@ -136,8 +132,8 @@ class HttpImageServiceTestCase(base.TestCase):
def test_download_fail_ioerror(self, req_get_mock, shutil_mock):
response_mock = req_get_mock.return_value
response_mock.status_code = http_client.OK
- response_mock.raw = mock.MagicMock(spec=file)
- file_mock = mock.Mock(spec=file)
+ response_mock.raw = mock.MagicMock(spec=io.BytesIO)
+ file_mock = mock.Mock(spec=io.BytesIO)
shutil_mock.side_effect = IOError
self.assertRaises(exception.ImageDownloadFailed,
self.service.download, self.href, file_mock)
@@ -188,7 +184,7 @@ class FileImageServiceTestCase(base.TestCase):
remove_mock, link_mock):
_validate_mock.return_value = self.href_path
stat_mock.return_value.st_dev = 'dev1'
- file_mock = mock.Mock(spec=file)
+ file_mock = mock.Mock(spec=io.BytesIO)
file_mock.name = 'file'
self.service.download(self.href, file_mock)
_validate_mock.assert_called_once_with(mock.ANY, self.href)
@@ -199,7 +195,7 @@ class FileImageServiceTestCase(base.TestCase):
@mock.patch.object(sendfile, 'sendfile', return_value=42, autospec=True)
@mock.patch.object(os.path, 'getsize', return_value=42, autospec=True)
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
@mock.patch.object(os, 'access', return_value=False, autospec=True)
@mock.patch.object(os, 'stat', autospec=True)
@mock.patch.object(image_service.FileImageService, 'validate_href',
@@ -208,9 +204,9 @@ class FileImageServiceTestCase(base.TestCase):
open_mock, size_mock, copy_mock):
_validate_mock.return_value = self.href_path
stat_mock.return_value.st_dev = 'dev1'
- file_mock = mock.MagicMock(spec=file)
+ file_mock = mock.MagicMock(spec=io.BytesIO)
file_mock.name = 'file'
- input_mock = mock.MagicMock(spec=file)
+ input_mock = mock.MagicMock(spec=io.BytesIO)
open_mock.return_value = input_mock
self.service.download(self.href, file_mock)
_validate_mock.assert_called_once_with(mock.ANY, self.href)
@@ -222,7 +218,7 @@ class FileImageServiceTestCase(base.TestCase):
@mock.patch.object(sendfile, 'sendfile', autospec=True)
@mock.patch.object(os.path, 'getsize', return_value=42, autospec=True)
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
@mock.patch.object(os, 'access', return_value=False, autospec=True)
@mock.patch.object(os, 'stat', autospec=True)
@mock.patch.object(image_service.FileImageService, 'validate_href',
@@ -236,9 +232,9 @@ class FileImageServiceTestCase(base.TestCase):
fake_chunk_seq = [chunk_size, chunk_size, chunk_size, 1024]
_validate_mock.return_value = self.href_path
stat_mock.return_value.st_dev = 'dev1'
- file_mock = mock.MagicMock(spec=file)
+ file_mock = mock.MagicMock(spec=io.BytesIO)
file_mock.name = 'file'
- input_mock = mock.MagicMock(spec=file)
+ input_mock = mock.MagicMock(spec=io.BytesIO)
open_mock.return_value = input_mock
size_mock.return_value = fake_image_size
copy_mock.side_effect = fake_chunk_seq
@@ -262,7 +258,7 @@ class FileImageServiceTestCase(base.TestCase):
access_mock, remove_mock):
_validate_mock.return_value = self.href_path
stat_mock.return_value.st_dev = 'dev1'
- file_mock = mock.MagicMock(spec=file)
+ file_mock = mock.MagicMock(spec=io.BytesIO)
file_mock.name = 'file'
self.assertRaises(exception.ImageDownloadFailed,
self.service.download, self.href, file_mock)
@@ -273,7 +269,7 @@ class FileImageServiceTestCase(base.TestCase):
@mock.patch.object(sendfile, 'sendfile', side_effect=OSError,
autospec=True)
@mock.patch.object(os.path, 'getsize', return_value=42, autospec=True)
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
@mock.patch.object(os, 'access', return_value=False, autospec=True)
@mock.patch.object(os, 'stat', autospec=True)
@mock.patch.object(image_service.FileImageService, 'validate_href',
@@ -282,9 +278,9 @@ class FileImageServiceTestCase(base.TestCase):
open_mock, size_mock, copy_mock):
_validate_mock.return_value = self.href_path
stat_mock.return_value.st_dev = 'dev1'
- file_mock = mock.MagicMock(spec=file)
+ file_mock = mock.MagicMock(spec=io.BytesIO)
file_mock.name = 'file'
- input_mock = mock.MagicMock(spec=file)
+ input_mock = mock.MagicMock(spec=io.BytesIO)
open_mock.return_value = input_mock
self.assertRaises(exception.ImageDownloadFailed,
self.service.download, self.href, file_mock)
diff --git a/ironic/tests/unit/common/test_images.py b/ironic/tests/unit/common/test_images.py
index 86143fc96..78514d1ea 100644
--- a/ironic/tests/unit/common/test_images.py
+++ b/ironic/tests/unit/common/test_images.py
@@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import builtins
+import io
import os
import shutil
@@ -23,8 +25,6 @@ from ironic_lib import utils as ironic_utils
import mock
from oslo_concurrency import processutils
from oslo_config import cfg
-import six
-import six.moves.builtins as __builtin__
from ironic.common import exception
from ironic.common.glance_service import service_utils as glance_utils
@@ -33,10 +33,6 @@ from ironic.common import images
from ironic.common import utils
from ironic.tests import base
-if six.PY3:
- import io
- file = io.BytesIO
-
CONF = cfg.CONF
@@ -46,9 +42,9 @@ class IronicImagesTestCase(base.TestCase):
pass
@mock.patch.object(image_service, 'get_image_service', autospec=True)
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
def test_fetch_image_service(self, open_mock, image_service_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'file'
open_mock.return_value = mock_file_handle
@@ -62,10 +58,10 @@ class IronicImagesTestCase(base.TestCase):
@mock.patch.object(image_service, 'get_image_service', autospec=True)
@mock.patch.object(images, 'image_to_raw', autospec=True)
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
def test_fetch_image_service_force_raw(self, open_mock, image_to_raw_mock,
image_service_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'file'
open_mock.return_value = mock_file_handle
@@ -294,7 +290,7 @@ class FsImageTestCase(base.TestCase):
self, mkfs_mock, mount_mock, umount_mock, dd_mock, write_mock,
tempdir_mock, create_root_fs_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tempdir'
tempdir_mock.return_value = mock_file_handle
@@ -329,7 +325,7 @@ class FsImageTestCase(base.TestCase):
self, mkfs_mock, mount_mock, umount_mock, dd_mock,
tempdir_mock, create_root_fs_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tempdir'
tempdir_mock.return_value = mock_file_handle
files_info = {'a': 'b'}
@@ -353,7 +349,7 @@ class FsImageTestCase(base.TestCase):
def test_create_vfat_image_mkfs_fails(self, mkfs_mock, dd_mock,
tempdir_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tempdir'
tempdir_mock.return_value = mock_file_handle
@@ -371,7 +367,7 @@ class FsImageTestCase(base.TestCase):
self, mkfs_mock, mount_mock, umount_mock, dd_mock,
tempdir_mock, create_root_fs_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tempdir'
tempdir_mock.return_value = mock_file_handle
umount_mock.side_effect = processutils.ProcessExecutionError
@@ -513,9 +509,9 @@ class FsImageTestCase(base.TestCase):
'path/to/grub': 'relpath/to/grub.cfg'}
grub_rel_path = 'relpath/to/grub.cfg'
e_img_rel_path = 'path/to/efiboot.img'
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
- mock_file_handle1 = mock.MagicMock(spec=file)
+ mock_file_handle1 = mock.MagicMock(spec=io.BytesIO)
mock_file_handle1.__enter__.return_value = 'mountdir'
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
mount_mock.return_value = (uefi_path_info,
@@ -561,9 +557,9 @@ class FsImageTestCase(base.TestCase):
grub_options = {'linux': '/vmlinuz',
'initrd': '/initrd'}
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
- mock_file_handle1 = mock.MagicMock(spec=file)
+ mock_file_handle1 = mock.MagicMock(spec=io.BytesIO)
mock_file_handle1.__enter__.return_value = 'mountdir'
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
mountdir_grub_cfg_path = 'tmpdir' + grub_cfg_file
@@ -590,7 +586,7 @@ class FsImageTestCase(base.TestCase):
self, gen_cfg_mock, execute_mock, tempdir_mock,
write_to_file_mock, create_root_fs_mock, ldlinux_path=None):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle
@@ -653,9 +649,9 @@ class FsImageTestCase(base.TestCase):
create_root_fs_mock,
umount_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
- mock_file_handle1 = mock.MagicMock(spec=file)
+ mock_file_handle1 = mock.MagicMock(spec=io.BytesIO)
mock_file_handle1.__enter__.return_value = 'mountdir'
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
create_root_fs_mock.side_effect = IOError
@@ -698,9 +694,9 @@ class FsImageTestCase(base.TestCase):
write_to_file_mock,
create_root_fs_mock,
umount_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
- mock_file_handle1 = mock.MagicMock(spec=file)
+ mock_file_handle1 = mock.MagicMock(spec=io.BytesIO)
mock_file_handle1.__enter__.return_value = 'mountdir'
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
mount_mock.return_value = ({'a': 'a'}, 'b', 'c')
@@ -725,7 +721,7 @@ class FsImageTestCase(base.TestCase):
tempdir_mock,
write_to_file_mock,
create_root_fs_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle
utils_mock.side_effect = processutils.ProcessExecutionError
@@ -740,7 +736,7 @@ class FsImageTestCase(base.TestCase):
@mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_uefi_deploy_iso(
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle
@@ -768,7 +764,7 @@ class FsImageTestCase(base.TestCase):
@mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_uefi_esp_image(
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle
@@ -796,7 +792,7 @@ class FsImageTestCase(base.TestCase):
@mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_uefi_deploy_iso_for_hrefs(
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle
@@ -824,7 +820,7 @@ class FsImageTestCase(base.TestCase):
@mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_uefi_esp_image_for_hrefs(
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle
@@ -852,7 +848,7 @@ class FsImageTestCase(base.TestCase):
@mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_bios(
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle
@@ -884,7 +880,7 @@ class FsImageTestCase(base.TestCase):
def test_create_boot_iso_for_bios_with_no_boot_mode(self, tempdir_mock,
fetch_images_mock,
create_isolinux_mock):
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle
diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py
index 778792d7c..851f14b0a 100644
--- a/ironic/tests/unit/common/test_pxe_utils.py
+++ b/ironic/tests/unit/common/test_pxe_utils.py
@@ -22,7 +22,6 @@ import mock
from oslo_config import cfg
from oslo_utils import fileutils
from oslo_utils import uuidutils
-import six
from ironic.common import exception
from ironic.common.glance_service import image_service
@@ -122,7 +121,7 @@ class TestPXEUtils(db_base.DbTestCase):
with open('ironic/tests/unit/drivers/pxe_config.template') as f:
expected_template = f.read().rstrip()
- self.assertEqual(six.text_type(expected_template), rendered_template)
+ self.assertEqual(str(expected_template), rendered_template)
def test_default_ipxe_boot_script(self):
rendered_template = utils.render_template(
@@ -132,7 +131,7 @@ class TestPXEUtils(db_base.DbTestCase):
with open('ironic/tests/unit/drivers/boot.ipxe') as f:
expected_template = f.read().rstrip()
- self.assertEqual(six.text_type(expected_template), rendered_template)
+ self.assertEqual(str(expected_template), rendered_template)
def test_default_ipxe_config(self):
# NOTE(lucasagomes): iPXE is just an extension of the PXE driver,
@@ -154,7 +153,7 @@ class TestPXEUtils(db_base.DbTestCase):
with open(templ_file) as f:
expected_template = f.read().rstrip()
- self.assertEqual(six.text_type(expected_template), rendered_template)
+ self.assertEqual(str(expected_template), rendered_template)
def test_default_ipxe_timeout_config(self):
# NOTE(lucasagomes): iPXE is just an extension of the PXE driver,
@@ -176,7 +175,7 @@ class TestPXEUtils(db_base.DbTestCase):
with open(templ_file) as f:
expected_template = f.read().rstrip()
- self.assertEqual(six.text_type(expected_template), rendered_template)
+ self.assertEqual(str(expected_template), rendered_template)
def test_default_ipxe_boot_from_volume_config(self):
self.config(
@@ -195,7 +194,7 @@ class TestPXEUtils(db_base.DbTestCase):
with open(templ_file) as f:
expected_template = f.read().rstrip()
- self.assertEqual(six.text_type(expected_template), rendered_template)
+ self.assertEqual(str(expected_template), rendered_template)
def test_default_ipxe_boot_from_volume_config_no_extra_volumes(self):
self.config(
@@ -217,7 +216,7 @@ class TestPXEUtils(db_base.DbTestCase):
'ipxe_config_boot_from_volume_no_extra_volumes.template'
with open(templ_file) as f:
expected_template = f.read().rstrip()
- self.assertEqual(six.text_type(expected_template), rendered_template)
+ self.assertEqual(str(expected_template), rendered_template)
def test_default_grub_config(self):
pxe_opts = self.pxe_options
@@ -233,7 +232,7 @@ class TestPXEUtils(db_base.DbTestCase):
with open(templ_file) as f:
expected_template = f.read().rstrip()
- self.assertEqual(six.text_type(expected_template), rendered_template)
+ self.assertEqual(str(expected_template), rendered_template)
@mock.patch('ironic.common.utils.create_link_without_raise', autospec=True)
@mock.patch('ironic_lib.utils.unlink_without_raise', autospec=True)
diff --git a/ironic/tests/unit/common/test_release_mappings.py b/ironic/tests/unit/common/test_release_mappings.py
index 19b52fe23..db3f18f85 100644
--- a/ironic/tests/unit/common/test_release_mappings.py
+++ b/ironic/tests/unit/common/test_release_mappings.py
@@ -14,7 +14,6 @@
import mock
from oslo_utils import versionutils
-import six
from ironic.api.controllers.v1 import versions as api_versions
from ironic.common import release_mappings
@@ -50,16 +49,16 @@ class ReleaseMappingsTestCase(base.TestCase):
for value in release_mappings.RELEASE_MAPPING.values():
self.assertIsInstance(value, dict)
self.assertEqual({'api', 'rpc', 'objects'}, set(value))
- self.assertIsInstance(value['api'], six.string_types)
+ self.assertIsInstance(value['api'], str)
(major, minor) = value['api'].split('.')
self.assertEqual(1, int(major))
self.assertLessEqual(int(minor), api_versions.MINOR_MAX_VERSION)
- self.assertIsInstance(value['rpc'], six.string_types)
+ self.assertIsInstance(value['rpc'], str)
self.assertIsInstance(value['objects'], dict)
for obj_value in value['objects'].values():
self.assertIsInstance(obj_value, list)
for ver in obj_value:
- self.assertIsInstance(ver, six.string_types)
+ self.assertIsInstance(ver, str)
tuple_ver = versionutils.convert_version_to_tuple(ver)
self.assertEqual(2, len(tuple_ver))
diff --git a/ironic/tests/unit/common/test_states.py b/ironic/tests/unit/common/test_states.py
index d841ac3bb..1688b000c 100644
--- a/ironic/tests/unit/common/test_states.py
+++ b/ironic/tests/unit/common/test_states.py
@@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
-
from ironic.common import states
from ironic.tests import base
@@ -31,7 +29,7 @@ class StatesTest(base.TestCase):
for key, value in states.__dict__.items():
# Assumption: A state variable name is all UPPERCASE and contents
# are a string.
- if key.upper() == key and isinstance(value, six.string_types):
+ if key.upper() == key and isinstance(value, str):
self.assertLessEqual(
len(value), 15,
"Value for state: {} is greater than 15 characters".format(
diff --git a/ironic/tests/unit/common/test_swift.py b/ironic/tests/unit/common/test_swift.py
index a4b6c89fa..cb53d16ba 100644
--- a/ironic/tests/unit/common/test_swift.py
+++ b/ironic/tests/unit/common/test_swift.py
@@ -12,11 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+import builtins
+from http import client as http_client
+import io
+
import mock
from oslo_config import cfg
-import six
-from six.moves import builtins as __builtin__
-from six.moves import http_client
from swiftclient import client as swift_client
from swiftclient import exceptions as swift_exception
from swiftclient import utils as swift_utils
@@ -27,10 +28,6 @@ from ironic.tests import base
CONF = cfg.CONF
-if six.PY3:
- import io
- file = io.BytesIO
-
@mock.patch.object(swift, 'get_swift_session', autospec=True,
return_value=mock.Mock(verify=False, cert=('spam', 'ham'),
@@ -57,11 +54,11 @@ class SwiftTestCase(base.TestCase):
os_options={'object_storage_url': 'http://example.com/objects'}
)
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
def test_create_object(self, open_mock, connection_mock, keystone_mock):
swiftapi = swift.SwiftAPI()
connection_obj_mock = connection_mock.return_value
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'file-object'
open_mock.return_value = mock_file_handle
@@ -75,7 +72,7 @@ class SwiftTestCase(base.TestCase):
'container', 'object', 'file-object', headers=None)
self.assertEqual('object-uuid', object_uuid)
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
def test_create_object_create_container_fails(self, open_mock,
connection_mock,
keystone_mock):
@@ -88,11 +85,11 @@ class SwiftTestCase(base.TestCase):
connection_obj_mock.put_container.assert_called_once_with('container')
self.assertFalse(connection_obj_mock.put_object.called)
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
def test_create_object_put_object_fails(self, open_mock, connection_mock,
keystone_mock):
swiftapi = swift.SwiftAPI()
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'file-object'
open_mock.return_value = mock_file_handle
connection_obj_mock = connection_mock.return_value
diff --git a/ironic/tests/unit/conductor/test_manager.py b/ironic/tests/unit/conductor/test_manager.py
index b3564ad9e..301610b82 100644
--- a/ironic/tests/unit/conductor/test_manager.py
+++ b/ironic/tests/unit/conductor/test_manager.py
@@ -20,6 +20,7 @@
from collections import namedtuple
import datetime
+import queue
import re
import eventlet
@@ -31,8 +32,6 @@ import oslo_messaging as messaging
from oslo_utils import uuidutils
from oslo_versionedobjects import base as ovo_base
from oslo_versionedobjects import fields
-import six
-from six.moves import queue
from ironic.common import boot_devices
from ironic.common import driver_factory
@@ -5881,12 +5880,6 @@ class SensorsTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
self.assertEqual(5, validate_mock.call_count)
self.assertEqual(5, get_sensors_data_mock.call_count)
self.assertEqual(5, notifier_mock.call_count)
- if six.PY2:
- # bail out if python2 as matching fails to match the
- # data structure becasue it requires the order to be consistent
- # but the mock also records the call dictionary contents in
- # random order changing with every invocation. :\
- return
n_call = mock.call(mock.ANY, mock.ANY, 'hardware.fake.metrics',
{'event_type': 'hardware.fake.metrics.update',
'node_name': 'fake_node', 'timestamp': mock.ANY,
@@ -6505,7 +6498,7 @@ class RaidHardwareTypeTestCases(RaidTestCases):
self.node.refresh()
self.assertEqual({}, self.node.target_raid_config)
self.assertEqual(exception.UnsupportedDriverExtension, exc.exc_info[0])
- self.assertIn('manual-management', six.text_type(exc.exc_info[1]))
+ self.assertIn('manual-management', str(exc.exc_info[1]))
@mock.patch.object(conductor_utils, 'node_power_action')
diff --git a/ironic/tests/unit/db/test_chassis.py b/ironic/tests/unit/db/test_chassis.py
index db298c7c6..1c67154de 100644
--- a/ironic/tests/unit/db/test_chassis.py
+++ b/ironic/tests/unit/db/test_chassis.py
@@ -16,7 +16,6 @@
"""Tests for manipulating Chassis via the DB API"""
from oslo_utils import uuidutils
-import six
from ironic.common import exception
from ironic.tests.unit.db import base
@@ -33,10 +32,10 @@ class DbChassisTestCase(base.DbTestCase):
uuids = [self.chassis.uuid]
for i in range(1, 6):
ch = utils.create_test_chassis(uuid=uuidutils.generate_uuid())
- uuids.append(six.text_type(ch.uuid))
+ uuids.append(str(ch.uuid))
res = self.dbapi.get_chassis_list()
res_uuids = [r.uuid for r in res]
- six.assertCountEqual(self, uuids, res_uuids)
+ self.assertCountEqual(uuids, res_uuids)
def test_get_chassis_by_id(self):
chassis = self.dbapi.get_chassis_by_id(self.chassis.id)
diff --git a/ironic/tests/unit/db/test_deploy_templates.py b/ironic/tests/unit/db/test_deploy_templates.py
index 921fe6591..d3bdb4b11 100644
--- a/ironic/tests/unit/db/test_deploy_templates.py
+++ b/ironic/tests/unit/db/test_deploy_templates.py
@@ -14,7 +14,6 @@
from oslo_db import exception as db_exc
from oslo_utils import uuidutils
-import six
from ironic.common import exception
from ironic.tests.unit.db import base
@@ -173,19 +172,19 @@ class DbDeployTemplateTestCase(base.DbTestCase):
self.dbapi.get_deploy_template_by_name, 'bogus')
def _template_list_preparation(self):
- uuids = [six.text_type(self.template.uuid)]
+ uuids = [str(self.template.uuid)]
for i in range(1, 3):
template = db_utils.create_test_deploy_template(
uuid=uuidutils.generate_uuid(),
name='CUSTOM_DT%d' % (i + 1))
- uuids.append(six.text_type(template.uuid))
+ uuids.append(str(template.uuid))
return uuids
def test_get_deploy_template_list(self):
uuids = self._template_list_preparation()
res = self.dbapi.get_deploy_template_list()
res_uuids = [r.uuid for r in res]
- six.assertCountEqual(self, uuids, res_uuids)
+ self.assertCountEqual(uuids, res_uuids)
def test_get_deploy_template_list_sorted(self):
uuids = self._template_list_preparation()
@@ -201,7 +200,7 @@ class DbDeployTemplateTestCase(base.DbTestCase):
names = ['CUSTOM_DT2', 'CUSTOM_DT3']
res = self.dbapi.get_deploy_template_list_by_names(names=names)
res_names = [r.name for r in res]
- six.assertCountEqual(self, names, res_names)
+ self.assertCountEqual(names, res_names)
def test_get_deploy_template_list_by_names_no_match(self):
self._template_list_preparation()
diff --git a/ironic/tests/unit/db/test_nodes.py b/ironic/tests/unit/db/test_nodes.py
index e61302be7..07401a27d 100644
--- a/ironic/tests/unit/db/test_nodes.py
+++ b/ironic/tests/unit/db/test_nodes.py
@@ -20,7 +20,6 @@ import datetime
import mock
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
from ironic.common import exception
from ironic.common import states
@@ -295,10 +294,10 @@ class DbNodeTestCase(base.DbTestCase):
uuids = []
for i in range(1, 6):
node = utils.create_test_node(uuid=uuidutils.generate_uuid())
- uuids.append(six.text_type(node['uuid']))
+ uuids.append(str(node['uuid']))
res = self.dbapi.get_node_list()
res_uuids = [r.uuid for r in res]
- six.assertCountEqual(self, uuids, res_uuids)
+ self.assertCountEqual(uuids, res_uuids)
for r in res:
self.assertEqual([], r.tags)
self.assertEqual([], r.traits)
diff --git a/ironic/tests/unit/db/test_portgroups.py b/ironic/tests/unit/db/test_portgroups.py
index 97803d3f2..fa0402094 100644
--- a/ironic/tests/unit/db/test_portgroups.py
+++ b/ironic/tests/unit/db/test_portgroups.py
@@ -13,7 +13,6 @@
"""Tests for manipulating portgroups via the DB API"""
from oslo_utils import uuidutils
-import six
from ironic.common import exception
from ironic.tests.unit.db import base
@@ -45,7 +44,7 @@ class DbportgroupTestCase(base.DbTestCase):
uuid=uuidutils.generate_uuid(),
name='portgroup' + str(i),
address='52:54:00:cf:2d:4%s' % i)
- uuids.append(six.text_type(portgroup.uuid))
+ uuids.append(str(portgroup.uuid))
return uuids
@@ -87,16 +86,16 @@ class DbportgroupTestCase(base.DbTestCase):
uuids = self._create_test_portgroup_range(6)
# Also add the uuid for the portgroup created in setUp()
- uuids.append(six.text_type(self.portgroup.uuid))
+ uuids.append(str(self.portgroup.uuid))
res = self.dbapi.get_portgroup_list()
res_uuids = [r.uuid for r in res]
- six.assertCountEqual(self, uuids, res_uuids)
+ self.assertCountEqual(uuids, res_uuids)
def test_get_portgroup_list_sorted(self):
uuids = self._create_test_portgroup_range(6)
# Also add the uuid for the portgroup created in setUp()
- uuids.append(six.text_type(self.portgroup.uuid))
+ uuids.append(str(self.portgroup.uuid))
res = self.dbapi.get_portgroup_list(sort_key='uuid')
res_uuids = [r.uuid for r in res]
self.assertEqual(sorted(uuids), res_uuids)
diff --git a/ironic/tests/unit/db/test_ports.py b/ironic/tests/unit/db/test_ports.py
index 003bc5e63..fa12c4c25 100644
--- a/ironic/tests/unit/db/test_ports.py
+++ b/ironic/tests/unit/db/test_ports.py
@@ -16,7 +16,6 @@
"""Tests for manipulating Ports via the DB API"""
from oslo_utils import uuidutils
-import six
from ironic.common import exception
from ironic.tests.unit.db import base
@@ -51,21 +50,21 @@ class DbPortTestCase(base.DbTestCase):
for i in range(1, 6):
port = db_utils.create_test_port(uuid=uuidutils.generate_uuid(),
address='52:54:00:cf:2d:4%s' % i)
- uuids.append(six.text_type(port.uuid))
+ uuids.append(str(port.uuid))
# Also add the uuid for the port created in setUp()
- uuids.append(six.text_type(self.port.uuid))
+ uuids.append(str(self.port.uuid))
res = self.dbapi.get_port_list()
res_uuids = [r.uuid for r in res]
- six.assertCountEqual(self, uuids, res_uuids)
+ self.assertCountEqual(uuids, res_uuids)
def test_get_port_list_sorted(self):
uuids = []
for i in range(1, 6):
port = db_utils.create_test_port(uuid=uuidutils.generate_uuid(),
address='52:54:00:cf:2d:4%s' % i)
- uuids.append(six.text_type(port.uuid))
+ uuids.append(str(port.uuid))
# Also add the uuid for the port created in setUp()
- uuids.append(six.text_type(self.port.uuid))
+ uuids.append(str(self.port.uuid))
res = self.dbapi.get_port_list(sort_key='uuid')
res_uuids = [r.uuid for r in res]
self.assertEqual(sorted(uuids), res_uuids)
diff --git a/ironic/tests/unit/db/test_volume_connectors.py b/ironic/tests/unit/db/test_volume_connectors.py
index 461d24bdc..b15e03275 100644
--- a/ironic/tests/unit/db/test_volume_connectors.py
+++ b/ironic/tests/unit/db/test_volume_connectors.py
@@ -15,7 +15,6 @@
"""Tests for manipulating VolumeConnectors via the DB API"""
from oslo_utils import uuidutils
-import six
from ironic.common import exception
from ironic.tests.unit.db import base
@@ -65,20 +64,20 @@ class DbVolumeConnectorTestCase(base.DbTestCase):
-1)
def _connector_list_preparation(self):
- uuids = [six.text_type(self.connector.uuid)]
+ uuids = [str(self.connector.uuid)]
for i in range(1, 6):
volume_connector = db_utils.create_test_volume_connector(
uuid=uuidutils.generate_uuid(),
type='iqn',
connector_id='iqn.test-%s' % i)
- uuids.append(six.text_type(volume_connector.uuid))
+ uuids.append(str(volume_connector.uuid))
return uuids
def test_get_volume_connector_list(self):
uuids = self._connector_list_preparation()
res = self.dbapi.get_volume_connector_list()
res_uuids = [r.uuid for r in res]
- six.assertCountEqual(self, uuids, res_uuids)
+ self.assertCountEqual(uuids, res_uuids)
def test_get_volume_connector_list_sorted(self):
uuids = self._connector_list_preparation()
diff --git a/ironic/tests/unit/db/test_volume_targets.py b/ironic/tests/unit/db/test_volume_targets.py
index 4dd4a3af7..62db5353f 100644
--- a/ironic/tests/unit/db/test_volume_targets.py
+++ b/ironic/tests/unit/db/test_volume_targets.py
@@ -15,7 +15,6 @@
"""Tests for manipulating VolumeTargets via the DB API"""
from oslo_utils import uuidutils
-import six
from ironic.common import exception
from ironic.tests.unit.db import base
@@ -79,20 +78,20 @@ class DbVolumeTargetTestCase(base.DbTestCase):
'11111111-2222-3333-4444-555555555555')
def _create_list_of_volume_targets(self, num):
- uuids = [six.text_type(self.target.uuid)]
+ uuids = [str(self.target.uuid)]
for i in range(1, num):
volume_target = db_utils.create_test_volume_target(
uuid=uuidutils.generate_uuid(),
properties={"target_iqn": "iqn.test-%s" % i},
boot_index=i)
- uuids.append(six.text_type(volume_target.uuid))
+ uuids.append(str(volume_target.uuid))
return uuids
def test_get_volume_target_list(self):
uuids = self._create_list_of_volume_targets(6)
res = self.dbapi.get_volume_target_list()
res_uuids = [r.uuid for r in res]
- six.assertCountEqual(self, uuids, res_uuids)
+ self.assertCountEqual(uuids, res_uuids)
def test_get_volume_target_list_sorted(self):
uuids = self._create_list_of_volume_targets(5)
diff --git a/ironic/tests/unit/dhcp/test_factory.py b/ironic/tests/unit/dhcp/test_factory.py
index c6b30535a..bda6bed0e 100644
--- a/ironic/tests/unit/dhcp/test_factory.py
+++ b/ironic/tests/unit/dhcp/test_factory.py
@@ -16,7 +16,6 @@
import inspect
import mock
-import six
import stevedore
from ironic.common import dhcp_factory
@@ -84,7 +83,7 @@ class TestDHCPFactory(base.TestCase):
class CompareBasetoModules(base.TestCase):
def test_drivers_match_dhcp_base(self):
- signature_method = inspect.getargspec if six.PY2 else inspect.signature
+ signature_method = inspect.signature
def _get_public_apis(inst):
methods = {}
diff --git a/ironic/tests/unit/drivers/modules/ansible/test_deploy.py b/ironic/tests/unit/drivers/modules/ansible/test_deploy.py
index 997833876..9cf759af4 100644
--- a/ironic/tests/unit/drivers/modules/ansible/test_deploy.py
+++ b/ironic/tests/unit/drivers/modules/ansible/test_deploy.py
@@ -15,7 +15,6 @@ import json
from ironic_lib import utils as irlib_utils
import mock
from oslo_concurrency import processutils
-import six
from ironic.common import exception
from ironic.common import states
@@ -235,7 +234,7 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
ansible_deploy._run_playbook,
self.node, 'deploy', extra_vars,
'/path/to/key')
- self.assertIn('VIKINGS!', six.text_type(exc))
+ self.assertIn('VIKINGS!', str(exc))
execute_mock.assert_called_once_with(
'env', 'ANSIBLE_CONFIG=/path/to/config',
'ansible-playbook', '/path/to/playbooks/deploy', '-i',
@@ -374,8 +373,8 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
exception.InvalidParameterValue,
ansible_deploy._parse_root_device_hints, task.node)
for key, value in expected.items():
- self.assertIn(six.text_type(key), six.text_type(exc))
- self.assertIn(six.text_type(value), six.text_type(exc))
+ self.assertIn(str(key), str(exc))
+ self.assertIn(str(value), str(exc))
def test__prepare_variables(self):
i_info = self.node.instance_info
@@ -486,9 +485,9 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
exc = self.assertRaises(exception.NodeCleaningFailure,
ansible_deploy._validate_clean_steps,
steps, self.node.uuid)
- self.assertIn("name foo, field ham.value", six.text_type(exc))
- self.assertIn("name bar, field interface", six.text_type(exc))
- self.assertIn("name undefined, field name", six.text_type(exc))
+ self.assertIn("name foo, field ham.value", str(exc))
+ self.assertIn("name bar, field interface", str(exc))
+ self.assertIn("name undefined, field name", str(exc))
def test__validate_clean_steps_names_not_unique(self):
steps = [{"name": "foo",
@@ -498,7 +497,7 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
exc = self.assertRaises(exception.NodeCleaningFailure,
ansible_deploy._validate_clean_steps,
steps, self.node.uuid)
- self.assertIn("unique names", six.text_type(exc))
+ self.assertIn("unique names", str(exc))
@mock.patch.object(ansible_deploy.yaml, 'safe_load', autospec=True)
def test__get_clean_steps(self, load_mock):
diff --git a/ironic/tests/unit/drivers/modules/ilo/test_boot.py b/ironic/tests/unit/drivers/modules/ilo/test_boot.py
index 384f5f43f..8ff57b09a 100644
--- a/ironic/tests/unit/drivers/modules/ilo/test_boot.py
+++ b/ironic/tests/unit/drivers/modules/ilo/test_boot.py
@@ -15,12 +15,12 @@
"""Test class for boot methods used by iLO modules."""
+import io
import tempfile
from ironic_lib import utils as ironic_utils
import mock
from oslo_config import cfg
-import six
from ironic.common import boot_devices
from ironic.common import exception
@@ -43,10 +43,6 @@ from ironic.drivers import utils as driver_utils
from ironic.tests.unit.drivers.modules.ilo import test_common
-if six.PY3:
- import io
- file = io.BytesIO
-
CONF = cfg.CONF
@@ -183,9 +179,9 @@ class IloBootPrivateMethodsTestCase(test_common.BaseIloTest):
CONF.pxe.pxe_append_params = 'kernel-params'
swift_obj_mock = swift_api_mock.return_value
- fileobj_mock = mock.MagicMock(spec=file)
+ fileobj_mock = mock.MagicMock(spec=io.BytesIO)
fileobj_mock.name = 'tmpfile'
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = fileobj_mock
tempfile_mock.return_value = mock_file_handle
@@ -241,9 +237,9 @@ class IloBootPrivateMethodsTestCase(test_common.BaseIloTest):
CONF.deploy.http_root = "/httpboot"
CONF.pxe.pxe_append_params = 'kernel-params'
- fileobj_mock = mock.MagicMock(spec=file)
+ fileobj_mock = mock.MagicMock(spec=io.BytesIO)
fileobj_mock.name = 'tmpfile'
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = fileobj_mock
tempfile_mock.return_value = mock_file_handle
@@ -307,9 +303,9 @@ class IloBootPrivateMethodsTestCase(test_common.BaseIloTest):
CONF.deploy.http_root = "/httpboot"
CONF.pxe.pxe_append_params = 'kernel-params'
- fileobj_mock = mock.MagicMock(spec=file)
+ fileobj_mock = mock.MagicMock(spec=io.BytesIO)
fileobj_mock.name = 'tmpfile'
- mock_file_handle = mock.MagicMock(spec=file)
+ mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = fileobj_mock
tempfile_mock.return_value = mock_file_handle
diff --git a/ironic/tests/unit/drivers/modules/ilo/test_common.py b/ironic/tests/unit/drivers/modules/ilo/test_common.py
index 64a270ad2..466f35a0c 100644
--- a/ironic/tests/unit/drivers/modules/ilo/test_common.py
+++ b/ironic/tests/unit/drivers/modules/ilo/test_common.py
@@ -15,7 +15,9 @@
"""Test class for common methods used by iLO modules."""
+import builtins
import hashlib
+import io
import os
import shutil
import tempfile
@@ -25,8 +27,6 @@ import mock
from oslo_config import cfg
from oslo_utils import importutils
from oslo_utils import uuidutils
-import six
-import six.moves.builtins as __builtin__
from ironic.common import boot_devices
from ironic.common import exception
@@ -45,11 +45,6 @@ INFO_DICT = db_utils.get_test_ilo_info()
ilo_client = importutils.try_import('proliantutils.ilo.client')
ilo_error = importutils.try_import('proliantutils.exception')
-if six.PY3:
- import io
- file = io.BytesIO
-
-
CONF = cfg.CONF
@@ -315,8 +310,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
autospec=True)
def test__prepare_floppy_image(self, tempfile_mock, fatimage_mock,
swift_api_mock):
- mock_image_file_handle = mock.MagicMock(spec=file)
- mock_image_file_obj = mock.MagicMock(spec=file)
+ mock_image_file_handle = mock.MagicMock(spec=io.BytesIO)
+ mock_image_file_obj = mock.MagicMock(spec=io.BytesIO)
mock_image_file_obj.name = 'image-tmp-file'
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
@@ -355,8 +350,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
def test__prepare_floppy_image_use_webserver(self, tempfile_mock,
fatimage_mock,
copy_mock):
- mock_image_file_handle = mock.MagicMock(spec=file)
- mock_image_file_obj = mock.MagicMock(spec=file)
+ mock_image_file_handle = mock.MagicMock(spec=io.BytesIO)
+ mock_image_file_obj = mock.MagicMock(spec=io.BytesIO)
mock_image_file_obj.name = 'image-tmp-file'
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
@@ -1038,11 +1033,11 @@ class IloCommonMethodsTestCase(BaseIloTest):
# | THEN |
unlink_mock.assert_called_once_with('/any_path1/any_file')
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
def test_verify_image_checksum(self, open_mock):
# | GIVEN |
data = b'Yankee Doodle went to town riding on a pony;'
- file_like_object = six.BytesIO(data)
+ file_like_object = io.BytesIO(data)
open_mock().__enter__.return_value = file_like_object
actual_hash = hashlib.md5(data).hexdigest()
# | WHEN |
@@ -1058,12 +1053,12 @@ class IloCommonMethodsTestCase(BaseIloTest):
ilo_common.verify_image_checksum,
invalid_file_path, 'hash_xxx')
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
def test_verify_image_checksum_throws_for_failed_validation(self,
open_mock):
# | GIVEN |
data = b'Yankee Doodle went to town riding on a pony;'
- file_like_object = six.BytesIO(data)
+ file_like_object = io.BytesIO(data)
open_mock().__enter__.return_value = file_like_object
invalid_hash = 'invalid_hash_value'
# | WHEN | & | THEN |
diff --git a/ironic/tests/unit/drivers/modules/ilo/test_console.py b/ironic/tests/unit/drivers/modules/ilo/test_console.py
index 6f885952e..2db07c0b2 100644
--- a/ironic/tests/unit/drivers/modules/ilo/test_console.py
+++ b/ironic/tests/unit/drivers/modules/ilo/test_console.py
@@ -16,7 +16,6 @@
"""Test class for common methods used by iLO modules."""
import mock
-import six
from ironic.common import exception
from ironic.conductor import task_manager
@@ -25,11 +24,6 @@ from ironic.drivers.modules import ipmitool
from ironic.tests.unit.drivers.modules.ilo import test_common
-if six.PY3:
- import io
- file = io.BytesIO
-
-
class IloConsoleInterfaceTestCase(test_common.BaseIloTest):
boot_interface = 'ilo-virtual-media'
diff --git a/ironic/tests/unit/drivers/modules/ilo/test_firmware_processor.py b/ironic/tests/unit/drivers/modules/ilo/test_firmware_processor.py
index ea0b14790..89aa96f9f 100644
--- a/ironic/tests/unit/drivers/modules/ilo/test_firmware_processor.py
+++ b/ironic/tests/unit/drivers/modules/ilo/test_firmware_processor.py
@@ -13,12 +13,13 @@
# under the License.
"""Test class for Firmware Processor used by iLO management interface."""
+
+import builtins
import io
+from urllib import parse as urlparse
import mock
from oslo_utils import importutils
-from six.moves import builtins as __builtin__
-import six.moves.urllib.parse as urlparse
from ironic.common import exception
from ironic.drivers.modules.ilo import common as ilo_common
@@ -42,8 +43,8 @@ class FirmwareProcessorTestCase(base.TestCase):
firmware_update_args = {'firmware_update_mode': 'invalid_mode',
'firmware_images': None}
# Note(deray): Need to set __name__ attribute explicitly to keep
- # ``six.wraps`` happy. Passing this to the `name` argument at the time
- # creation of Mock doesn't help.
+ # ``functools.wraps`` happy. Passing this to the `name` argument at
+ # the time creation of Mock doesn't help.
update_firmware_mock.__name__ = 'update_firmware_mock'
wrapped_func = (ilo_fw_processor.
verify_firmware_update_args(update_firmware_mock))
@@ -370,7 +371,7 @@ class FirmwareProcessorTestCase(base.TestCase):
shutil_mock.rmtree.assert_called_once_with(
tempfile_mock.mkdtemp(), ignore_errors=True)
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
@mock.patch.object(
ilo_fw_processor.image_service, 'FileImageService', autospec=True)
def test__download_file_based_fw_to_copies_file_to_target(
@@ -390,7 +391,7 @@ class FirmwareProcessorTestCase(base.TestCase):
file_image_service_mock.return_value.download.assert_called_once_with(
firmware_file_path, fd_mock)
- @mock.patch.object(__builtin__, 'open', autospec=True)
+ @mock.patch.object(builtins, 'open', autospec=True)
@mock.patch.object(ilo_fw_processor, 'image_service', autospec=True)
def test__download_http_based_fw_to_downloads_the_fw_file(
self, image_service_mock, open_mock):
diff --git a/ironic/tests/unit/drivers/modules/ilo/test_inspect.py b/ironic/tests/unit/drivers/modules/ilo/test_inspect.py
index 3dde5ca59..deb3f2e2d 100644
--- a/ironic/tests/unit/drivers/modules/ilo/test_inspect.py
+++ b/ironic/tests/unit/drivers/modules/ilo/test_inspect.py
@@ -16,7 +16,6 @@
"""Test class for Management Interface used by iLO modules."""
import mock
-import six
from ironic.common import exception
from ironic.common import states
@@ -365,7 +364,7 @@ class TestInspectPrivateMethods(test_common.BaseIloTest):
self.node,
ilo_mock)
self.assertEqual(
- six.text_type(result),
+ str(result),
("Failed to inspect hardware. Reason: Server didn't return the "
"key(s): cpu_arch"))
diff --git a/ironic/tests/unit/drivers/modules/irmc/test_boot.py b/ironic/tests/unit/drivers/modules/irmc/test_boot.py
index 3dd100133..68ba24297 100644
--- a/ironic/tests/unit/drivers/modules/irmc/test_boot.py
+++ b/ironic/tests/unit/drivers/modules/irmc/test_boot.py
@@ -16,6 +16,7 @@
Test class for iRMC Boot Driver
"""
+import io
import os
import shutil
import tempfile
@@ -24,7 +25,6 @@ from ironic_lib import utils as ironic_utils
import mock
from oslo_config import cfg
from oslo_utils import uuidutils
-import six
from ironic.common import boot_devices
from ironic.common import exception
@@ -47,10 +47,6 @@ from ironic.tests.unit.drivers.modules import test_pxe
from ironic.tests.unit.drivers import third_party_driver_mock_specs \
as mock_specs
from ironic.tests.unit.objects import utils as obj_utils
-if six.PY3:
- import io
- file = io.BytesIO
-
INFO_DICT = db_utils.get_test_irmc_info()
CONF = cfg.CONF
@@ -519,7 +515,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
tempfile_mock,
create_vfat_image_mock,
copyfile_mock):
- mock_image_file_handle = mock.MagicMock(spec=file)
+ mock_image_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_image_file_obj = mock.MagicMock()
mock_image_file_obj.name = 'image-tmp-file'
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
@@ -546,7 +542,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
tempfile_mock,
create_vfat_image_mock,
copyfile_mock):
- mock_image_file_handle = mock.MagicMock(spec=file)
+ mock_image_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_image_file_obj = mock.MagicMock()
mock_image_file_obj.name = 'image-tmp-file'
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
diff --git a/ironic/tests/unit/drivers/modules/test_agent_client.py b/ironic/tests/unit/drivers/modules/test_agent_client.py
index 4a5d6f89f..9d1af1201 100644
--- a/ironic/tests/unit/drivers/modules/test_agent_client.py
+++ b/ironic/tests/unit/drivers/modules/test_agent_client.py
@@ -12,13 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from http import client as http_client
import json
import mock
import requests
import retrying
-import six
-from six.moves import http_client
from ironic.common import exception
from ironic import conf
@@ -31,7 +30,7 @@ CONF = conf.CONF
class MockResponse(object):
def __init__(self, text, status_code=http_client.OK):
- assert isinstance(text, six.string_types)
+ assert isinstance(text, str)
self.text = text
self.status_code = status_code
diff --git a/ironic/tests/unit/drivers/modules/test_image_cache.py b/ironic/tests/unit/drivers/modules/test_image_cache.py
index 37ae008ec..bd57332fb 100644
--- a/ironic/tests/unit/drivers/modules/test_image_cache.py
+++ b/ironic/tests/unit/drivers/modules/test_image_cache.py
@@ -24,7 +24,6 @@ import uuid
import mock
from oslo_utils import uuidutils
-import six
from ironic.common import exception
from ironic.common import image_service
@@ -168,8 +167,7 @@ class TestImageCacheFetch(base.TestCase):
autospec=True)
def test_fetch_image_not_uuid(self, mock_download, mock_clean_up):
href = u'http://abc.com/ubuntu.qcow2'
- href_encoded = href.encode('utf-8') if six.PY2 else href
- href_converted = str(uuid.uuid5(uuid.NAMESPACE_URL, href_encoded))
+ href_converted = str(uuid.uuid5(uuid.NAMESPACE_URL, href))
master_path = ''.join([os.path.join(self.master_dir, href_converted),
'.converted'])
self.cache.fetch_image(href, self.dest_path)
@@ -184,8 +182,7 @@ class TestImageCacheFetch(base.TestCase):
def test_fetch_image_not_uuid_no_force_raw(self, mock_download,
mock_clean_up):
href = u'http://abc.com/ubuntu.qcow2'
- href_encoded = href.encode('utf-8') if six.PY2 else href
- href_converted = str(uuid.uuid5(uuid.NAMESPACE_URL, href_encoded))
+ href_converted = str(uuid.uuid5(uuid.NAMESPACE_URL, href))
master_path = os.path.join(self.master_dir, href_converted)
self.cache.fetch_image(href, self.dest_path, force_raw=False)
mock_download.assert_called_once_with(
diff --git a/ironic/tests/unit/drivers/modules/test_ipmitool.py b/ironic/tests/unit/drivers/modules/test_ipmitool.py
index c27e070a3..7404f7a37 100644
--- a/ironic/tests/unit/drivers/modules/test_ipmitool.py
+++ b/ironic/tests/unit/drivers/modules/test_ipmitool.py
@@ -34,7 +34,6 @@ from ironic_lib import utils as ironic_utils
import mock
from oslo_concurrency import processutils
from oslo_utils import uuidutils
-import six
from ironic.common import boot_devices
from ironic.common import exception
@@ -474,8 +473,9 @@ class Base(db_base.DbTestCase):
self.vendor = ipmi.VendorPassthru()
-@six.add_metaclass(IPMIToolPrivateMethodTestCaseMeta)
-class IPMIToolPrivateMethodTestCase(Base):
+class IPMIToolPrivateMethodTestCase(
+ Base,
+ metaclass=IPMIToolPrivateMethodTestCaseMeta):
def setUp(self):
super(IPMIToolPrivateMethodTestCase, self).setUp()
@@ -529,7 +529,7 @@ class IPMIToolPrivateMethodTestCase(Base):
ValueError,
self._test__make_password_file,
12345, ValueError('we should fail'))
- self.assertEqual('we should fail', six.text_type(result))
+ self.assertEqual('we should fail', str(result))
@mock.patch.object(tempfile, 'NamedTemporaryFile',
new=mock.MagicMock(side_effect=OSError('Test Error')))
@@ -548,7 +548,7 @@ class IPMIToolPrivateMethodTestCase(Base):
result = self.assertRaises(
OverflowError,
self._test__make_password_file, 12345)
- self.assertEqual('Test Error', six.text_type(result))
+ self.assertEqual('Test Error', str(result))
def test__make_password_file_write_exception(self):
# Test exception in _make_password_file for write()
@@ -761,8 +761,8 @@ class IPMIToolPrivateMethodTestCase(Base):
info['ipmi_password'] = 12345678
node = obj_utils.get_test_node(self.context, driver_info=info)
ret = ipmi._parse_driver_info(node)
- self.assertEqual(six.u('12345678'), ret['password'])
- self.assertIsInstance(ret['password'], six.text_type)
+ self.assertEqual(u'12345678', ret['password'])
+ self.assertIsInstance(ret['password'], str)
def test__parse_driver_info_ipmi_prot_version_1_5(self):
info = dict(INFO_DICT)
diff --git a/ironic/tests/unit/drivers/modules/xclarity/test_management.py b/ironic/tests/unit/drivers/modules/xclarity/test_management.py
index 754e50a61..d66da9b8f 100644
--- a/ironic/tests/unit/drivers/modules/xclarity/test_management.py
+++ b/ironic/tests/unit/drivers/modules/xclarity/test_management.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+import importlib
import sys
import mock
from oslo_utils import importutils
-import six
from ironic.common import boot_devices
from ironic.common import exception
@@ -75,7 +75,7 @@ class XClarityManagementDriverTestCase(db_base.DbTestCase):
sys.modules['xclarity_client.exceptions'] = (
xclarity_client_exceptions)
if 'ironic.drivers.modules.xclarity' in sys.modules:
- six.moves.reload_module(
+ importlib.reload(
sys.modules['ironic.drivers.modules.xclarity'])
ex = exception.XClarityError('E')
mock_get_xc_client.return_value.set_node_boot_info.side_effect = ex
@@ -110,7 +110,7 @@ class XClarityManagementDriverTestCase(db_base.DbTestCase):
sys.modules['xclarity_client.exceptions'] = (
xclarity_client_exceptions)
if 'ironic.drivers.modules.xclarity' in sys.modules:
- six.moves.reload_module(
+ importlib.reload(
sys.modules['ironic.drivers.modules.xclarity'])
ex = exception.XClarityError('E')
mock_xc_client.return_value.get_node_all_boot_info.side_effect = ex
diff --git a/ironic/tests/unit/drivers/modules/xclarity/test_power.py b/ironic/tests/unit/drivers/modules/xclarity/test_power.py
index d259a6b28..86f1e3318 100644
--- a/ironic/tests/unit/drivers/modules/xclarity/test_power.py
+++ b/ironic/tests/unit/drivers/modules/xclarity/test_power.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+import importlib
import sys
import mock
from oslo_utils import importutils
-import six
from ironic.common import exception
from ironic.common import states
@@ -80,7 +80,7 @@ class XClarityPowerDriverTestCase(db_base.DbTestCase):
sys.modules['xclarity_client.exceptions'] = (
xclarity_client_exceptions)
if 'ironic.drivers.modules.xclarity' in sys.modules:
- six.moves.reload_module(
+ importlib.reload(
sys.modules['ironic.drivers.modules.xclarity'])
ex = exception.XClarityError('E')
mock_xc_client.return_value.get_node_power_status.side_effect = ex
@@ -118,7 +118,7 @@ class XClarityPowerDriverTestCase(db_base.DbTestCase):
sys.modules['xclarity_client.exceptions'] = (
xclarity_client_exceptions)
if 'ironic.drivers.modules.xclarity' in sys.modules:
- six.moves.reload_module(
+ importlib.reload(
sys.modules['ironic.drivers.modules.xclarity'])
ex = exception.XClarityError('E')
mock_xc_client.return_value.set_node_power_status.side_effect = ex
diff --git a/ironic/tests/unit/drivers/third_party_driver_mocks.py b/ironic/tests/unit/drivers/third_party_driver_mocks.py
index 960846189..3f3346a3d 100644
--- a/ironic/tests/unit/drivers/third_party_driver_mocks.py
+++ b/ironic/tests/unit/drivers/third_party_driver_mocks.py
@@ -29,11 +29,11 @@ Current list of mocked libraries:
- python-ibmcclient
"""
+import importlib
import sys
import mock
from oslo_utils import importutils
-import six
from ironic.drivers.modules import ipmitool
from ironic.tests.unit.drivers import third_party_driver_mock_specs \
@@ -68,7 +68,7 @@ if not proliantutils:
proliantutils.exception.ImageExtractionFailed = type(
'ImageExtractionFailed', (Exception,), {})
if 'ironic.drivers.ilo' in sys.modules:
- six.moves.reload_module(sys.modules['ironic.drivers.ilo'])
+ importlib.reload(sys.modules['ironic.drivers.ilo'])
redfish = importutils.try_import('redfish')
if not redfish:
@@ -76,7 +76,7 @@ if not redfish:
sys.modules['redfish'] = redfish
if 'ironic.drivers.redfish' in sys.modules:
- six.moves.reload_module(sys.modules['ironic.drivers.modules.redfish'])
+ importlib.reload(sys.modules['ironic.drivers.modules.redfish'])
# attempt to load the external 'python-dracclient' library, which is required
# by the optional drivers.modules.drac module
@@ -109,7 +109,7 @@ if not dracclient:
# Now that the external library has been mocked, if anything had already
# loaded any of the drivers, reload them.
if 'ironic.drivers.modules.drac' in sys.modules:
- six.moves.reload_module(sys.modules['ironic.drivers.modules.drac'])
+ importlib.reload(sys.modules['ironic.drivers.modules.drac'])
# attempt to load the external 'pysnmp' library, which is required by
@@ -128,7 +128,7 @@ if not pysnmp:
# if anything has loaded the snmp driver yet, reload it now that the
# external library has been mocked
if 'ironic.drivers.modules.snmp' in sys.modules:
- six.moves.reload_module(sys.modules['ironic.drivers.modules.snmp'])
+ importlib.reload(sys.modules['ironic.drivers.modules.snmp'])
# attempt to load the external 'scciclient' library, which is required by
@@ -154,7 +154,7 @@ if not scciclient:
# if anything has loaded the iRMC driver yet, reload it now that the
# external library has been mocked
if 'ironic.drivers.modules.irmc' in sys.modules:
- six.moves.reload_module(sys.modules['ironic.drivers.modules.irmc'])
+ importlib.reload(sys.modules['ironic.drivers.modules.irmc'])
# install mock object to prevent the irmc-virtual-media boot interface from
@@ -227,8 +227,7 @@ if not sushy:
sys.modules['sushy.auth'] = sushy.auth
if 'ironic.drivers.modules.redfish' in sys.modules:
- six.moves.reload_module(
- sys.modules['ironic.drivers.modules.redfish'])
+ importlib.reload(sys.modules['ironic.drivers.modules.redfish'])
xclarity_client = importutils.try_import('xclarity_client')
if not xclarity_client:
@@ -287,5 +286,4 @@ if not ibmc_client:
sys.modules['ibmc_client.constants'] = constants
if 'ironic.drivers.modules.ibmc' in sys.modules:
- six.moves.reload_module(
- sys.modules['ironic.drivers.modules.ibmc'])
+ importlib.reload(sys.modules['ironic.drivers.modules.ibmc'])
diff --git a/ironic/tests/unit/objects/test_objects.py b/ironic/tests/unit/objects/test_objects.py
index 993a1eb9c..33ae36d6d 100644
--- a/ironic/tests/unit/objects/test_objects.py
+++ b/ironic/tests/unit/objects/test_objects.py
@@ -22,7 +22,6 @@ from oslo_utils import timeutils
from oslo_versionedobjects import base as object_base
from oslo_versionedobjects import exception as object_exception
from oslo_versionedobjects import fixture as object_fixture
-import six
from ironic.common import context
from ironic.common import release_mappings
@@ -629,7 +628,7 @@ class _TestObject(object):
try:
obj['bar'] = 'value'
except TypeError as e:
- err_message = six.text_type(e)
+ err_message = str(e)
finally:
self.assertIn("'TestObj' object does not support item assignment",
err_message)
diff --git a/ironic/tests/unit/objects/utils.py b/ironic/tests/unit/objects/utils.py
index ccc800607..26c3a22e7 100644
--- a/ironic/tests/unit/objects/utils.py
+++ b/ironic/tests/unit/objects/utils.py
@@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
"""Ironic object test utilities."""
-import inspect
-import six
+import functools
+import inspect
from ironic.common import exception
from ironic.common.i18n import _
@@ -25,7 +25,7 @@ from ironic.tests.unit.db import utils as db_utils
def check_keyword_arguments(func):
- @six.wraps(func)
+ @functools.wraps(func)
def wrapper(**kw):
obj_type = kw.pop('object_type')
result = func(**kw)
diff --git a/lower-constraints.txt b/lower-constraints.txt
index ef8bc5889..d7f7decad 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -58,7 +58,6 @@ requests==2.14.2
requestsexceptions==1.4.0
retrying==1.2.3
rfc3986==0.3.1
-six==1.10.0
Sphinx==1.6.2
sphinxcontrib-httpdomain==1.6.1
sphinxcontrib-pecanwsme==0.10.0
diff --git a/requirements.txt b/requirements.txt
index d337ce44d..fff36d71b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -35,7 +35,6 @@ os-traits>=0.4.0 # Apache-2.0
pecan!=1.0.2,!=1.0.3,!=1.0.4,!=1.2,>=1.0.0 # BSD
requests>=2.14.2 # Apache-2.0
rfc3986>=0.3.1 # Apache-2.0
-six>=1.10.0 # MIT
jsonpatch!=1.20,>=1.16 # BSD
WSME>=0.9.3 # MIT
Jinja2>=2.10 # BSD License (3 clause)