summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/ext/support_matrix.py3
-rw-r--r--nova/api/ec2/__init__.py2
-rw-r--r--nova/api/ec2/cloud.py3
-rw-r--r--nova/api/ec2/ec2utils.py3
-rw-r--r--nova/api/openstack/__init__.py3
-rw-r--r--nova/api/openstack/compute/plugins/v3/servers.py2
-rw-r--r--nova/api/openstack/compute/servers.py2
-rw-r--r--nova/api/openstack/wsgi.py2
-rw-r--r--nova/compute/flavors.py2
-rw-r--r--nova/compute/utils.py5
-rw-r--r--nova/network/floating_ips.py4
-rw-r--r--nova/objects/fields.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/contrib/test_flavor_manage.py5
-rw-r--r--nova/tests/unit/api/openstack/compute/contrib/test_migrate_server.py3
-rw-r--r--nova/tests/unit/api/openstack/compute/test_flavors.py3
-rw-r--r--nova/tests/unit/api/openstack/test_faults.py3
-rw-r--r--nova/tests/unit/objects/test_instance_action.py6
-rw-r--r--nova/tests/unit/test_availability_zones.py3
-rw-r--r--nova/tests/unit/virt/hyperv/test_hypervapi.py18
-rw-r--r--nova/tests/unit/virt/ironic/test_driver.py3
-rw-r--r--nova/tests/unit/virt/libvirt/test_volume.py5
-rw-r--r--nova/tests/unit/virt/test_virt.py3
-rw-r--r--nova/tests/unit/virt/vmwareapi/test_vmops.py5
-rw-r--r--nova/utils.py6
-rw-r--r--nova/virt/ironic/driver.py2
25 files changed, 58 insertions, 40 deletions
diff --git a/doc/ext/support_matrix.py b/doc/ext/support_matrix.py
index 6e423fdc02..6adeb812a6 100644
--- a/doc/ext/support_matrix.py
+++ b/doc/ext/support_matrix.py
@@ -24,6 +24,7 @@ It is used via a single directive in the .rst file
import re
+import six
from six.moves import configparser
from docutils import nodes
@@ -111,7 +112,7 @@ class SupportMatrixTarget(object):
class SupportMatrixDirective(rst.Directive):
option_spec = {
- 'support-matrix': unicode,
+ 'support-matrix': six.text_type,
}
def run(self):
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py
index ddbe8c3df5..7acfdc4f6f 100644
--- a/nova/api/ec2/__init__.py
+++ b/nova/api/ec2/__init__.py
@@ -572,7 +572,7 @@ def ec2_error_ex(ex, req, code=None, message=None, unexpected=False):
log_fun(log_msg, log_msg_args, context=context)
if ex.args and not message and (not unexpected or status < 500):
- message = unicode(ex.args[0])
+ message = six.text_type(ex.args[0])
if unexpected:
# Log filtered environment for unexpected errors.
env = req.environ.copy()
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 6ae06254ec..8ddb2e15a4 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -26,6 +26,7 @@ import time
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import timeutils
+import six
from nova.api.ec2 import ec2utils
from nova.api.ec2 import inst_state
@@ -726,7 +727,7 @@ class CloudController(object):
return source_project_id
def create_security_group(self, context, group_name, group_description):
- if isinstance(group_name, unicode):
+ if isinstance(group_name, six.text_type):
group_name = utils.utf8(group_name)
if CONF.ec2_strict_validation:
# EC2 specification gives constraints for name and description:
diff --git a/nova/api/ec2/ec2utils.py b/nova/api/ec2/ec2utils.py
index 5e6322f606..690d9a379c 100644
--- a/nova/api/ec2/ec2utils.py
+++ b/nova/api/ec2/ec2utils.py
@@ -20,6 +20,7 @@ import re
from oslo_log import log as logging
from oslo_utils import timeutils
from oslo_utils import uuidutils
+import six
from nova import context
from nova import exception
@@ -413,7 +414,7 @@ def dict_from_dotted_str(items):
for key, value in items:
parts = key.split(".")
key = str(camelcase_to_underscore(parts[0]))
- if isinstance(value, str) or isinstance(value, unicode):
+ if isinstance(value, six.string_types):
# NOTE(vish): Automatically convert strings back
# into their respective values
value = _try_convert(value)
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index dd1f840220..a46acda39a 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -21,6 +21,7 @@ WSGI middleware for OpenStack API controllers.
from oslo_config import cfg
from oslo_log import log as logging
import routes
+import six
import stevedore
import webob.dec
import webob.exc
@@ -90,7 +91,7 @@ class FaultWrapper(base_wsgi.Middleware):
status, webob.exc.HTTPInternalServerError)()
def _error(self, inner, req):
- LOG.exception(_LE("Caught error: %s"), unicode(inner))
+ LOG.exception(_LE("Caught error: %s"), six.text_type(inner))
safe = getattr(inner, 'safe', False)
headers = getattr(inner, 'headers', None)
diff --git a/nova/api/openstack/compute/plugins/v3/servers.py b/nova/api/openstack/compute/plugins/v3/servers.py
index ff09a7b16f..4cee4ffe1e 100644
--- a/nova/api/openstack/compute/plugins/v3/servers.py
+++ b/nova/api/openstack/compute/plugins/v3/servers.py
@@ -908,7 +908,7 @@ class ServersController(wsgi.Controller):
if not image_href and create_kwargs.get('block_device_mapping'):
return ''
elif image_href:
- return self._image_uuid_from_href(unicode(image_href))
+ return self._image_uuid_from_href(six.text_type(image_href))
else:
msg = _("Missing imageRef attribute")
raise exc.HTTPBadRequest(explanation=msg)
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index f663b1418f..3bf1cd18af 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -842,7 +842,7 @@ class Controller(wsgi.Controller):
def _image_ref_from_req_data(self, data):
try:
- return unicode(data['server']['imageRef'])
+ return six.text_type(data['server']['imageRef'])
except (TypeError, KeyError):
msg = _("Missing imageRef attribute")
raise exc.HTTPBadRequest(explanation=msg)
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index 04613aab61..8358ba933c 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -775,7 +775,7 @@ class Resource(wsgi.Application):
if body:
msg = _("Action: '%(action)s', calling method: %(meth)s, body: "
"%(body)s") % {'action': action,
- 'body': unicode(body, 'utf-8'),
+ 'body': six.text_type(body, 'utf-8'),
'meth': str(meth)}
LOG.debug(strutils.mask_password(msg))
else:
diff --git a/nova/compute/flavors.py b/nova/compute/flavors.py
index 27dcb33eba..1228b092fb 100644
--- a/nova/compute/flavors.py
+++ b/nova/compute/flavors.py
@@ -119,7 +119,7 @@ def create(name, memory, vcpus, root_gb, ephemeral_gb=0, flavorid=None,
# NOTE(vish): Internally, flavorid is stored as a string but it comes
# in through json as an integer, so we convert it here.
- flavorid = unicode(flavorid)
+ flavorid = six.text_type(flavorid)
# ensure leading/trailing whitespaces not present.
if flavorid.strip() != flavorid:
diff --git a/nova/compute/utils.py b/nova/compute/utils.py
index 8f4c3816a6..3892af1c24 100644
--- a/nova/compute/utils.py
+++ b/nova/compute/utils.py
@@ -21,6 +21,7 @@ import traceback
import netifaces
from oslo_config import cfg
from oslo_log import log
+import six
from nova import block_device
from nova.compute import power_state
@@ -55,7 +56,7 @@ def exception_to_dict(fault):
# just because there is an unexpected error retrieving the message
except Exception:
try:
- message = unicode(fault)
+ message = six.text_type(fault)
except Exception:
message = None
if not message:
@@ -76,7 +77,7 @@ def _get_fault_details(exc_info, error_code):
tb = exc_info[2]
if tb:
details = ''.join(traceback.format_tb(tb))
- return unicode(details)
+ return six.text_type(details)
def add_instance_fault_from_exc(context, instance, fault, exc_info=None):
diff --git a/nova/network/floating_ips.py b/nova/network/floating_ips.py
index 036b2f210d..a83281893e 100644
--- a/nova/network/floating_ips.py
+++ b/nova/network/floating_ips.py
@@ -368,7 +368,7 @@ class FloatingIP(object):
"""Performs db and driver calls to associate floating ip & fixed ip."""
interface = CONF.public_interface or interface
- @utils.synchronized(unicode(floating_address))
+ @utils.synchronized(six.text_type(floating_address))
def do_associate():
# associate floating ip
floating = objects.FloatingIP.associate(context, floating_address,
@@ -464,7 +464,7 @@ class FloatingIP(object):
"""Performs db and driver calls to disassociate floating ip."""
interface = CONF.public_interface or interface
- @utils.synchronized(unicode(address))
+ @utils.synchronized(six.text_type(address))
def do_disassociate():
# NOTE(vish): Note that we are disassociating in the db before we
# actually remove the ip address on the host. We are
diff --git a/nova/objects/fields.py b/nova/objects/fields.py
index 226923652b..34fce242da 100644
--- a/nova/objects/fields.py
+++ b/nova/objects/fields.py
@@ -245,7 +245,7 @@ class String(FieldType):
# FIXME(danms): We should really try to avoid the need to do this
if isinstance(value, (six.string_types, int, long, float,
datetime.datetime)):
- return unicode(value)
+ return six.text_type(value)
else:
raise ValueError(_('A string is required in field %(attr)s, '
'not %(type)s') %
diff --git a/nova/tests/unit/api/openstack/compute/contrib/test_flavor_manage.py b/nova/tests/unit/api/openstack/compute/contrib/test_flavor_manage.py
index 950cdae39f..eb242c086d 100644
--- a/nova/tests/unit/api/openstack/compute/contrib/test_flavor_manage.py
+++ b/nova/tests/unit/api/openstack/compute/contrib/test_flavor_manage.py
@@ -17,6 +17,7 @@ import datetime
import mock
from oslo_serialization import jsonutils
+import six
import webob
from nova.api.openstack.compute.contrib import flavor_access as \
@@ -114,7 +115,7 @@ class FlavorManageTestV21(test.NoDBTestCase):
"vcpus": 2,
"disk": 1,
"OS-FLV-EXT-DATA:ephemeral": 1,
- "id": unicode('1234'),
+ "id": six.text_type('1234'),
"swap": 512,
"rxtx_factor": 1,
"os-flavor-access:is_public": True,
@@ -156,7 +157,7 @@ class FlavorManageTestV21(test.NoDBTestCase):
"vcpus": 2,
"disk": 1,
"OS-FLV-EXT-DATA:ephemeral": 1,
- "id": unicode('1234'),
+ "id": six.text_type('1234'),
"swap": 512,
"rxtx_factor": 1,
"os-flavor-access:is_public": True,
diff --git a/nova/tests/unit/api/openstack/compute/contrib/test_migrate_server.py b/nova/tests/unit/api/openstack/compute/contrib/test_migrate_server.py
index 41c8611c26..5af0189ee5 100644
--- a/nova/tests/unit/api/openstack/compute/contrib/test_migrate_server.py
+++ b/nova/tests/unit/api/openstack/compute/contrib/test_migrate_server.py
@@ -14,6 +14,7 @@
# under the License.
from oslo_utils import uuidutils
+import six
import webob
from nova.api.openstack.compute.contrib import admin_actions as \
@@ -214,7 +215,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
self.controller._migrate_live,
self.req, instance.uuid, body=body)
if check_response:
- self.assertIn(unicode(fake_exc), ex.explanation)
+ self.assertIn(six.text_type(fake_exc), ex.explanation)
def test_migrate_live_compute_service_unavailable(self):
self._test_migrate_live_failed_with_exception(
diff --git a/nova/tests/unit/api/openstack/compute/test_flavors.py b/nova/tests/unit/api/openstack/compute/test_flavors.py
index a71d59b9b8..926d9c22e4 100644
--- a/nova/tests/unit/api/openstack/compute/test_flavors.py
+++ b/nova/tests/unit/api/openstack/compute/test_flavors.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import six
import six.moves.urllib.parse as urlparse
import webob
@@ -607,7 +608,7 @@ class DisabledFlavorsWithRealDBTestV21(test.TestCase):
del inst_type['id']
inst_type['name'] += '.disabled'
- inst_type['flavorid'] = unicode(max(
+ inst_type['flavorid'] = six.text_type(max(
[int(flavor['flavorid']) for flavor in inst_types]) + 1)
inst_type['disabled'] = True
diff --git a/nova/tests/unit/api/openstack/test_faults.py b/nova/tests/unit/api/openstack/test_faults.py
index 09a70aab61..e022478931 100644
--- a/nova/tests/unit/api/openstack/test_faults.py
+++ b/nova/tests/unit/api/openstack/test_faults.py
@@ -16,6 +16,7 @@
import mock
from oslo_serialization import jsonutils
+import six
import webob
import webob.dec
import webob.exc
@@ -56,7 +57,7 @@ class TestFaultWrapper(test.NoDBTestCase):
# translate().
mock_translate.assert_any_call(u'Should be translated.', None)
# The return value from translate() should appear in the response.
- self.assertIn("I've been translated!", unicode(response.body))
+ self.assertIn("I've been translated!", six.text_type(response.body))
class TestFaults(test.NoDBTestCase):
diff --git a/nova/tests/unit/objects/test_instance_action.py b/nova/tests/unit/objects/test_instance_action.py
index fa56aa8304..ef4618f0d6 100644
--- a/nova/tests/unit/objects/test_instance_action.py
+++ b/nova/tests/unit/objects/test_instance_action.py
@@ -16,6 +16,7 @@ import traceback
import mock
from oslo_utils import timeutils
+import six
from nova import db
from nova.objects import instance_action
@@ -292,13 +293,14 @@ class _TestInstanceActionEventObject(object):
timeutils.set_time_override(override_time=NOW)
test_class = instance_action.InstanceActionEvent
expected_packed_values = test_class.pack_action_event_finish(
- self.context, 'fake-uuid', 'fake-event', 'val', unicode('fake-tb'))
+ self.context, 'fake-uuid', 'fake-event', 'val',
+ six.text_type('fake-tb'))
expected_packed_values['finish_time'] = timeutils.utcnow()
mock_finish.return_value = fake_event
event = test_class.event_finish_with_failure(
self.context, 'fake-uuid', 'fake-event', exc_val='val',
- exc_tb=unicode('fake-tb'), want_result=True)
+ exc_tb=six.text_type('fake-tb'), want_result=True)
mock_finish.assert_called_once_with(self.context,
expected_packed_values)
self.compare_obj(event, fake_event)
diff --git a/nova/tests/unit/test_availability_zones.py b/nova/tests/unit/test_availability_zones.py
index 2892dd665c..335bf3103e 100644
--- a/nova/tests/unit/test_availability_zones.py
+++ b/nova/tests/unit/test_availability_zones.py
@@ -18,6 +18,7 @@ Tests for availability zones
"""
from oslo_config import cfg
+import six
from nova import availability_zones as az
from nova import context
@@ -125,7 +126,7 @@ class AvailabilityZoneTestCases(test.TestCase):
service = self._create_service_with_topic('network', self.host)
services = db.service_get_all(self.context)
az.set_availability_zones(self.context, services)
- self.assertIsInstance(services[0]['host'], unicode)
+ self.assertIsInstance(services[0]['host'], six.text_type)
cached_key = az._make_cache_key(services[0]['host'])
self.assertIsInstance(cached_key, str)
self._destroy_service(service)
diff --git a/nova/tests/unit/virt/hyperv/test_hypervapi.py b/nova/tests/unit/virt/hyperv/test_hypervapi.py
index a8460e4aeb..06f2681e9c 100644
--- a/nova/tests/unit/virt/hyperv/test_hypervapi.py
+++ b/nova/tests/unit/virt/hyperv/test_hypervapi.py
@@ -25,6 +25,7 @@ import mock
from mox3 import mox
from oslo_config import cfg
from oslo_utils import units
+import six
from nova.api.metadata import base as instance_metadata
from nova import context
@@ -404,7 +405,7 @@ class HyperVAPITestCase(HyperVAPIBaseTestCase):
target_lun, target_portal, True)
vmutils.VMUtils.create_nic(mox.Func(self._check_vm_name),
- mox.IsA(str), mox.IsA(unicode)).InAnyOrder()
+ mox.IsA(str), mox.IsA(six.text_type)).InAnyOrder()
if setup_vif_mocks_func:
setup_vif_mocks_func()
@@ -464,7 +465,7 @@ class HyperVAPITestCase(HyperVAPIBaseTestCase):
fake.PathUtils.copyfile(mox.IsA(str), mox.IsA(str))
m = vhdutils.VHDUtils.get_internal_vhd_size_by_file_size(
- mox.IsA(unicode), mox.IsA(object))
+ mox.IsA(six.text_type), mox.IsA(object))
m.AndReturn(1025)
vhdutils.VHDUtils.resize_vhd(mox.IsA(str), mox.IsA(object),
@@ -511,7 +512,7 @@ class HyperVAPITestCase(HyperVAPIBaseTestCase):
if not (cow and vhd_format == constants.DISK_FORMAT_VHD):
m = vhdutils.VHDUtils.get_internal_vhd_size_by_file_size(
- mox.IsA(unicode), mox.IsA(object))
+ mox.IsA(six.text_type), mox.IsA(object))
m.AndReturn(1025)
vhdutils.VHDUtils.resize_vhd(mox.IsA(str), mox.IsA(object),
is_file_max_size=False)
@@ -950,7 +951,7 @@ class HyperVAPITestCase(HyperVAPIBaseTestCase):
m.AndReturn(self._test_instance_dir)
self._mox.StubOutWithMock(fake.PathUtils, 'exists')
- m = fake.PathUtils.exists(mox.IsA(unicode))
+ m = fake.PathUtils.exists(mox.IsA(six.text_type))
m.AndReturn(True)
fake_parent_vhd_path = (os.path.join('FakeParentPath', '%s.vhd' %
@@ -960,15 +961,16 @@ class HyperVAPITestCase(HyperVAPIBaseTestCase):
m.AndReturn({'ParentPath': fake_parent_vhd_path,
'MaxInternalSize': 1})
m = vhdutils.VHDUtils.get_internal_vhd_size_by_file_size(
- mox.IsA(unicode), mox.IsA(object))
+ mox.IsA(six.text_type), mox.IsA(object))
m.AndReturn(1025)
- vhdutils.VHDUtils.reconnect_parent_vhd(mox.IsA(str), mox.IsA(unicode))
+ vhdutils.VHDUtils.reconnect_parent_vhd(mox.IsA(str),
+ mox.IsA(six.text_type))
- m = vhdutils.VHDUtils.get_vhd_info(mox.IsA(unicode))
+ m = vhdutils.VHDUtils.get_vhd_info(mox.IsA(six.text_type))
m.AndReturn({'MaxInternalSize': 1024})
- m = fake.PathUtils.exists(mox.IsA(unicode))
+ m = fake.PathUtils.exists(mox.IsA(six.text_type))
m.AndReturn(True)
m = fake.PathUtils.get_instance_dir(mox.IsA(str))
diff --git a/nova/tests/unit/virt/ironic/test_driver.py b/nova/tests/unit/virt/ironic/test_driver.py
index fe332d50dd..0ba3438bd8 100644
--- a/nova/tests/unit/virt/ironic/test_driver.py
+++ b/nova/tests/unit/virt/ironic/test_driver.py
@@ -20,6 +20,7 @@ import mock
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
+import six
from nova.api.metadata import base as instance_metadata
from nova.compute import power_state as nova_states
@@ -1116,7 +1117,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
node=node_uuid)
network_info = utils.get_test_network_info()
- port_id = unicode(network_info[0]['id'])
+ port_id = six.text_type(network_info[0]['id'])
expected_patch = [{'op': 'add',
'path': '/extra/vif_port_id',
'value': port_id}]
diff --git a/nova/tests/unit/virt/libvirt/test_volume.py b/nova/tests/unit/virt/libvirt/test_volume.py
index de9a22b573..f9bde3ad6a 100644
--- a/nova/tests/unit/virt/libvirt/test_volume.py
+++ b/nova/tests/unit/virt/libvirt/test_volume.py
@@ -24,6 +24,7 @@ import fixtures
import mock
from oslo_concurrency import processutils
from oslo_config import cfg
+import six
from nova.compute import arch
from nova import exception
@@ -1374,7 +1375,7 @@ Setting up iSCSI targets: unused
self.stubs.Set(linuxscsi, 'find_multipath_device', lambda x: devices)
self.stubs.Set(linuxscsi, 'remove_device', lambda x: None)
# Should work for string, unicode, and list
- wwns = ['1234567890123456', unicode('1234567890123456'),
+ wwns = ['1234567890123456', six.text_type('1234567890123456'),
['1234567890123456', '1234567890123457']]
for wwn in wwns:
connection_info = self.fibrechan_connection(self.vol,
@@ -1464,7 +1465,7 @@ Setting up iSCSI targets: unused
self.stubs.Set(linuxscsi, 'find_multipath_device', lambda x: devices)
self.stubs.Set(linuxscsi, 'remove_device', lambda x: None)
# Should work for string, unicode, and list
- wwns = ['1234567890123456', unicode('1234567890123456'),
+ wwns = ['1234567890123456', six.text_type('1234567890123456'),
['1234567890123456']]
expected_remove_calls = []
for wwn in wwns:
diff --git a/nova/tests/unit/virt/test_virt.py b/nova/tests/unit/virt/test_virt.py
index 67b0ac503a..0e4b302b9d 100644
--- a/nova/tests/unit/virt/test_virt.py
+++ b/nova/tests/unit/virt/test_virt.py
@@ -17,6 +17,7 @@ import io
import os
import mock
+import six
from nova import test
from nova import utils
@@ -120,7 +121,7 @@ class FakeMount(object):
class TestDiskImage(test.NoDBTestCase):
def mock_proc_mounts(self, mock_open):
- response = io.StringIO(unicode(PROC_MOUNTS_CONTENTS))
+ response = io.StringIO(six.text_type(PROC_MOUNTS_CONTENTS))
mock_open.return_value = response
@mock.patch('__builtin__.open')
diff --git a/nova/tests/unit/virt/vmwareapi/test_vmops.py b/nova/tests/unit/virt/vmwareapi/test_vmops.py
index 8dee7c4887..40e6c4f213 100644
--- a/nova/tests/unit/virt/vmwareapi/test_vmops.py
+++ b/nova/tests/unit/virt/vmwareapi/test_vmops.py
@@ -20,6 +20,7 @@ from oslo_utils import uuidutils
from oslo_vmware import exceptions as vexc
from oslo_vmware.objects import datastore as ds_obj
from oslo_vmware import vim_util as vutil
+import six
from nova.compute import power_state
from nova import context
@@ -1315,9 +1316,9 @@ class VMwareVMOpsTestCase(test.NoDBTestCase):
self._verify_spawn_method_calls(_call_method, extras)
dc_ref = 'fake_dc_ref'
- source_file = unicode('[fake_ds] vmware_base/%s/%s.vmdk' %
+ source_file = six.text_type('[fake_ds] vmware_base/%s/%s.vmdk' %
(self._image_id, self._image_id))
- dest_file = unicode('[fake_ds] vmware_base/%s/%s.%d.vmdk' %
+ dest_file = six.text_type('[fake_ds] vmware_base/%s/%s.%d.vmdk' %
(self._image_id, self._image_id,
self._instance['root_gb']))
# TODO(dims): add more tests for copy_virtual_disk after
diff --git a/nova/utils.py b/nova/utils.py
index 2cc51ffe6a..9811ff5f3a 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -424,7 +424,7 @@ def utf8(value):
http://github.com/facebook/tornado/blob/master/tornado/escape.py
"""
- if isinstance(value, unicode):
+ if isinstance(value, six.text_type):
return value.encode('utf-8')
assert isinstance(value, str)
return value
@@ -600,7 +600,7 @@ def make_dev_path(dev, partition=None, base='/dev'):
def sanitize_hostname(hostname):
"""Return a hostname which conforms to RFC-952 and RFC-1123 specs."""
- if isinstance(hostname, unicode):
+ if isinstance(hostname, six.text_type):
hostname = hostname.encode('latin-1', 'ignore')
hostname = re.sub('[ _]', '-', hostname)
@@ -1076,7 +1076,7 @@ def get_system_metadata_from_image(image_meta, flavor=None):
prefix_format = SM_IMAGE_PROP_PREFIX + '%s'
for key, value in image_meta.get('properties', {}).iteritems():
- new_value = safe_truncate(unicode(value), 255)
+ new_value = safe_truncate(six.text_type(value), 255)
system_meta[prefix_format % key] = new_value
for key in SM_INHERITABLE_KEYS:
diff --git a/nova/virt/ironic/driver.py b/nova/virt/ironic/driver.py
index c50c1dc609..93a905fb22 100644
--- a/nova/virt/ironic/driver.py
+++ b/nova/virt/ironic/driver.py
@@ -977,7 +977,7 @@ class IronicDriver(virt_driver.ComputeDriver):
# not needed if no vif are defined
for vif, pif in zip(network_info, ports):
# attach what neutron needs directly to the port
- port_id = unicode(vif['id'])
+ port_id = six.text_type(vif['id'])
patch = [{'op': 'add',
'path': '/extra/vif_port_id',
'value': port_id}]