diff --git a/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_jsonrpc.py b/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_jsonrpc.py index 6c455bb8d05..07b46e5d9ab 100644 --- a/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_jsonrpc.py +++ b/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_jsonrpc.py @@ -18,11 +18,11 @@ import copy import json import posixpath from unittest import mock +import urllib import uuid from oslo_utils.secretutils import md5 import requests -import six from cinder.tests.unit import test from cinder.volume import configuration as conf @@ -808,7 +808,7 @@ class TestNefCollections(test.TestCase): def test_path(self): path = 'path/to/item name + - & # $ = 0' result = self.instance.path(path) - quoted_path = six.moves.urllib.parse.quote_plus(path) + quoted_path = urllib.parse.quote_plus(path) expected = posixpath.join(self.instance.root, quoted_path) self.assertEqual(expected, result) @@ -1184,9 +1184,7 @@ class TestNefProxy(test.TestCase): settings = {'value': guid} get_settings.return_value = settings self.assertIsNone(self.proxy.update_lock()) - path = '%s:%s' % (guid, self.proxy.path) - if isinstance(path, six.text_type): - path = path.encode('utf-8') + path = ('%s:%s' % (guid, self.proxy.path)).encode('utf-8') expected = md5(path, usedforsecurity=False).hexdigest() self.assertEqual(expected, self.proxy.lock) diff --git a/cinder/volume/drivers/nexenta/iscsi.py b/cinder/volume/drivers/nexenta/iscsi.py index 70e7ee5a679..19608e37b50 100644 --- a/cinder/volume/drivers/nexenta/iscsi.py +++ b/cinder/volume/drivers/nexenta/iscsi.py @@ -14,7 +14,6 @@ from oslo_log import log as logging from oslo_utils import excutils -import six from cinder.common import constants from cinder import exception @@ -225,7 +224,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver): self.nms.zvol.create( self._get_zvol_name(volume['name']), '%sG' % (volume['size'],), - six.text_type(self.configuration.nexenta_blocksize), + str(self.configuration.nexenta_blocksize), self.configuration.nexenta_sparse) def extend_volume(self, volume, new_size): diff --git a/cinder/volume/drivers/nexenta/nfs.py b/cinder/volume/drivers/nexenta/nfs.py index bd350f768d4..c0f25cd6932 100644 --- a/cinder/volume/drivers/nexenta/nfs.py +++ b/cinder/volume/drivers/nexenta/nfs.py @@ -21,7 +21,6 @@ from oslo_log import log as logging from oslo_utils import fileutils from oslo_utils.secretutils import md5 from oslo_utils import units -import six from cinder.common import constants from cinder import context @@ -715,7 +714,7 @@ class NexentaNfsDriver(nfs.NfsDriver): '%(count)d attempts.', {'share': nfs_share, 'count': num_attempts}) - raise exception.NfsException(six.text_type(e)) + raise exception.NfsException(str(e)) LOG.warning( 'Mount attempt %(attempt)d failed: %(error)s. ' 'Retrying mount ...', diff --git a/cinder/volume/drivers/nexenta/ns5/iscsi.py b/cinder/volume/drivers/nexenta/ns5/iscsi.py index 7b67aeb9dd1..8833407a5c9 100644 --- a/cinder/volume/drivers/nexenta/ns5/iscsi.py +++ b/cinder/volume/drivers/nexenta/ns5/iscsi.py @@ -20,7 +20,6 @@ import uuid from oslo_log import log as logging from oslo_utils import units -import six from cinder.common import constants from cinder import context @@ -425,7 +424,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver): host_addresses = [] items = self.nef.netaddrs.list() for item in items: - ip_cidr = six.text_type(item['address']) + ip_cidr = str(item['address']) ip_addr, ip_mask = ip_cidr.split('/') ip_obj = ipaddress.ip_address(ip_addr) if not ip_obj.is_loopback: @@ -1012,7 +1011,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver): :returns: return True, if database entry with specified snapshot id exists, otherwise return False """ - if not isinstance(snapshot_id, six.string_types): + if not isinstance(snapshot_id, str): return False try: uuid.UUID(snapshot_id, version=4) diff --git a/cinder/volume/drivers/nexenta/ns5/jsonrpc.py b/cinder/volume/drivers/nexenta/ns5/jsonrpc.py index 471436f8694..2e2443ca797 100644 --- a/cinder/volume/drivers/nexenta/ns5/jsonrpc.py +++ b/cinder/volume/drivers/nexenta/ns5/jsonrpc.py @@ -15,12 +15,12 @@ import json import posixpath +import urllib from eventlet import greenthread from oslo_log import log as logging from oslo_utils.secretutils import md5 import requests -import six from cinder import exception from cinder.i18n import _ @@ -44,7 +44,7 @@ class NefException(exception.VolumeDriverException): kwargs[key] = data[key] else: kwargs[key] = defaults[key] - elif isinstance(data, six.string_types): + elif isinstance(data, str): if 'message' not in kwargs: kwargs['message'] = data for key in defaults: @@ -328,7 +328,7 @@ class NefCollections(object): self.proxy = proxy def path(self, name): - quoted_name = six.moves.urllib.parse.quote_plus(name) + quoted_name = urllib.parse.quote_plus(name) return posixpath.join(self.root, quoted_name) def get(self, name, payload=None): @@ -599,14 +599,14 @@ class NefProxy(object): prop = self.settings.get('system.guid') guid = prop.get('value') path = '%s:%s' % (guid, self.path) - if isinstance(path, six.text_type): + if isinstance(path, str): path = path.encode('utf-8') self.lock = md5(path, usedforsecurity=False).hexdigest() def url(self, path): netloc = '%s:%d' % (self.host, int(self.port)) components = (self.scheme, netloc, str(path), None, None) - url = six.moves.urllib.parse.urlunsplit(components) + url = urllib.parse.urlunsplit(components) return url def delay(self, attempt): diff --git a/cinder/volume/drivers/nexenta/ns5/nfs.py b/cinder/volume/drivers/nexenta/ns5/nfs.py index 8573fc42e17..f8ad6d6081b 100644 --- a/cinder/volume/drivers/nexenta/ns5/nfs.py +++ b/cinder/volume/drivers/nexenta/ns5/nfs.py @@ -21,7 +21,6 @@ import uuid from oslo_log import log as logging from oslo_utils.secretutils import md5 from oslo_utils import units -import six from cinder.common import constants from cinder import context @@ -769,7 +768,7 @@ class NexentaNfsDriver(nfs.NfsDriver): :param volume: volume reference """ share = self._get_volume_share(volume) - if isinstance(share, six.text_type): + if isinstance(share, str): share = share.encode('utf-8') path = md5(share, usedforsecurity=False).hexdigest() return os.path.join(self.mount_point_base, path) @@ -913,7 +912,7 @@ class NexentaNfsDriver(nfs.NfsDriver): :returns: return True, if database entry with specified snapshot id exists, otherwise return False """ - if not isinstance(snapshot_id, six.string_types): + if not isinstance(snapshot_id, str): return False try: uuid.UUID(snapshot_id, version=4) diff --git a/cinder/volume/drivers/nexenta/utils.py b/cinder/volume/drivers/nexenta/utils.py index 8f5a0adc34a..74b0755c94d 100644 --- a/cinder/volume/drivers/nexenta/utils.py +++ b/cinder/volume/drivers/nexenta/utils.py @@ -14,10 +14,9 @@ # under the License. import re +from urllib import parse as urlparse from oslo_utils import units -import six -import six.moves.urllib.parse as urlparse from cinder import exception from cinder.i18n import _ @@ -38,7 +37,7 @@ def str2size(s, scale=1024): if not s: return 0 - if isinstance(s, six.integer_types): + if isinstance(s, int): return s match = re.match(r'^([\.\d]+)\s*([BbKkMmGgTtPpEeZzYy]?)', s) @@ -67,13 +66,13 @@ def get_rrmgr_cmd(src, dst, compression=None, tcp_buf_size=None, """Returns rrmgr command for source and destination.""" cmd = ['rrmgr', '-s', 'zfs'] if compression: - cmd.extend(['-c', six.text_type(compression)]) + cmd.extend(['-c', str(compression)]) cmd.append('-q') cmd.append('-e') if tcp_buf_size: - cmd.extend(['-w', six.text_type(tcp_buf_size)]) + cmd.extend(['-w', str(tcp_buf_size)]) if connections: - cmd.extend(['-n', six.text_type(connections)]) + cmd.extend(['-n', str(connections)]) cmd.extend([src, dst]) return ' '.join(cmd)