'-+-')
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'
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
:returns: hardwareIdList
"""
hardwareIdList = None
- hardwareIdType = 2
+ hardwareIdType = self._get_hardware_type(initiator)
rc, ret = conn.InvokeMethod(
'CreateStorageHardwareID',
hardwareIdManagementService,
"%(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