]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Create initiator id for VMAX iSCSI driver
authorXing Yang <xing.yang@emc.com>
Tue, 21 Apr 2015 03:08:38 +0000 (23:08 -0400)
committerXing Yang <xing.yang@emc.com>
Fri, 24 Apr 2015 02:35:09 +0000 (22:35 -0400)
This is related to Bug #1440427. The fix for that bug only addressed
the issue for the FC driver. The same problem exists for the iSCSI
driver. This patch addressed the problem for the VMAX iSCSI driver.
The initiator id will be created on the array if it does not exist
for the iSCSI driver.

Change-Id: I5df57df122a704066d4d7a1997ac2642b073c9e8
Closes-Bug: #1446443

cinder/tests/unit/test_emc_vmax.py
cinder/volume/drivers/emc/emc_vmax_utils.py

index d335053b5443810ee1a6ee9a8c5643d57603f939..c33f07fd2d3f80a8ee909f6a8910b3dbc8e30606 100644 (file)
@@ -1644,6 +1644,20 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase):
                                                              '-+-')
         self.assertEqual('SYMMETRIX-+-000197200056', systemnameV3)
 
+    def test_get_hardware_type(self):
+        iqn_initiator = 'iqn.1992-04.com.emc: 50000973f006dd80'
+        hardwaretypeid = (
+            self.driver.utils._get_hardware_type(iqn_initiator))
+        self.assertEqual(5, hardwaretypeid)
+        wwpn_initiator = '123456789012345'
+        hardwaretypeid = (
+            self.driver.utils._get_hardware_type(wwpn_initiator))
+        self.assertEqual(2, hardwaretypeid)
+        bogus_initiator = 'bogus'
+        hardwaretypeid = (
+            self.driver.utils._get_hardware_type(bogus_initiator))
+        self.assertEqual(0, hardwaretypeid)
+
     def test_wait_for_job_complete(self):
         myjob = SE_ConcreteJob()
         myjob.classname = 'SE_ConcreteJob'
index 8636a69b48b09fefef339b8e6c8026b7bca5f833..4c2d10648d7fa0f10bfa157ef59f3c59fde9a694 100644 (file)
@@ -1894,7 +1894,7 @@ class EMCVMAXUtils(object):
 
     def create_storage_hardwareId_instance_name(
             self, conn, hardwareIdManagementService, initiator):
-        """Create storage hardware ID instance name based on the given wwpn.
+        """Create storage hardware ID instance name based on the WWPN/IQN.
 
         :param conn: connection to the ecom server
         :param hardwareIdManagementService: the hardware ID management service
@@ -1903,7 +1903,7 @@ class EMCVMAXUtils(object):
         :returns: hardwareIdList
         """
         hardwareIdList = None
-        hardwareIdType = 2
+        hardwareIdType = self._get_hardware_type(initiator)
         rc, ret = conn.InvokeMethod(
             'CreateStorageHardwareID',
             hardwareIdManagementService,
@@ -1920,3 +1920,21 @@ class EMCVMAXUtils(object):
                          "%(initiator)s, rc=%(rc)d, ret=%(ret)s."),
                      {'initiator': initiator, 'rc': rc, 'ret': ret})
         return hardwareIdList
+
+    def _get_hardware_type(
+            self, initiator):
+        """Determine the hardware type based on the initiator.
+
+        :param initiator: initiator(IQN or WWPN)
+        :returns: hardwareTypeId
+        """
+        hardwareTypeId = 0
+        try:
+            int(initiator, 16)
+            hardwareTypeId = 2
+        except Exception:
+            if 'iqn' in initiator.lower():
+                hardwareTypeId = 5
+        if hardwareTypeId == 0:
+            LOG.warn(_LW("Cannot determine the hardware type."))
+        return hardwareTypeId