Merge "Remove six from STX drivers"

This commit is contained in:
Zuul
2024-06-11 06:20:02 +00:00
committed by Gerrit Code Review
2 changed files with 7 additions and 15 deletions

View File

@ -25,7 +25,6 @@ from oslo_log import log as logging
from oslo_utils import strutils
from oslo_utils import units
import requests
import six
from cinder import coordination
from cinder.i18n import _
@ -35,8 +34,7 @@ from cinder.volume import volume_utils
LOG = logging.getLogger(__name__)
@six.add_metaclass(volume_utils.TraceWrapperMetaclass)
class STXClient(object):
class STXClient(object, metaclass=volume_utils.TraceWrapperMetaclass):
def __init__(self, host, login, password, protocol, ssl_verify):
self._mgmt_ip_addrs = list(map(str.strip, host.split(',')))
self._login = login
@ -118,11 +116,9 @@ class STXClient(object):
# password. This should likely be replaced by a version that
# does not use md5 here.
self._session_key = None
hash_ = "%s_%s" % (self._login, self._password)
if six.PY3:
hash_ = hash_.encode('utf-8')
hash_ = hashlib.md5(hash_) # nosec
digest = hash_.hexdigest()
digest = hashlib.md5( # nosec
("%s_%s" % (self._login, self._password)).encode('utf-8')
).hexdigest()
url = self._base_url + "/login/" + digest
try:

View File

@ -21,7 +21,6 @@ import uuid
from oslo_config import cfg
from oslo_log import log as logging
import six
from cinder import exception
from cinder.i18n import _
@ -55,8 +54,7 @@ CONF.register_opts(common_opts, group=configuration.SHARED_CONF_GROUP)
CONF.register_opts(iscsi_opts, group=configuration.SHARED_CONF_GROUP)
@six.add_metaclass(volume_utils.TraceWrapperMetaclass)
class STXCommon(object):
class STXCommon(object, metaclass=volume_utils.TraceWrapperMetaclass):
VERSION = "2.0"
stats = {}
@ -95,7 +93,7 @@ class STXCommon(object):
msg = _("Failed to connect to %(vendor_name)s Array %(host)s: "
"%(err)s") % {'vendor_name': self.vendor_name,
'host': self.config.san_ip,
'err': six.text_type(ex)}
'err': str(ex)}
LOG.error(msg)
raise stx_exception.ConnectionError(message=msg)
except stx_exception.AuthenticationError:
@ -146,9 +144,7 @@ class STXCommon(object):
"""
uuid_str = name.replace("-", "")
vol_uuid = uuid.UUID('urn:uuid:%s' % uuid_str)
vol_encoded = base64.urlsafe_b64encode(vol_uuid.bytes)
if six.PY3:
vol_encoded = vol_encoded.decode('ascii')
vol_encoded = base64.urlsafe_b64encode(vol_uuid.bytes).decode('ascii')
return vol_encoded[:19]
def check_flags(self, options, required_flags):