]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
VMAX-Replacing deprecated API EMCGetTargetEndpoints
authorHelen Walsh <helen.walsh@emc.com>
Wed, 11 Nov 2015 21:52:18 +0000 (21:52 +0000)
committerHelen Walsh <helen.walsh@emc.com>
Tue, 1 Mar 2016 23:55:54 +0000 (23:55 +0000)
8.x version of Solution Enabler no longer supports
EMCGetTargetEndpoints InvokeMethod. Replacing with
an AssociatorNames call from protocol controller
to EMC_FCSCSIProtocolEndpoint. It will retrieve
the same information.

Closes-Bug: #1512791
Change-Id: I49b49c3deb372cbbf77e87313d0cbc155cdb8984

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
cinder/volume/drivers/emc/emc_vmax_provision.py
cinder/volume/drivers/emc/emc_vmax_utils.py

index bd87d3474d484a9f4e100221e1a7e813b07a2193..0acd6b3ad3730437d4dde4fbf514fb2499584077 100644 (file)
@@ -786,6 +786,8 @@ class FakeEcomConnection(object):
             result = self._enum_repgroups()
         elif ResultClass == 'Symm_FCSCSIProtocolEndpoint':
             result = self._enum_fcscsiendpoint()
+        elif ResultClass == 'EMC_FCSCSIProtocolEndpoint':
+            result = self._enum_fcscsiendpoint()
         elif ResultClass == 'Symm_SRPStoragePool':
             result = self._enum_srpstoragepool()
         elif ResultClass == 'Symm_StoragePoolCapabilities':
@@ -7609,3 +7611,43 @@ class EMCVMAXFCTest(test.TestCase):
         mvInstances = self.driver._get_common_masking_views(
             portGroupInstanceName, initiatorGroupInstanceName)
         self.assertTrue(len(mvInstances) == 0)
+
+
+class EMCVMAXUtilsTest(test.TestCase):
+    def setUp(self):
+
+        self.data = EMCVMAXCommonData()
+        super(EMCVMAXUtilsTest, self).setUp()
+
+        configuration = mock.Mock()
+        configuration.safe_get.return_value = 'UtilsTests'
+        configuration.config_group = 'UtilsTests'
+        emc_vmax_common.EMCVMAXCommon._gather_info = mock.Mock()
+        driver = emc_vmax_iscsi.EMCVMAXISCSIDriver(configuration=configuration)
+        driver.db = FakeDB()
+        self.driver = driver
+        self.driver.utils = emc_vmax_utils.EMCVMAXUtils(object)
+
+    def test_get_target_endpoints(self):
+        conn = FakeEcomConnection()
+        hardwareid = 123456789012345
+        result = self.driver.utils.get_target_endpoints(conn, hardwareid)
+        self.assertEqual(
+            ([{'Name': '5000090000000000'}]), result)
+
+    def test_get_protocol_controller(self):
+        conn = FakeEcomConnection()
+        hardwareid = 123456789012345
+        result = self.driver.utils.get_protocol_controller(conn, hardwareid)
+        self.assertEqual(
+            ({'CreationClassName': 'Symm_LunMaskingView',
+              'ElementName': 'OS-fakehost-gold-I-MV'}), result)
+
+    def test_get_protocol_controller_exception(self):
+        conn = FakeEcomConnection()
+        conn.AssociatorNames = mock.Mock(return_value=[])
+        hardwareid = 123456789012345
+        self.assertRaises(
+            exception.VolumeBackendAPIException,
+            self.driver.utils.get_protocol_controller,
+            conn, hardwareid)
index 1e4fede9d78a475a519191730346349ed8587cb1..10f58e5ef2aedc478011df09731a9a3f567eade2 100644 (file)
@@ -1576,9 +1576,9 @@ class EMCVMAXCommon(object):
             LOG.debug("HardwareID instance is: %(hardwareIdInstance)s.",
                       {'hardwareIdInstance': hardwareIdInstance})
             try:
-                _rc, targetEndpoints = (
-                    self.provision.get_target_endpoints(
-                        self.conn, storageHardwareService, hardwareIdInstance))
+                targetEndpoints = (
+                    self.utils.get_target_endpoints(
+                        self.conn, hardwareIdInstance))
             except Exception:
                 errorMessage = (_(
                     "Unable to get target endpoints for hardwareId "
@@ -1588,11 +1588,10 @@ class EMCVMAXCommon(object):
                 raise exception.VolumeBackendAPIException(data=errorMessage)
 
             if targetEndpoints:
-                endpoints = targetEndpoints['TargetEndpoints']
 
                 LOG.debug("There are %(len)lu endpoints.",
-                          {'len': len(endpoints)})
-                for targetendpoint in endpoints:
+                          {'len': len(targetEndpoints)})
+                for targetendpoint in targetEndpoints:
                     wwn = targetendpoint['Name']
                     # Add target wwn to the list if it is not already there.
                     if not any(d == wwn for d in targetWwns):
index 38405e5b7e674a51e6881370e8b3d914bc47752c..f5f1de30b83367e17fac8803f09459682148113d 100644 (file)
@@ -59,6 +59,7 @@ class EMCVMAXFCDriver(driver.FibreChannelDriver):
               - necessary updates for CG changes (#1534616)
               - Changing PercentSynced to CopyState (bug #1517103)
               - Getting iscsi ip from port in existing masking view
+              - Replacement of EMCGetTargetEndpoints api (bug #1512791)
     """
 
     VERSION = "2.3.0"
index d1cde1c4fde585978c1963c6cf6da5d81f20926c..66d3fc0e75cba72e177c15cd95f4b8a8262b9d28 100644 (file)
@@ -65,6 +65,7 @@ class EMCVMAXISCSIDriver(driver.ISCSIDriver):
               - necessary updates for CG changes (#1534616)
               - Changing PercentSynced to CopyState (bug #1517103)
               - Getting iscsi ip from port in existing masking view
+              - Replacement of EMCGetTargetEndpoints api (bug #1512791)
     """
 
     VERSION = "2.3.0"
index 28fa7d9efcd7f7fcf10bca9db294075a73ebf513..2a769a826905fbdf7458741f839174cd3052612e 100644 (file)
@@ -835,34 +835,6 @@ class EMCVMAXProvision(object):
 
         return rc, job
 
-    def get_target_endpoints(self, conn, storageHardwareService, hardwareId):
-        """Given the hardwareId get the target endpoints.
-
-        :param conn: the connection to the ecom server
-        :param storageHardwareService: the storage HardwareId Service
-        :param hardwareId: the hardware Id
-        :returns: int -- return code
-        :returns: targetEndpoints
-        :raises: VolumeBackendAPIException
-        """
-        startTime = time.time()
-
-        rc, targetEndpoints = conn.InvokeMethod(
-            'EMCGetTargetEndpoints', storageHardwareService,
-            HardwareId=hardwareId)
-
-        if rc != 0:
-            exceptionMessage = (_("Error finding Target WWNs."))
-            LOG.error(exceptionMessage)
-            raise exception.VolumeBackendAPIException(data=exceptionMessage)
-
-        LOG.debug("InvokeMethod EMCGetTargetEndpoints "
-                  "took: %(delta)s H:MM:SS.",
-                  {'delta': self.utils.get_time_delta(startTime,
-                                                      time.time())})
-
-        return rc, targetEndpoints
-
     def create_consistency_group(
             self, conn, replicationService, consistencyGroupName, extraSpecs):
         """Create a new consistency group.
index a065a2505433aa9ac303470ad5305ca1f3540293..8c2998dc972c560e51c5d5d273caae7ca95e2a6f 100644 (file)
@@ -2436,3 +2436,43 @@ class EMCVMAXUtils(object):
                 cimProperties = properties[1]
                 foundIpAddress = cimProperties.value
         return foundIpAddress
+
+    def get_target_endpoints(self, conn, hardwareId):
+        """Given the hardwareId get the target endpoints.
+
+        :param conn: the connection to the ecom server
+        :param hardwareId: the hardware Id
+        :returns: targetEndpoints
+        :raises: VolumeBackendAPIException
+        """
+        protocolControllerInstanceName = self.get_protocol_controller(
+            conn, hardwareId)
+
+        targetEndpoints = conn.AssociatorNames(
+            protocolControllerInstanceName,
+            ResultClass='EMC_FCSCSIProtocolEndpoint')
+
+        return targetEndpoints
+
+    def get_protocol_controller(self, conn, hardwareinstancename):
+        """Get the front end protocol endpoints of a hardware instance
+
+        :param conn: the ecom connection
+        :param hardwareinstancename: the hardware instance name
+        :returns: protocolControllerInstanceName
+        :raises: VolumeBackendAPIException
+        """
+        protocolControllerInstanceName = None
+        protocol_controllers = conn.AssociatorNames(
+            hardwareinstancename,
+            ResultClass='EMC_FrontEndSCSIProtocolController')
+        if len(protocol_controllers) > 0:
+            protocolControllerInstanceName = protocol_controllers[0]
+        if protocolControllerInstanceName is None:
+            exceptionMessage = (_(
+                "Unable to get target endpoints for hardwareId "
+                "%(hardwareIdInstance)s.")
+                % {'hardwareIdInstance': hardwareinstancename})
+            LOG.error(exceptionMessage)
+            raise exception.VolumeBackendAPIException(data=exceptionMessage)
+        return protocolControllerInstanceName