Remove six from Inspur driver

Change-Id: I9e653ae7534bf4b9f7974ac6ff70e59aeb458b29
This commit is contained in:
Takashi Kajinami 2024-02-01 21:12:31 +09:00
parent 2a18843ab9
commit 2fee3be3b4
4 changed files with 34 additions and 39 deletions

View File

@ -19,7 +19,6 @@ import re
from oslo_concurrency import processutils
from oslo_utils import units
import six
from cinder import exception
from cinder import utils
@ -277,8 +276,8 @@ class FakeInStorage(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
@ -426,7 +425,7 @@ class FakeInStorage(object):
num = num * 1024
unit_index += 1
return six.text_type(num)
return str(num)
def _cmd_lslicense(self, **kwargs):
rows = [None] * 3
@ -476,7 +475,7 @@ class FakeInStorage(object):
for i in range(pool_num):
row_data = [str(i + 1),
self._flags['instorage_mcs_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',
@ -774,7 +773,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(),
@ -799,7 +798,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']])
@ -1018,7 +1017,7 @@ port_speed!N/A
filter_value = kwargs['filtervalue'].split('=')[1]
to_delete = []
for k, v in self._lcmappings_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)
@ -1065,16 +1064,16 @@ port_speed!N/A
if self._lcconsistgrp_list[cg_id]['name'] == kwargs['obj']:
lcconsistgrp = self._lcconsistgrp_list[cg_id]
rows = []
rows.append(['id', six.text_type(cg_id)])
rows.append(['id', str(cg_id)])
rows.append(['name', lcconsistgrp['name']])
rows.append(['status', lcconsistgrp['status']])
rows.append(['autodelete',
six.text_type(lcconsistgrp['autodelete'])])
str(lcconsistgrp['autodelete'])])
rows.append(['start_time',
six.text_type(lcconsistgrp['start_time'])])
str(lcconsistgrp['start_time'])])
for lcmap_id in lcconsistgrp['lcmaps'].keys():
rows.append(['FC_mapping_id', six.text_type(lcmap_id)])
rows.append(['FC_mapping_id', str(lcmap_id)])
rows.append(['FC_mapping_name',
lcconsistgrp['lcmaps'][lcmap_id]])
@ -1170,7 +1169,7 @@ port_speed!N/A
filter_key = kwargs['filtervalue'].split('=')[0]
filter_value = kwargs['filtervalue'].split('=')[1]
for k, v in self._rcrelationship_list.items():
if six.text_type(v[filter_key]) == filter_value:
if str(v[filter_key]) == filter_value:
self._rc_state_transition('wait', v)
if self._next_cmd_error['lsrcrelationship'] == 'speed_up':
@ -1232,7 +1231,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']])
@ -1377,7 +1376,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 _add_port_to_host(self, host_info, **kwargs):
@ -1408,7 +1407,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']

View File

@ -18,7 +18,6 @@
from unittest import mock
from eventlet import greenthread
import six
from cinder import context
import cinder.db
@ -327,7 +326,7 @@ class InStorageMCSISCSIDriverTestCase(test.TestCase):
for k, v in exp_m_path['data'].items():
if k in ('target_iqns', 'target_portals'):
# These are randomly ordered lists
six.assertCountEqual(self, v, ret['data'][k])
self.assertCountEqual(v, ret['data'][k])
else:
self.assertEqual(v, ret['data'][k])
@ -403,8 +402,7 @@ class InStorageMCSISCSIDriverTestCase(test.TestCase):
for host_exists in ['yes-auth', 'yes-noauth', 'no']:
self._set_flag('instorage_mcs_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' % 56789,
'ip': '11.11.11.11',
'host': 'host-%s' % case}

View File

@ -30,7 +30,6 @@ from oslo_utils import excutils
from oslo_utils import strutils
from oslo_utils import units
import paramiko
import six
from cinder.common import constants
from cinder import context
@ -420,7 +419,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
pool = volume_utils.extract_host(volume.host, 'pool')
opts['iogrp'] = self._assistant.select_io_group(self._state, opts)
self._assistant.create_vdisk(volume.name, six.text_type(volume.size),
self._assistant.create_vdisk(volume.name, str(volume.size),
'gb', pool, opts)
if opts['qos']:
self._assistant.add_vdisk_qos(volume.name, opts['qos'])
@ -563,7 +562,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
msg = (_('Failed to extend a volume with remote copy '
'%(volume)s. Exception: '
'%(err)s.') % {'volume': volume.id,
'err': six.text_type(e)})
'err': str(e)})
LOG.error(msg)
raise exception.VolumeDriverException(message=msg)
else:
@ -2010,7 +2009,7 @@ class InStorageAssistant(object):
# Before we start, make sure host name is a string and that we have
# one port at least .
host_name = connector['host']
if not isinstance(host_name, six.string_types):
if not isinstance(host_name, str):
msg = _('create_host: Host name is not unicode or string.')
LOG.error(msg)
raise exception.VolumeDriverException(message=msg)
@ -2027,7 +2026,7 @@ class InStorageAssistant(object):
raise exception.VolumeDriverException(message=msg)
# Build a host name for the InStorage 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')
@ -2884,7 +2883,7 @@ class InStorageAssistant(object):
# CMMVC5959E is the code in InStorage, meaning that
# there is a relationship that already has this name on the
# master cluster.
if 'CMMVC5959E' not in six.text_type(e):
if 'CMMVC5959E' not in str(e):
# If there is no relation between the primary and the
# secondary back-end storage, the exception is raised.
raise
@ -3335,15 +3334,15 @@ class InStorageSSH(object):
def mkippartnership(self, ip_v4, bandwidth=1000, backgroundcopyrate=50):
ssh_cmd = ['mcsop', 'mkippartnership', '-type', 'ipv4',
'-clusterip', ip_v4, '-linkbandwidthmbits',
six.text_type(bandwidth),
'-backgroundcopyrate', six.text_type(backgroundcopyrate)]
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 = ['mcsop', '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)
@ -3371,7 +3370,7 @@ class InStorageSSH(object):
def mkvdisk(self, name, size, units, pool, opts, params):
ssh_cmd = ['mcsop', 'mkvdisk', '-name', 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)
@ -3404,7 +3403,7 @@ class InStorageSSH(object):
def expandvdisksize(self, vdisk, amount):
ssh_cmd = (
['mcsop', 'expandvdisksize', '-size', six.text_type(amount),
['mcsop', 'expandvdisksize', '-size', str(amount),
'-unit', 'gb', '"%s"' % vdisk])
self.run_ssh_assert_no_output(ssh_cmd)
@ -3414,7 +3413,7 @@ class InStorageSSH(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)])
if consistgrp:
ssh_cmd.extend(['-consistgrp', consistgrp])
out, err = self._ssh(ssh_cmd, check_exit_code=False)
@ -3518,7 +3517,7 @@ class CLIParser(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)
@ -3553,7 +3552,7 @@ class CLIParser(object):
else:
yield []
if isinstance(self.raw, six.string_types):
if isinstance(self.raw, str):
stdout, stderr = self.raw, ''
else:
stdout, stderr = self.raw

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 _
@ -155,7 +154,7 @@ class InStorageMCSReplication(object):
vref.name)
opts['iogrp'] = src_attr['IO_group_id']
self.target_assistant.create_vdisk(target_vol_name,
six.text_type(vref['size']),
str(vref['size']),
'gb', pool, opts)
system_info = self.target_assistant.get_system_info()
@ -191,7 +190,7 @@ class InStorageMCSReplication(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.error(msg)
raise exception.VolumeDriverException(message=msg)
@ -207,7 +206,7 @@ class InStorageMCSReplication(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.error(msg)
raise exception.VolumeDriverException(message=msg)