From: Helen Walsh Date: Wed, 11 Nov 2015 21:52:18 +0000 (+0000) Subject: VMAX-Replacing deprecated API EMCGetTargetEndpoints X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7f434a09b1c6f9b5c1f3adf381f5755ebc879cf4;p=openstack-build%2Fcinder-build.git VMAX-Replacing deprecated API EMCGetTargetEndpoints 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 --- diff --git a/cinder/tests/unit/test_emc_vmax.py b/cinder/tests/unit/test_emc_vmax.py index bd87d3474..0acd6b3ad 100644 --- a/cinder/tests/unit/test_emc_vmax.py +++ b/cinder/tests/unit/test_emc_vmax.py @@ -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) diff --git a/cinder/volume/drivers/emc/emc_vmax_common.py b/cinder/volume/drivers/emc/emc_vmax_common.py index 1e4fede9d..10f58e5ef 100644 --- a/cinder/volume/drivers/emc/emc_vmax_common.py +++ b/cinder/volume/drivers/emc/emc_vmax_common.py @@ -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): diff --git a/cinder/volume/drivers/emc/emc_vmax_fc.py b/cinder/volume/drivers/emc/emc_vmax_fc.py index 38405e5b7..f5f1de30b 100644 --- a/cinder/volume/drivers/emc/emc_vmax_fc.py +++ b/cinder/volume/drivers/emc/emc_vmax_fc.py @@ -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" diff --git a/cinder/volume/drivers/emc/emc_vmax_iscsi.py b/cinder/volume/drivers/emc/emc_vmax_iscsi.py index d1cde1c4f..66d3fc0e7 100644 --- a/cinder/volume/drivers/emc/emc_vmax_iscsi.py +++ b/cinder/volume/drivers/emc/emc_vmax_iscsi.py @@ -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" diff --git a/cinder/volume/drivers/emc/emc_vmax_provision.py b/cinder/volume/drivers/emc/emc_vmax_provision.py index 28fa7d9ef..2a769a826 100644 --- a/cinder/volume/drivers/emc/emc_vmax_provision.py +++ b/cinder/volume/drivers/emc/emc_vmax_provision.py @@ -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. diff --git a/cinder/volume/drivers/emc/emc_vmax_utils.py b/cinder/volume/drivers/emc/emc_vmax_utils.py index a065a2505..8c2998dc9 100644 --- a/cinder/volume/drivers/emc/emc_vmax_utils.py +++ b/cinder/volume/drivers/emc/emc_vmax_utils.py @@ -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