]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
i18n Compatibility in VMAX driver
authorXing Yang <xing.yang@emc.com>
Fri, 20 Feb 2015 06:57:05 +0000 (01:57 -0500)
committerXing Yang <xing.yang@emc.com>
Fri, 27 Feb 2015 20:31:18 +0000 (15:31 -0500)
The patch fixed some message formatting issues according to the
i18n guidelines in the VMAX driver.

Change-Id: I5c1d2ec640d26c026bda89061e416fe7b136eaac

cinder/volume/drivers/emc/emc_vmax_common.py
cinder/volume/drivers/emc/emc_vmax_fast.py
cinder/volume/drivers/emc/emc_vmax_https.py
cinder/volume/drivers/emc/emc_vmax_provision_v3.py
cinder/volume/drivers/emc/emc_vmax_utils.py

index 73d3bcd89e1a3009224e9348fa732a9967364c08..f0438a62ae75f09a046565c69f1bd04626a7f54b 100644 (file)
@@ -1091,7 +1091,9 @@ class EMCVMAXCommon(object):
                 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 "
@@ -1544,15 +1546,19 @@ class EMCVMAXCommon(object):
             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
@@ -1577,10 +1583,15 @@ class EMCVMAXCommon(object):
         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):
@@ -1681,23 +1692,27 @@ class EMCVMAXCommon(object):
             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']
@@ -1711,7 +1726,9 @@ class EMCVMAXCommon(object):
                 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
@@ -2241,8 +2258,8 @@ class EMCVMAXCommon(object):
                           "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)
@@ -3524,7 +3541,7 @@ class EMCVMAXCommon(object):
             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):
index 155f3bc3d601473d430b684d7e84c6e3683e703e..4515b64447a91694b22d0124a64c26a70113dfee 100644 (file)
@@ -117,12 +117,11 @@ class EMCVMAXFast(object):
 
         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 "
@@ -138,9 +137,20 @@ class EMCVMAXFast(object):
                 "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):
@@ -159,10 +169,9 @@ class EMCVMAXFast(object):
             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 "
@@ -740,19 +749,18 @@ class EMCVMAXFast(object):
         :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))
 
index c44f5912b254599c13a56917cbea47e9ae13df49..9a145723b7d410e9ad20101549541f96a5910900 100644 (file)
@@ -108,7 +108,8 @@ class HTTPSConnection(httplib.HTTPSConnection):
             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
index 80ca10e6aa8f37641820cb39314ee3785e403759..cac18c2178794a72a9e8efa12c95bb028028c9e9 100644 (file)
@@ -349,7 +349,9 @@ class EMCVMAXProvisionV3(object):
 
         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
index 613853cfdcc8c84cbc5f9ebbb14db5b4dc6039bb..c9301636a4d2369fa8742be20e40f368f1da56cd 100644 (file)
@@ -868,12 +868,23 @@ class EMCVMAXUtils(object):
 
         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.
 
@@ -891,7 +902,7 @@ class EMCVMAXUtils(object):
 
         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})
@@ -1366,7 +1377,7 @@ class EMCVMAXUtils(object):
         :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):
@@ -1706,7 +1717,11 @@ class EMCVMAXUtils(object):
         :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("-")