Remove six from Nexenta drivers

Change-Id: I3290fd411da511f276d4f592820e9a88df958472
This commit is contained in:
Takashi Kajinami 2024-02-01 21:17:22 +09:00
parent 2a18843ab9
commit 337adf9a12
7 changed files with 19 additions and 26 deletions

View File

@ -18,11 +18,11 @@ import copy
import json import json
import posixpath import posixpath
from unittest import mock from unittest import mock
import urllib
import uuid import uuid
from oslo_utils.secretutils import md5 from oslo_utils.secretutils import md5
import requests import requests
import six
from cinder.tests.unit import test from cinder.tests.unit import test
from cinder.volume import configuration as conf from cinder.volume import configuration as conf
@ -808,7 +808,7 @@ class TestNefCollections(test.TestCase):
def test_path(self): def test_path(self):
path = 'path/to/item name + - & # $ = 0' path = 'path/to/item name + - & # $ = 0'
result = self.instance.path(path) 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) expected = posixpath.join(self.instance.root, quoted_path)
self.assertEqual(expected, result) self.assertEqual(expected, result)
@ -1184,9 +1184,7 @@ class TestNefProxy(test.TestCase):
settings = {'value': guid} settings = {'value': guid}
get_settings.return_value = settings get_settings.return_value = settings
self.assertIsNone(self.proxy.update_lock()) self.assertIsNone(self.proxy.update_lock())
path = '%s:%s' % (guid, self.proxy.path) path = ('%s:%s' % (guid, self.proxy.path)).encode('utf-8')
if isinstance(path, six.text_type):
path = path.encode('utf-8')
expected = md5(path, usedforsecurity=False).hexdigest() expected = md5(path, usedforsecurity=False).hexdigest()
self.assertEqual(expected, self.proxy.lock) self.assertEqual(expected, self.proxy.lock)

View File

@ -14,7 +14,6 @@
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
import six
from cinder.common import constants from cinder.common import constants
from cinder import exception from cinder import exception
@ -225,7 +224,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
self.nms.zvol.create( self.nms.zvol.create(
self._get_zvol_name(volume['name']), self._get_zvol_name(volume['name']),
'%sG' % (volume['size'],), '%sG' % (volume['size'],),
six.text_type(self.configuration.nexenta_blocksize), str(self.configuration.nexenta_blocksize),
self.configuration.nexenta_sparse) self.configuration.nexenta_sparse)
def extend_volume(self, volume, new_size): def extend_volume(self, volume, new_size):

View File

@ -21,7 +21,6 @@ from oslo_log import log as logging
from oslo_utils import fileutils from oslo_utils import fileutils
from oslo_utils.secretutils import md5 from oslo_utils.secretutils import md5
from oslo_utils import units from oslo_utils import units
import six
from cinder.common import constants from cinder.common import constants
from cinder import context from cinder import context
@ -715,7 +714,7 @@ class NexentaNfsDriver(nfs.NfsDriver):
'%(count)d attempts.', '%(count)d attempts.',
{'share': nfs_share, {'share': nfs_share,
'count': num_attempts}) 'count': num_attempts})
raise exception.NfsException(six.text_type(e)) raise exception.NfsException(str(e))
LOG.warning( LOG.warning(
'Mount attempt %(attempt)d failed: %(error)s. ' 'Mount attempt %(attempt)d failed: %(error)s. '
'Retrying mount ...', 'Retrying mount ...',

View File

@ -20,7 +20,6 @@ import uuid
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import units from oslo_utils import units
import six
from cinder.common import constants from cinder.common import constants
from cinder import context from cinder import context
@ -425,7 +424,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
host_addresses = [] host_addresses = []
items = self.nef.netaddrs.list() items = self.nef.netaddrs.list()
for item in items: for item in items:
ip_cidr = six.text_type(item['address']) ip_cidr = str(item['address'])
ip_addr, ip_mask = ip_cidr.split('/') ip_addr, ip_mask = ip_cidr.split('/')
ip_obj = ipaddress.ip_address(ip_addr) ip_obj = ipaddress.ip_address(ip_addr)
if not ip_obj.is_loopback: if not ip_obj.is_loopback:
@ -1012,7 +1011,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
:returns: return True, if database entry with specified :returns: return True, if database entry with specified
snapshot id exists, otherwise return False snapshot id exists, otherwise return False
""" """
if not isinstance(snapshot_id, six.string_types): if not isinstance(snapshot_id, str):
return False return False
try: try:
uuid.UUID(snapshot_id, version=4) uuid.UUID(snapshot_id, version=4)

View File

@ -15,12 +15,12 @@
import json import json
import posixpath import posixpath
import urllib
from eventlet import greenthread from eventlet import greenthread
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils.secretutils import md5 from oslo_utils.secretutils import md5
import requests import requests
import six
from cinder import exception from cinder import exception
from cinder.i18n import _ from cinder.i18n import _
@ -44,7 +44,7 @@ class NefException(exception.VolumeDriverException):
kwargs[key] = data[key] kwargs[key] = data[key]
else: else:
kwargs[key] = defaults[key] kwargs[key] = defaults[key]
elif isinstance(data, six.string_types): elif isinstance(data, str):
if 'message' not in kwargs: if 'message' not in kwargs:
kwargs['message'] = data kwargs['message'] = data
for key in defaults: for key in defaults:
@ -328,7 +328,7 @@ class NefCollections(object):
self.proxy = proxy self.proxy = proxy
def path(self, name): 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) return posixpath.join(self.root, quoted_name)
def get(self, name, payload=None): def get(self, name, payload=None):
@ -599,14 +599,14 @@ class NefProxy(object):
prop = self.settings.get('system.guid') prop = self.settings.get('system.guid')
guid = prop.get('value') guid = prop.get('value')
path = '%s:%s' % (guid, self.path) path = '%s:%s' % (guid, self.path)
if isinstance(path, six.text_type): if isinstance(path, str):
path = path.encode('utf-8') path = path.encode('utf-8')
self.lock = md5(path, usedforsecurity=False).hexdigest() self.lock = md5(path, usedforsecurity=False).hexdigest()
def url(self, path): def url(self, path):
netloc = '%s:%d' % (self.host, int(self.port)) netloc = '%s:%d' % (self.host, int(self.port))
components = (self.scheme, netloc, str(path), None, None) components = (self.scheme, netloc, str(path), None, None)
url = six.moves.urllib.parse.urlunsplit(components) url = urllib.parse.urlunsplit(components)
return url return url
def delay(self, attempt): def delay(self, attempt):

View File

@ -21,7 +21,6 @@ import uuid
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils.secretutils import md5 from oslo_utils.secretutils import md5
from oslo_utils import units from oslo_utils import units
import six
from cinder.common import constants from cinder.common import constants
from cinder import context from cinder import context
@ -769,7 +768,7 @@ class NexentaNfsDriver(nfs.NfsDriver):
:param volume: volume reference :param volume: volume reference
""" """
share = self._get_volume_share(volume) share = self._get_volume_share(volume)
if isinstance(share, six.text_type): if isinstance(share, str):
share = share.encode('utf-8') share = share.encode('utf-8')
path = md5(share, usedforsecurity=False).hexdigest() path = md5(share, usedforsecurity=False).hexdigest()
return os.path.join(self.mount_point_base, path) 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 :returns: return True, if database entry with specified
snapshot id exists, otherwise return False snapshot id exists, otherwise return False
""" """
if not isinstance(snapshot_id, six.string_types): if not isinstance(snapshot_id, str):
return False return False
try: try:
uuid.UUID(snapshot_id, version=4) uuid.UUID(snapshot_id, version=4)

View File

@ -14,10 +14,9 @@
# under the License. # under the License.
import re import re
from urllib import parse as urlparse
from oslo_utils import units from oslo_utils import units
import six
import six.moves.urllib.parse as urlparse
from cinder import exception from cinder import exception
from cinder.i18n import _ from cinder.i18n import _
@ -38,7 +37,7 @@ def str2size(s, scale=1024):
if not s: if not s:
return 0 return 0
if isinstance(s, six.integer_types): if isinstance(s, int):
return s return s
match = re.match(r'^([\.\d]+)\s*([BbKkMmGgTtPpEeZzYy]?)', 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.""" """Returns rrmgr command for source and destination."""
cmd = ['rrmgr', '-s', 'zfs'] cmd = ['rrmgr', '-s', 'zfs']
if compression: if compression:
cmd.extend(['-c', six.text_type(compression)]) cmd.extend(['-c', str(compression)])
cmd.append('-q') cmd.append('-q')
cmd.append('-e') cmd.append('-e')
if tcp_buf_size: if tcp_buf_size:
cmd.extend(['-w', six.text_type(tcp_buf_size)]) cmd.extend(['-w', str(tcp_buf_size)])
if connections: if connections:
cmd.extend(['-n', six.text_type(connections)]) cmd.extend(['-n', str(connections)])
cmd.extend([src, dst]) cmd.extend([src, dst])
return ' '.join(cmd) return ' '.join(cmd)