From: Xing Yang Date: Tue, 21 Apr 2015 03:08:38 +0000 (-0400) Subject: Create initiator id for VMAX iSCSI driver X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c94e6b153a424056c846f7ba19ee617650174282;p=openstack-build%2Fcinder-build.git Create initiator id for VMAX iSCSI driver 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 --- diff --git a/cinder/tests/unit/test_emc_vmax.py b/cinder/tests/unit/test_emc_vmax.py index d335053b5..c33f07fd2 100644 --- a/cinder/tests/unit/test_emc_vmax.py +++ b/cinder/tests/unit/test_emc_vmax.py @@ -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' diff --git a/cinder/volume/drivers/emc/emc_vmax_utils.py b/cinder/volume/drivers/emc/emc_vmax_utils.py index 8636a69b4..4c2d10648 100644 --- a/cinder/volume/drivers/emc/emc_vmax_utils.py +++ b/cinder/volume/drivers/emc/emc_vmax_utils.py @@ -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