foundStorageGroupInstanceName)
emcFastSetting = self.utils._get_fast_settings_from_storage_group(
storageGroupInstance)
- targetCombination = targetSlo + '+' + targetWorkload
+ targetCombination = ("%(targetSlo)s+%(targetWorkload)s"
+ % {'targetSlo': targetSlo,
+ 'targetWorkload': targetWorkload})
if targetCombination in emcFastSetting:
LOG.error(_LE(
"No action required. Volume: %(volumeName)s is "
configurationFile = self.configuration.cinder_emc_config_file
else:
configurationFile = (
- CINDER_EMC_CONFIG_FILE_PREFIX + configGroupName +
- CINDER_EMC_CONFIG_FILE_POSTFIX)
+ ("%(prefix)s%(configGroupName)s%(postfix)s"
+ % {'prefix': CINDER_EMC_CONFIG_FILE_PREFIX,
+ 'configGroupName': configGroupName,
+ 'postfix': CINDER_EMC_CONFIG_FILE_POSTFIX}))
# The file saved in self.configuration may not be the correct one,
# double check.
if configGroupName not in configurationFile:
configurationFile = (
- CINDER_EMC_CONFIG_FILE_PREFIX + configGroupName +
- CINDER_EMC_CONFIG_FILE_POSTFIX)
+ ("%(prefix)s%(configGroupName)s%(postfix)s"
+ % {'prefix': CINDER_EMC_CONFIG_FILE_PREFIX,
+ 'configGroupName': configGroupName,
+ 'postfix': CINDER_EMC_CONFIG_FILE_POSTFIX}))
self._set_ecom_credentials(configurationFile)
return configurationFile
self.user, self.passwd = self.utils.get_ecom_cred(configurationFile)
self.ecomUseSSL, self.ecomCACert, self.ecomNoVerification = (
self.utils.get_ecom_cred_SSL(configurationFile))
+ ip_port = ("%(ip)s:%(port)s"
+ % {'ip': ip,
+ 'port': port})
if self.ecomUseSSL:
- self.url = 'https://' + ip + ':' + port
+ self.url = ("https://%(ip_port)s"
+ % {'ip_port': ip_port})
else:
- self.url = 'http://' + ip + ':' + port
+ self.url = ("http://%(ip_port)s"
+ % {'ip_port': ip_port})
self.conn = self._get_ecom_connection()
def _initial_setup(self, volume, volumeTypeId=None):
maskingViewDict['slo'] = slo
maskingViewDict['workload'] = workload
maskingViewDict['pool'] = poolName
- maskingViewDict['sgGroupName'] = (
- 'OS-' + shortHostName + '-' + poolName + '-' + slo + '-' +
- workload + '-SG')
- maskingViewDict['maskingViewName'] = (
- 'OS-' + shortHostName + '-' + poolName + '-' + slo + '-' +
- workload + '-MV')
+ prefix = (
+ ("OS-%(shortHostName)s-%(poolName)s-%(slo)s-%(workload)s"
+ % {'shortHostName': shortHostName,
+ 'poolName': poolName,
+ 'slo': slo,
+ 'workload': workload}))
else:
- maskingViewDict['sgGroupName'] = (
- 'OS-' + shortHostName + '-' + poolName + '-' +
- protocol + '-SG')
- maskingViewDict['maskingViewName'] = (
- 'OS-' + shortHostName + '-' + poolName + '-' +
- protocol + '-MV')
+ prefix = (
+ ("OS-%(shortHostName)s-%(poolName)s-%(protocol)s"
+ % {'shortHostName': shortHostName,
+ 'poolName': poolName,
+ 'protocol': protocol}))
maskingViewDict['fastPolicy'] = (
self.utils.parse_fast_policy_name_from_file(
self.configuration.cinder_emc_config_file))
+ maskingViewDict['sgGroupName'] = ("%(prefix)s-SG"
+ % {'prefix': prefix})
+
+ maskingViewDict['maskingViewName'] = ("%(prefix)s-MV"
+ % {'prefix': prefix})
volumeName = volume['name']
volumeInstance = self._find_lun(volume)
storageSystemName = volumeInstance['SystemName']
self.configuration.cinder_emc_config_file))
maskingViewDict['igGroupName'] = (
- 'OS-' + shortHostName + '-' + protocol + '-IG')
+ ("OS-%(shortHostName)s-%(protocol)s-IG"
+ % {'shortHostName': shortHostName,
+ 'protocol': protocol}))
maskingViewDict['connector'] = connector
maskingViewDict['volumeInstance'] = volumeInstance
maskingViewDict['volumeName'] = volumeName
"Replication Service: %(service)s Operation: 8 "
"Synchronization: %(syncName)s.",
{'snapshot': snapshotname,
- 'service': str(repservice),
- 'syncName': str(syncName)})
+ 'service': repservice,
+ 'syncName': syncName})
self.provision.delete_clone_relationship(
self.conn, repservice, syncName, self.extraSpecs, True)
LOG.info(_LI("Target wwns in masking view %(maskingView)s: "
"%(targetWwns)s."),
{'maskingView': mvInstanceName,
- 'targetWwns': str(targetWwns)})
+ 'targetWwns': six.text_type(targetWwns)})
return targetWwns
def get_port_group_from_masking_view(self, maskingViewInstanceName):
assocStorageGroupInstanceName = (
self.utils.get_storage_group_from_volume(conn, volumeInstanceName))
- defaultSgGroupName = (DEFAULT_SG_PREFIX + fastPolicyName +
- DEFAULT_SG_POSTFIX)
+ defaultSgName = self._format_default_sg_string(fastPolicyName)
defaultStorageGroupInstanceName = (
self.utils.find_storage_masking_group(conn,
controllerConfigService,
- defaultSgGroupName))
+ defaultSgName))
if defaultStorageGroupInstanceName is None:
LOG.error(_LE(
"Unable to find default storage group "
"Volume: %(volumeName)s Does not belong "
"to storage storage group %(defaultSgGroupName)s."),
{'volumeName': volumeName,
- 'defaultSgGroupName': defaultSgGroupName})
+ 'defaultSgGroupName': defaultSgName})
return foundDefaultStorageGroupInstanceName
+ def _format_default_sg_string(self, fastPolicyName):
+ """Format the default storage group name
+
+ :param fastPolicyName: the fast policy name
+ :returns: defaultSgName
+ """
+ return ("%(prefix)s%(fastPolicyName)s%(postfix)s"
+ % {'prefix': DEFAULT_SG_PREFIX,
+ 'fastPolicyName': fastPolicyName,
+ 'postfix': DEFAULT_SG_POSTFIX})
+
def add_volume_to_default_storage_group_for_fast_policy(
self, conn, controllerConfigService, volumeInstance,
volumeName, fastPolicyName, extraSpecs):
associated with the volume
"""
failedRet = None
- defaultSgGroupName = (DEFAULT_SG_PREFIX + fastPolicyName +
- DEFAULT_SG_POSTFIX)
+ defaultSgName = self._format_default_sg_string(fastPolicyName)
storageGroupInstanceName = self.utils.find_storage_masking_group(
- conn, controllerConfigService, defaultSgGroupName)
+ conn, controllerConfigService, defaultSgName)
if storageGroupInstanceName is None:
LOG.error(_LE(
"Unable to create default storage group for "
:returns: defaultStorageGroupInstanceName - the default storage group
instance name
"""
- defaultSgGroupName = (DEFAULT_SG_PREFIX + fastPolicyName +
- DEFAULT_SG_POSTFIX)
+ defaultSgName = self._format_default_sg_string(fastPolicyName)
defaultStorageGroupInstanceName = (
self.utils.find_storage_masking_group(conn,
controllerConfigService,
- defaultSgGroupName))
+ defaultSgName))
if defaultStorageGroupInstanceName is None:
# Create it and associate it with the FAST policy in question.
defaultStorageGroupInstanceName = (
self._create_default_storage_group(conn,
controllerConfigService,
fastPolicyName,
- defaultSgGroupName,
+ defaultSgName,
volumeInstance,
extraSpecs))
self.key_file = None if key_file is None else key_file
self.cert_file = None if cert_file is None else cert_file
self.insecure = no_verification
- self.ca_certs = None if ca_certs is None else str(ca_certs)
+ self.ca_certs = (
+ None if ca_certs is None else six.text_type(ca_certs))
self.set_context()
# ssl exceptions are reported in various form in Python 3
# so to be compatible, we report the same kind as under
for storagePoolSetting in storagePoolSettings:
settingInstanceID = storagePoolSetting['InstanceID']
- matchString = slo + ':' + workload
+ matchString = ("%(slo)s:%(workload)s"
+ % {'slo': slo,
+ 'workload': workload})
if matchString in settingInstanceID:
foundStoragePoolSetting = storagePoolSetting
break
idarray = poolInstanceId.split('+')
if len(idarray) > 2:
- systemName = idarray[0] + '+' + idarray[1]
+ systemName = self._format_system_name(idarray[0], idarray[1])
LOG.debug("Pool name: %(poolName)s System name: %(systemName)s.",
{'poolName': poolName, 'systemName': systemName})
return poolName, systemName
+ def _format_system_name(self, part1, part2):
+ """Join to make up system name
+
+ :param part1: the prefix
+ :param part2: the postfix
+ :returns: systemName
+ """
+ return ("%(part1)s+%(part2)s"
+ % {'part1': part1,
+ 'part2': part2})
+
def parse_pool_instance_id_v3(self, poolInstanceId):
"""Given the instance Id parse the pool name and system name from it.
idarray = poolInstanceId.split('-+-')
if len(idarray) > 2:
- systemName = idarray[0] + '-+-' + idarray[1]
+ systemName = self._format_system_name(idarray[0], idarray[1])
LOG.debug("Pool name: %(poolName)s System name: %(systemName)s.",
{'poolName': poolName, 'systemName': systemName})
:returns: string -- delta in string H:MM:SS
"""
delta = endTime - startTime
- return str(datetime.timedelta(seconds=int(delta)))
+ return six.text_type(datetime.timedelta(seconds=int(delta)))
def find_sync_sv_by_target(
self, conn, storageSystem, target, waitforsync=True):
:param workload: the workload string e.g DSS
:returns: storageGroupName
"""
- return 'OS-' + poolName + '-' + slo + '-' + workload + '-SG'
+ storageGroupName = ("OS-%(poolName)s-%(slo)s-%(workload)s-SG"
+ % {'poolName': poolName,
+ 'slo': slo,
+ 'workload': workload})
+ return storageGroupName
def strip_short_host_name(self, storageGroupName):
tempList = storageGroupName.split("-")