Remove six from storwize driver

Change-Id: I4fced65f362336aa035a7db9f1ad5514d9bb307d
This commit is contained in:
Eric Harney
2023-03-30 13:45:46 -04:00
parent b1d0be7b26
commit 592e31d232
3 changed files with 69 additions and 78 deletions

View File

@@ -28,7 +28,6 @@ from oslo_config import cfg
from oslo_service import loopingcall
from oslo_utils import units
import paramiko
import six
from cinder import context
import cinder.db
@@ -350,8 +349,8 @@ class StorwizeSVCManagementSimulator(object):
ids.sort()
for index, n in enumerate(ids):
if n > index:
return six.text_type(index)
return six.text_type(len(ids))
return str(index)
return str(len(ids))
# Check if name is valid
@staticmethod
@@ -516,7 +515,7 @@ class StorwizeSVCManagementSimulator(object):
num = num * 1024
unit_index += 1
return six.text_type(num)
return str(num)
def _cmd_lslicense(self, **kwargs):
rows = [None] * 3
@@ -569,7 +568,7 @@ class StorwizeSVCManagementSimulator(object):
for i in range(pool_num):
row_data = [str(i + 1),
self._flags['storwize_svc_volpool_name'][i], 'online',
'1', six.text_type(len(self._volumes_list)),
'1', str(len(self._volumes_list)),
'3573412790272', '256', '3529926246400',
'1693247906775',
'26843545600', '38203734097', '47', '80', 'auto',
@@ -801,13 +800,13 @@ port_speed!N/A
value1 = filter1.split('=')[1]
value2 = filter2.split('=')[1]
for v in ports:
if(six.text_type(v[5]) == value1 and six.text_type(
if(str(v[5]) == value1 and str(
v[7]) == value2):
rows.append(v)
else:
value = kwargs['filtervalue'].split('=')[1]
for v in ports:
if six.text_type(v[5]) == value:
if str(v[5]) == value:
rows.append(v)
else:
rows = ports
@@ -866,7 +865,7 @@ port_speed!N/A
value = kwargs['filtervalue'].split('=')[1]
for v in ports:
if six.text_type(v[5]) == value:
if str(v[5]) == value:
rows.append(v)
else:
rows = ports
@@ -1146,7 +1145,7 @@ port_speed!N/A
curr_size = int(self._volumes_list[vol_name]['capacity'])
addition = size * units.Gi
self._volumes_list[vol_name]['capacity'] = (
six.text_type(curr_size + addition))
str(curr_size + addition))
return ('', '')
def _get_fcmap_info(self, vol_name):
@@ -1182,7 +1181,7 @@ port_speed!N/A
cap = self._convert_bytes_units(vol['capacity'])
else:
cap = vol['capacity']
rows.append([six.text_type(vol['id']), vol['name'],
rows.append([str(vol['id']), vol['name'],
vol['IO_group_id'],
vol['IO_group_name'], 'online', '0',
_get_test_pool(),
@@ -1207,7 +1206,7 @@ port_speed!N/A
item = self._convert_bytes_units(item)
rows = []
rows.append(['id', six.text_type(vol['id'])])
rows.append(['id', str(vol['id'])])
rows.append(['name', vol['name']])
rows.append(['IO_group_id', vol['IO_group_id']])
rows.append(['IO_group_name', vol['IO_group_name']])
@@ -1306,7 +1305,7 @@ port_speed!N/A
if 'name' in kwargs:
host_name = kwargs['name'].strip('\'\"')
else:
host_name = 'host' + six.text_type(host_info['id'])
host_name = 'host' + str(host_info['id'])
if self._is_invalid_name(host_name):
return self._errors['CMMVC6527E']
@@ -1754,7 +1753,7 @@ port_speed!N/A
filter_value = kwargs['filtervalue'].split('=')[1]
to_delete = []
for k, v in self._fcmappings_list.items():
if six.text_type(v[filter_key]) == filter_value:
if str(v[filter_key]) == filter_value:
source = self._volumes_list[v['source']]
target = self._volumes_list[v['target']]
self._state_transition('wait', v)
@@ -1883,16 +1882,16 @@ port_speed!N/A
fcconsistgrp = self._fcconsistgrp_list[cg_id]
break
rows = []
rows.append(['id', six.text_type(cg_id)])
rows.append(['id', str(cg_id)])
rows.append(['name', fcconsistgrp['name']])
rows.append(['status', fcconsistgrp['status']])
rows.append(['autodelete',
six.text_type(fcconsistgrp['autodelete'])])
str(fcconsistgrp['autodelete'])])
rows.append(['start_time',
six.text_type(fcconsistgrp['start_time'])])
str(fcconsistgrp['start_time'])])
for fcmap_id in fcconsistgrp['fcmaps'].keys():
rows.append(['FC_mapping_id', six.text_type(fcmap_id)])
rows.append(['FC_mapping_id', str(fcmap_id)])
rows.append(['FC_mapping_name',
fcconsistgrp['fcmaps'][fcmap_id]])
@@ -2971,7 +2970,7 @@ port_speed!N/A
filter_key = kwargs['filtervalue'].split('=')[0]
filter_value = kwargs['filtervalue'].split('=')[1]
for k, v in self._partnership_list.items():
if six.text_type(v[filter_key]) == filter_value:
if str(v[filter_key]) == filter_value:
rows.append([v['id'], v['name'], v['location'],
v['partnership'], v['type'], v['cluster_ip'],
v['event_log_sequence']])
@@ -3451,9 +3450,9 @@ class StorwizeSVCISCSIDriverTestCase(test.TestCase):
'storwize_svc_allow_tenant_qos': True,
'storwize_preferred_host_site': self.host_site}
wwpns = [
six.text_type(random.randint(0, 9999999999999999)).zfill(16),
six.text_type(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % six.text_type(
str(random.randint(0, 9999999999999999)).zfill(16),
str(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % str(
random.randint(10000, 99999))
self._connector = {'ip': '1.234.56.78',
'host': 'storwize-svc-test',
@@ -3920,14 +3919,12 @@ class StorwizeSVCISCSIDriverTestCase(test.TestCase):
# Check the multipath host-volume map return value
# target_iqns and target_portals have no guaranteed order
six.assertCountEqual(self,
exp_m_path['data']['target_iqns'],
ret['data']['target_iqns'])
self.assertCountEqual(exp_m_path['data']['target_iqns'],
ret['data']['target_iqns'])
del exp_m_path['data']['target_iqns']
six.assertCountEqual(self,
exp_m_path['data']['target_portals'],
ret['data']['target_portals'])
self.assertCountEqual(exp_m_path['data']['target_portals'],
ret['data']['target_portals'])
del exp_m_path['data']['target_portals']
for k, v in exp_m_path['data'].items():
@@ -4007,8 +4004,8 @@ class StorwizeSVCISCSIDriverTestCase(test.TestCase):
for host_exists in ['yes-auth', 'yes-noauth', 'no']:
self._set_flag('storwize_svc_iscsi_chap_enabled',
auth_enabled)
case = 'en' + six.text_type(
auth_enabled) + 'ex' + six.text_type(host_exists)
case = 'en' + str(
auth_enabled) + 'ex' + str(host_exists)
conn_na = {'initiator': 'test:init:%s' %
random.randint(10000, 99999),
'ip': '11.11.11.11',
@@ -4123,10 +4120,9 @@ class StorwizeSVCISCSIDriverTestCase(test.TestCase):
types[protocol] = volume_types.create(ctxt, protocol, opts)
# Create a connector for the second 'host'
wwpns = [six.text_type(random.randint(0, 9999999999999999)).zfill(16),
six.text_type(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % six.text_type(random.randint(10000,
99999))
wwpns = [str(random.randint(0, 9999999999999999)).zfill(16),
str(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % str(random.randint(10000, 99999))
conn2 = {'ip': '1.234.56.79',
'host': 'storwize-svc-test2',
'wwpns': wwpns,
@@ -4178,9 +4174,9 @@ class StorwizeSVCFcDriverTestCase(test.TestCase):
'storwize_svc_multipath_enabled': False,
'storwize_svc_allow_tenant_qos': True}
wwpns = [
six.text_type(random.randint(0, 9999999999999999)).zfill(16),
six.text_type(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % six.text_type(
str(random.randint(0, 9999999999999999)).zfill(16),
str(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % str(
random.randint(10000, 99999))
self._connector = {'ip': '1.234.56.78',
'host': 'storwize-svc-test',
@@ -5011,10 +5007,9 @@ class StorwizeSVCFcDriverTestCase(test.TestCase):
types[protocol] = volume_types.create(ctxt, protocol, opts)
# Create a connector for the second 'host'
wwpns = [six.text_type(random.randint(0, 9999999999999999)).zfill(16),
six.text_type(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % six.text_type(random.randint(10000,
99999))
wwpns = [str(random.randint(0, 9999999999999999)).zfill(16),
str(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % str(random.randint(10000, 99999))
conn2 = {'ip': '1.234.56.79',
'host': 'storwize-svc-test2',
'wwpns': wwpns,
@@ -5076,9 +5071,9 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
self.fcdriver = StorwizeSVCFcFakeDriver(
configuration=config)
wwpns = [
six.text_type(random.randint(0, 9999999999999999)).zfill(16),
six.text_type(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % six.text_type(
str(random.randint(0, 9999999999999999)).zfill(16),
str(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % str(
random.randint(10000, 99999))
self._connector = {'ip': '1.234.56.78',
'host': 'storwize-svc-test',
@@ -11528,9 +11523,9 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
SVC_POOLS,
'replication_device': [self.rep_target]}
wwpns = [
six.text_type(random.randint(0, 9999999999999999)).zfill(16),
six.text_type(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % six.text_type(
str(random.randint(0, 9999999999999999)).zfill(16),
str(random.randint(0, 9999999999999999)).zfill(16)]
initiator = 'test.initiator.%s' % str(
random.randint(10000, 99999))
self._connector = {'ip': '1.234.56.78',
'host': 'storwize-svc-test',
@@ -11999,7 +11994,7 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
rep_type = self.driver._get_volume_replicated_type(
self.ctxt, volume)
src_opts = self.driver._get_vdisk_params(volume['volume_type_id'])
opt_cycle_period_seconds = six.text_type(
opt_cycle_period_seconds = str(
src_opts.get('cycle_period_seconds'))
self.assertEqual(opt_cycle_period_seconds, cycle_period_seconds)
self.assertEqual(storwize_const.GMCV_MULTI, cycling_mode)
@@ -12052,7 +12047,7 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
self.assertIsNotNone(rel_info)
src_opts = self.driver._get_vdisk_params(volume['volume_type_id'])
opt_cycle_period_seconds = six.text_type(
opt_cycle_period_seconds = str(
src_opts.get('cycle_period_seconds'))
self.assertEqual(opt_cycle_period_seconds,
rel_info['cycle_period_seconds'])

View File

@@ -20,7 +20,6 @@ from eventlet import greenthread
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import excutils
import six
from cinder import exception
from cinder.i18n import _
@@ -52,7 +51,7 @@ class StorwizeSVCReplication(object):
except Exception as e:
msg = (_('Unable to fail-over the volume %(id)s to the '
'secondary back-end, error: %(error)s') %
{"id": vref['id'], "error": six.text_type(e)})
{"id": vref['id'], "error": str(e)})
LOG.exception(msg)
raise exception.VolumeDriverException(message=msg)
@@ -68,7 +67,7 @@ class StorwizeSVCReplication(object):
except Exception as e:
msg = (_('Unable to fail-back the volume: %(vol)s to the '
'master back-end, error: %(error)s') %
{"vol": volume['name'], "error": six.text_type(e)})
{"vol": volume['name'], "error": str(e)})
LOG.exception(msg)
raise exception.VolumeDriverException(message=msg)
@@ -106,7 +105,7 @@ class StorwizeSVCReplicationGlobalMirror(StorwizeSVCReplication):
vref['name'])
opts['iogrp'] = src_attr['IO_group_id']
self.target_helpers.create_vdisk(target_vol_name,
six.text_type(vref['size']),
str(vref['size']),
'gb', pool, opts)
system_info = self.target_helpers.get_system_info()
@@ -184,7 +183,7 @@ class StorwizeSVCReplicationGMCV(StorwizeSVCReplicationGlobalMirror):
src_change_pool = src_child_pool
try:
self.driver._helpers.create_vdisk(source_change_vol_name,
six.text_type(vref['size']),
str(vref['size']),
'gb',
src_change_pool,
src_change_opts)
@@ -201,7 +200,7 @@ class StorwizeSVCReplicationGMCV(StorwizeSVCReplicationGlobalMirror):
target_opts['iogrp'] = src_attr['IO_group_id']
try:
self.target_helpers.create_vdisk(target_vol_name,
six.text_type(vref['size']),
str(vref['size']),
'gb',
target_pool,
target_opts)
@@ -228,7 +227,7 @@ class StorwizeSVCReplicationGMCV(StorwizeSVCReplicationGlobalMirror):
target_change_opts['autoexpand'] = True
try:
self.target_helpers.create_vdisk(target_change_vol_name,
six.text_type(vref['size']),
str(vref['size']),
'gb',
target_change_pool,
target_change_opts)
@@ -257,7 +256,7 @@ class StorwizeSVCReplicationGMCV(StorwizeSVCReplicationGlobalMirror):
except Exception as e:
msg = (_("Unable to set up gmcv mode replication for %(vol)s. "
"Exception: %(err)s.") % {'vol': vref['id'],
'err': six.text_type(e)})
'err': str(e)})
LOG.exception(msg)
raise exception.VolumeDriverException(message=msg)
LOG.debug('leave: volume_replication_setup:volume %s', vref['name'])
@@ -303,7 +302,7 @@ class StorwizeSVCReplicationManager(object):
return processutils.ssh_execute(
ssh, command, check_exit_code=check_exit_code)
except Exception as e:
LOG.error(six.text_type(e))
LOG.error(str(e))
last_exception = e
greenthread.sleep(random.randint(20, 500) / 100.0)
try:

View File

@@ -31,7 +31,6 @@ from oslo_utils import excutils
from oslo_utils import strutils
from oslo_utils import units
import paramiko
import six
from cinder import context
from cinder import exception
@@ -409,7 +408,7 @@ class StorwizeSSH(object):
if cycle_period_seconds:
ssh_cmd = ['svctask', 'chrcrelationship']
ssh_cmd.extend(['-cycleperiodseconds',
six.text_type(cycle_period_seconds)])
str(cycle_period_seconds)])
ssh_cmd.append(relationship)
self.run_ssh_assert_no_output(ssh_cmd)
@@ -501,16 +500,15 @@ class StorwizeSSH(object):
def mkippartnership(self, ip_v4, bandwidth=1000, backgroundcopyrate=50):
ssh_cmd = ['svctask', 'mkippartnership', '-type', 'ipv4',
'-clusterip', ip_v4, '-linkbandwidthmbits',
six.text_type(bandwidth),
'-backgroundcopyrate', six.text_type(backgroundcopyrate)]
'-clusterip', ip_v4, '-linkbandwidthmbits', str(bandwidth),
'-backgroundcopyrate', str(backgroundcopyrate)]
return self.run_ssh_assert_no_output(ssh_cmd)
def mkfcpartnership(self, system_name, bandwidth=1000,
backgroundcopyrate=50):
ssh_cmd = ['svctask', 'mkfcpartnership', '-linkbandwidthmbits',
six.text_type(bandwidth),
'-backgroundcopyrate', six.text_type(backgroundcopyrate),
str(bandwidth),
'-backgroundcopyrate', str(backgroundcopyrate),
system_name]
return self.run_ssh_assert_no_output(ssh_cmd)
@@ -650,7 +648,7 @@ class StorwizeSSH(object):
def mkvdisk(self, name, size, units, pool, opts, params):
ssh_cmd = ['svctask', 'mkvdisk', '-name', '"%s"' % name, '-mdiskgrp',
'"%s"' % pool, '-iogrp', six.text_type(opts['iogrp']),
'"%s"' % pool, '-iogrp', str(opts['iogrp']),
'-size', size, '-unit', units] + params
try:
return self.run_ssh_check_created(ssh_cmd)
@@ -721,7 +719,7 @@ class StorwizeSSH(object):
def expandvdisksize(self, vdisk, amount):
ssh_cmd = (
['svctask', 'expandvdisksize', '-size', six.text_type(amount),
['svctask', 'expandvdisksize', '-size', str(amount),
'-unit', 'gb', '"%s"' % vdisk])
self.run_ssh_assert_no_output(ssh_cmd)
@@ -732,7 +730,7 @@ class StorwizeSSH(object):
if not full_copy:
ssh_cmd.extend(['-copyrate', '0'])
else:
ssh_cmd.extend(['-copyrate', six.text_type(copy_rate)])
ssh_cmd.extend(['-copyrate', str(copy_rate)])
ssh_cmd.append('-autodelete')
if consistgrp:
ssh_cmd.extend(['-consistgrp', consistgrp])
@@ -1462,8 +1460,8 @@ class StorwizeHelpers(object):
# Before we start, make sure host name is a string and that we have at
# least one port.
host_name = connector['host']
if not isinstance(host_name, six.string_types):
msg = _('create_host: Host name is not unicode or string.')
if not isinstance(host_name, str):
msg = _('create_host: Host name is not a string.')
LOG.error(msg)
raise exception.VolumeDriverException(message=msg)
@@ -1484,7 +1482,7 @@ class StorwizeHelpers(object):
raise exception.VolumeDriverException(message=msg)
# Build a host name for the Storwize host - first clean up the name
if isinstance(host_name, six.text_type):
if isinstance(host_name, str):
host_name = unicodedata.normalize('NFKD', host_name).encode(
'ascii', 'replace').decode('ascii')
@@ -2060,7 +2058,7 @@ class StorwizeHelpers(object):
else:
params.extend(['-buffersize', '%s%%' % str(opts['rsize']),
'-warning',
'%s%%' % six.text_type(opts['warning'])])
'%s%%' % str(opts['warning'])])
if not opts['autoexpand']:
params.append('-noautoexpand')
if opts['compression']:
@@ -2068,7 +2066,7 @@ class StorwizeHelpers(object):
else:
params.append('-thin')
params.extend(['-grainsize',
six.text_type(opts['grainsize'])])
str(opts['grainsize'])])
return params
def create_hyperswap_volume(self, vol_name, size, units, pool, opts):
@@ -2080,8 +2078,7 @@ class StorwizeHelpers(object):
self.check_data_reduction_pool_params(opts)
params = self._get_hyperswap_volume_create_params(opts, is_dr_pool)
hyperpool = '%s:%s' % (pool, opts['peer_pool'])
self.ssh.mkvolume(vol_name, six.text_type(size), units,
hyperpool, params)
self.ssh.mkvolume(vol_name, str(size), units, hyperpool, params)
def convert_volume_to_hyperswap(self, vol_name, opts, state):
vol_name = '%s' % vol_name
@@ -2421,7 +2418,7 @@ class StorwizeHelpers(object):
# update flashcopy rate for clone volume
if copy_rate != '0' and attrs['rc_controlled'] != 'yes':
self.ssh.chfcmap(map_id,
copyrate=six.text_type(new_flashcopy_rate))
copyrate=str(new_flashcopy_rate))
def run_flashcopy(self, source, target, timeout, copy_rate,
clean_rate, full_copy=True, restore=False):
@@ -3312,7 +3309,7 @@ class CLIResponse(object):
vs = []
for k in keys:
v = a.get(k, None)
if isinstance(v, six.string_types) or v is None:
if isinstance(v, str) or v is None:
v = [v]
if isinstance(v, list):
vs.append(v)
@@ -3347,7 +3344,7 @@ class CLIResponse(object):
else:
yield []
if isinstance(self.raw, six.string_types):
if isinstance(self.raw, str):
stdout, stderr = self.raw, ''
else:
stdout, stderr = self.raw
@@ -5996,7 +5993,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
volume['volume_type_id'],
volume_metadata=volume.get('volume_metadata'))
# Check cycle_period_seconds
rep_cps = six.text_type(rep_opts.get('cycle_period_seconds'))
rep_cps = str(rep_opts.get('cycle_period_seconds'))
if rel_info['cycle_period_seconds'] != rep_cps:
msg = (_("Failed to manage existing volume due to "
"the cycle_period_seconds %(vol_cps)s of "