]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
EMC VMAX - get_short_host_name not called in find_device_number
authorHelen Walsh <helen.walsh@emc.com>
Tue, 1 Dec 2015 22:38:33 +0000 (22:38 +0000)
committerHelen Walsh <helen.walsh@emc.com>
Tue, 15 Dec 2015 02:08:27 +0000 (02:08 +0000)
The get_short_host_name needs to be called in find_device_number.
There are 2 reasons for this:
1. Sometimes the full host name is contained in the
   connector['host'] object.
2. When the short host name still exceeds 38 characters,
   it must be truncated, in order to guarantee a "contains string"
   match between the host and the masking view name.

Change-Id: I9631f33eafe2cfb64388d8e19c6ed8d1e948a6fa
Closes-Bug: #1520635

cinder/tests/unit/test_emc_vmax.py
cinder/volume/drivers/emc/emc_vmax_common.py
cinder/volume/drivers/emc/emc_vmax_fc.py
cinder/volume/drivers/emc/emc_vmax_iscsi.py

index d789a85230a9a9b53dd569618e542b7eebbc164c..3e7d510c38fd60056a80ab93ed30657c3d181115 100644 (file)
@@ -813,8 +813,7 @@ class FakeEcomConnection(object):
 
         return unitnames
 
-    def _ref_unitnames2(self):
-        unitnames = []
+    def mv_entry(self, mvname):
         unitname = {}
 
         dependent = {}
@@ -829,28 +828,28 @@ class FakeEcomConnection(object):
 
         classcimproperty = Fake_CIMProperty()
         elementName = (
-            classcimproperty.fake_getElementNameCIMProperty('OS-myhost-MV'))
+            classcimproperty.fake_getElementNameCIMProperty(mvname))
         properties = {u'ElementName': elementName}
         antecedent.properties = properties
 
         unitname['Dependent'] = dependent
         unitname['Antecedent'] = antecedent
         unitname['CreationClassName'] = self.data.unit_creationclass
+        return unitname
+
+    def _ref_unitnames2(self):
+        unitnames = []
+        unitname = self.mv_entry('OS-myhost-MV')
         unitnames.append(unitname)
 
         # Second masking
-        unitname2 = unitname.copy()
-        elementName2 = (
-            classcimproperty.fake_getElementNameCIMProperty('OS-fakehost-MV'))
-        properties2 = {u'ElementName': elementName2}
-
-        antecedent2 = SYMM_LunMasking()
-        antecedent2['CreationClassName'] = self.data.lunmask_creationclass2
-        antecedent2['SystemName'] = self.data.storage_system
-
-        antecedent2.properties = properties2
-        unitname2['Antecedent'] = antecedent2
+        unitname2 = self.mv_entry('OS-fakehost-MV')
         unitnames.append(unitname2)
+
+        # third masking
+        amended = 'OS-rslong493156848e71b072a17c1c4625e45f75-MV'
+        unitname3 = self.mv_entry(amended)
+        unitnames.append(unitname3)
         return unitnames
 
     def _default_ref(self, objectpath):
@@ -2022,9 +2021,29 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase):
         data = (
             self.driver.common.find_device_number(self.data.test_volume_v2,
                                                   host))
-        # Empty dict
         self.assertFalse(data)
 
+    def test_find_device_number_long_host(self):
+        # Long host name
+        host = 'myhost.mydomain.com'
+        data = (
+            self.driver.common.find_device_number(self.data.test_volume_v2,
+                                                  host))
+        self.assertEqual('OS-myhost-MV', data['maskingview'])
+
+    def test_find_device_number_short_name_over_38_chars(self):
+        # short name over 38 chars
+        host = 'myShortnameIsOverThirtyEightCharactersLong'
+        host = self.driver.common.utils.generate_unique_trunc_host(host)
+        amended = 'OS-' + host + '-MV'
+        v2_host_over_38 = self.data.test_volume_v2.copy()
+        # Pool aware scheduler enabled
+        v2_host_over_38['host'] = host
+        data = (
+            self.driver.common.find_device_number(v2_host_over_38,
+                                                  host))
+        self.assertEqual(amended, data['maskingview'])
+
     def test_unbind_and_get_volume_from_storage_pool(self):
         conn = self.fake_ecom_connection()
         common = self.driver.common
index f1935fe54a9dc928e00ababc87fff50f1b2d1c4f..928e0cd6c36f456fa9b06d870b2fc3501405cc45 100644 (file)
@@ -1472,6 +1472,7 @@ class EMCVMAXCommon(object):
                 {'volumeName': volumeName,
                  'volumeInstance': volumeInstance.path})
         else:
+            host = self.utils.get_host_short_name(host)
             hoststr = ("-%(host)s-"
                        % {'host': host})
 
index f8b44945bd0618ebddd918bfb8e362611e2bf69b..4b3a286ed2109cd504879e4f620c4d8a3877c154 100644 (file)
@@ -44,6 +44,8 @@ class EMCVMAXFCDriver(driver.FibreChannelDriver):
         2.2.4 - Create CG from CG snapshot
         2.3.0 - Name change for MV and SG for FAST (bug #1515181)
               - Fix for randomly choosing port group. (bug #1501919)
+              - get_short_host_name needs to be called in find_device_number
+                (bug #1520635)
     """
 
     VERSION = "2.3.0"
index 3161a51ab0fb05359e4be87e20311f602ff359bc..605aef1cfa97534991275db8803538cd6a08d131 100644 (file)
@@ -52,6 +52,8 @@ class EMCVMAXISCSIDriver(driver.ISCSIDriver):
         2.2.4 - Create CG from CG snapshot
         2.3.0 - Name change for MV and SG for FAST (bug #1515181)
               - Fix for randomly choosing port group. (bug #1501919)
+              - get_short_host_name needs to be called in find_device_number
+                (bug #1520635)
     """
 
     VERSION = "2.3.0"