Merge "Remove six from Huawei drivers"
This commit is contained in:
commit
08adeda490
@ -22,7 +22,6 @@ from oslo_config import cfg
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
@ -291,7 +290,7 @@ class HuaweiBaseDriver(driver.VolumeDriver):
|
|||||||
smartcache.add(opts['cachename'], lun_id)
|
smartcache.add(opts['cachename'], lun_id)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._delete_lun_with_check(lun_id)
|
self._delete_lun_with_check(lun_id)
|
||||||
msg = _('Create volume error. Because %s.') % six.text_type(err)
|
msg = _('Create volume error. Because %s.') % str(err)
|
||||||
raise exception.VolumeBackendAPIException(data=msg)
|
raise exception.VolumeBackendAPIException(data=msg)
|
||||||
|
|
||||||
return lun_params, lun_info, model_update
|
return lun_params, lun_info, model_update
|
||||||
@ -567,7 +566,7 @@ class HuaweiBaseDriver(driver.VolumeDriver):
|
|||||||
pool_name = host['capabilities']['pool_name']
|
pool_name = host['capabilities']['pool_name']
|
||||||
pools = self.client.get_all_pools()
|
pools = self.client.get_all_pools()
|
||||||
pool_info = self.client.get_pool_info(pool_name, pools)
|
pool_info = self.client.get_pool_info(pool_name, pools)
|
||||||
dst_volume_name = six.text_type(uuid.uuid4())
|
dst_volume_name = str(uuid.uuid4())
|
||||||
|
|
||||||
lun_info = huawei_utils.get_lun_info(self.client, volume)
|
lun_info = huawei_utils.get_lun_info(self.client, volume)
|
||||||
if not lun_info:
|
if not lun_info:
|
||||||
@ -1617,7 +1616,7 @@ class HuaweiBaseDriver(driver.VolumeDriver):
|
|||||||
'id': src_vol.id,
|
'id': src_vol.id,
|
||||||
'provider_location': src_vol.provider_location,
|
'provider_location': src_vol.provider_location,
|
||||||
}
|
}
|
||||||
snapshot_kwargs = {'id': six.text_type(uuid.uuid4()),
|
snapshot_kwargs = {'id': str(uuid.uuid4()),
|
||||||
'volume': objects.Volume(**vol_kwargs),
|
'volume': objects.Volume(**vol_kwargs),
|
||||||
'volume_size': src_vol.size}
|
'volume_size': src_vol.size}
|
||||||
snapshot = objects.Snapshot(**snapshot_kwargs)
|
snapshot = objects.Snapshot(**snapshot_kwargs)
|
||||||
|
@ -25,7 +25,6 @@ import re
|
|||||||
|
|
||||||
from lxml import etree as ET
|
from lxml import etree as ET
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
@ -85,17 +84,20 @@ class HuaweiConf(object):
|
|||||||
|
|
||||||
need_encode = False
|
need_encode = False
|
||||||
if name_node is not None and not name_node.text.startswith('!$$$'):
|
if name_node is not None and not name_node.text.startswith('!$$$'):
|
||||||
encoded = base64.b64encode(six.b(name_node.text)).decode()
|
encoded = base64.b64encode(
|
||||||
|
name_node.text.encode('latin-1')).decode()
|
||||||
name_node.text = '!$$$' + encoded
|
name_node.text = '!$$$' + encoded
|
||||||
need_encode = True
|
need_encode = True
|
||||||
|
|
||||||
if pwd_node is not None and not pwd_node.text.startswith('!$$$'):
|
if pwd_node is not None and not pwd_node.text.startswith('!$$$'):
|
||||||
encoded = base64.b64encode(six.b(pwd_node.text)).decode()
|
encoded = base64.b64encode(
|
||||||
|
pwd_node.text.encode('latin-1')).decode()
|
||||||
pwd_node.text = '!$$$' + encoded
|
pwd_node.text = '!$$$' + encoded
|
||||||
need_encode = True
|
need_encode = True
|
||||||
|
|
||||||
if vstore_node is not None and not vstore_node.text.startswith('!$$$'):
|
if vstore_node is not None and not vstore_node.text.startswith('!$$$'):
|
||||||
encoded = base64.b64encode(six.b(vstore_node.text)).decode()
|
encoded = base64.b64encode(
|
||||||
|
vstore_node.text.encode('latin-1')).decode()
|
||||||
vstore_node.text = '!$$$' + encoded
|
vstore_node.text = '!$$$' + encoded
|
||||||
need_encode = True
|
need_encode = True
|
||||||
|
|
||||||
@ -119,7 +121,7 @@ class HuaweiConf(object):
|
|||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.InvalidInput(reason=msg)
|
raise exception.InvalidInput(reason=msg)
|
||||||
|
|
||||||
user = base64.b64decode(six.b(text[4:])).decode()
|
user = base64.b64decode(text[4:].encode('latin-1')).decode()
|
||||||
setattr(self.conf, 'san_user', user)
|
setattr(self.conf, 'san_user', user)
|
||||||
|
|
||||||
def _san_password(self, xml_root):
|
def _san_password(self, xml_root):
|
||||||
@ -129,14 +131,14 @@ class HuaweiConf(object):
|
|||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.InvalidInput(reason=msg)
|
raise exception.InvalidInput(reason=msg)
|
||||||
|
|
||||||
pwd = base64.b64decode(six.b(text[4:])).decode()
|
pwd = base64.b64decode(text[4:].encode('latin-1')).decode()
|
||||||
setattr(self.conf, 'san_password', pwd)
|
setattr(self.conf, 'san_password', pwd)
|
||||||
|
|
||||||
def _san_vstore(self, xml_root):
|
def _san_vstore(self, xml_root):
|
||||||
vstore = None
|
vstore = None
|
||||||
text = xml_root.findtext('Storage/vStoreName')
|
text = xml_root.findtext('Storage/vStoreName')
|
||||||
if text:
|
if text:
|
||||||
vstore = base64.b64decode(six.b(text[4:])).decode()
|
vstore = base64.b64decode(text[4:].encode('latin-1')).decode()
|
||||||
setattr(self.conf, 'vstore_name', vstore)
|
setattr(self.conf, 'vstore_name', vstore)
|
||||||
|
|
||||||
def _ssl_cert_path(self, xml_root):
|
def _ssl_cert_path(self, xml_root):
|
||||||
|
@ -19,7 +19,6 @@ import math
|
|||||||
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 strutils
|
from oslo_utils import strutils
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
@ -45,7 +44,7 @@ def encode_name(name):
|
|||||||
|
|
||||||
def old_encode_name(name):
|
def old_encode_name(name):
|
||||||
pre_name = name.split("-")[0]
|
pre_name = name.split("-")[0]
|
||||||
vol_encoded = six.text_type(hash(name))
|
vol_encoded = str(hash(name))
|
||||||
if vol_encoded.startswith('-'):
|
if vol_encoded.startswith('-'):
|
||||||
newuuid = pre_name + vol_encoded
|
newuuid = pre_name + vol_encoded
|
||||||
else:
|
else:
|
||||||
@ -63,7 +62,7 @@ def encode_host_name(name):
|
|||||||
|
|
||||||
def old_encode_host_name(name):
|
def old_encode_host_name(name):
|
||||||
if name and len(name) > constants.MAX_NAME_LENGTH:
|
if name and len(name) > constants.MAX_NAME_LENGTH:
|
||||||
name = six.text_type(hash(name))
|
name = str(hash(name))
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
@ -201,7 +200,7 @@ def _get_opts_from_specs(specs):
|
|||||||
opt_key = _get_opt_key(spec_key)
|
opt_key = _get_opt_key(spec_key)
|
||||||
opts[opt_key] = opts_capability[spec_key][1]
|
opts[opt_key] = opts_capability[spec_key][1]
|
||||||
|
|
||||||
for key, value in six.iteritems(specs):
|
for key, value in specs.items():
|
||||||
if key not in opts_capability:
|
if key not in opts_capability:
|
||||||
continue
|
continue
|
||||||
func = opts_capability[key][0]
|
func = opts_capability[key][0]
|
||||||
@ -337,7 +336,7 @@ def get_volume_private_data(volume):
|
|||||||
return info
|
return info
|
||||||
|
|
||||||
# To keep compatible with old driver version
|
# To keep compatible with old driver version
|
||||||
return {'huawei_lun_id': six.text_type(info),
|
return {'huawei_lun_id': str(info),
|
||||||
'huawei_lun_wwn': volume.admin_metadata.get('huawei_lun_wwn'),
|
'huawei_lun_wwn': volume.admin_metadata.get('huawei_lun_wwn'),
|
||||||
'huawei_sn': volume.metadata.get('huawei_sn'),
|
'huawei_sn': volume.metadata.get('huawei_sn'),
|
||||||
'hypermetro_id': volume.metadata.get('hypermetro_id'),
|
'hypermetro_id': volume.metadata.get('hypermetro_id'),
|
||||||
@ -370,7 +369,7 @@ def get_snapshot_private_data(snapshot):
|
|||||||
return info
|
return info
|
||||||
|
|
||||||
# To keep compatible with old driver version
|
# To keep compatible with old driver version
|
||||||
return {'huawei_snapshot_id': six.text_type(info),
|
return {'huawei_snapshot_id': str(info),
|
||||||
'huawei_snapshot_wwn': snapshot.metadata.get(
|
'huawei_snapshot_wwn': snapshot.metadata.get(
|
||||||
'huawei_snapshot_wwn'),
|
'huawei_snapshot_wwn'),
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import time
|
|||||||
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 requests
|
import requests
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
@ -95,7 +94,7 @@ class RestClient(object):
|
|||||||
res.raise_for_status()
|
res.raise_for_status()
|
||||||
except requests.HTTPError as exc:
|
except requests.HTTPError as exc:
|
||||||
return {"error": {"code": exc.response.status_code,
|
return {"error": {"code": exc.response.status_code,
|
||||||
"description": six.text_type(exc)}}
|
"description": str(exc)}}
|
||||||
|
|
||||||
res_json = res.json()
|
res_json = res.json()
|
||||||
if not log_filter_flag:
|
if not log_filter_flag:
|
||||||
@ -1988,9 +1987,9 @@ class RestClient(object):
|
|||||||
|
|
||||||
def change_hostlun_id(self, map_info, hostlun_id):
|
def change_hostlun_id(self, map_info, hostlun_id):
|
||||||
url = "/mappingview"
|
url = "/mappingview"
|
||||||
view_id = six.text_type(map_info['view_id'])
|
view_id = str(map_info['view_id'])
|
||||||
lun_id = six.text_type(map_info['lun_id'])
|
lun_id = str(map_info['lun_id'])
|
||||||
hostlun_id = six.text_type(hostlun_id)
|
hostlun_id = str(hostlun_id)
|
||||||
data = {"TYPE": 245,
|
data = {"TYPE": 245,
|
||||||
"ID": view_id,
|
"ID": view_id,
|
||||||
"ASSOCIATEOBJTYPE": 11,
|
"ASSOCIATEOBJTYPE": 11,
|
||||||
|
Loading…
Reference in New Issue
Block a user