From debbf0ee49dcb78a92afaed24a60d81ba441430f Mon Sep 17 00:00:00 2001 From: Xing Yang Date: Sun, 14 Sep 2014 19:50:01 -0400 Subject: [PATCH] Getting iscsi_ip_address from cinder.conf In the current version (2.0) of the VMAX driver, we retrieve iSCSI IP addresses dynamically from SMI-S. However, we ran into situations where we can't get them reliably during testing. The fix is to get this information from cinder.conf, just like in version 1.0. Change-Id: If474f44e99cc45592bacfdec9e1eb2fa48c41e68 Closes-Bug: #1369355 --- cinder/tests/test_emc_vmax.py | 29 ++++++++------------ cinder/volume/drivers/emc/emc_vmax_common.py | 13 ++------- cinder/volume/drivers/emc/emc_vmax_fc.py | 2 +- cinder/volume/drivers/emc/emc_vmax_iscsi.py | 19 +++++++------ 4 files changed, 25 insertions(+), 38 deletions(-) diff --git a/cinder/tests/test_emc_vmax.py b/cinder/tests/test_emc_vmax.py index eee0025ee..de26053bb 100644 --- a/cinder/tests/test_emc_vmax.py +++ b/cinder/tests/test_emc_vmax.py @@ -1037,7 +1037,7 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase): conn = FakeEcomConnection() return conn - def fake_do_iscsi_discovery(self, volume, ipAddress): + def fake_do_iscsi_discovery(self, volume): output = [] item = '10.10.0.50: 3260,1 iqn.1992-04.com.emc: 50000973f006dd80' output.append(item) @@ -1181,12 +1181,8 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase): '_wrap_find_device_number', return_value={'hostlunid': 1, 'storagesystem': EMCVMAXCommonData.storage_system}) - @mock.patch.object( - EMCVMAXUtils, - 'find_ip_protocol_endpoint', - return_value='10.10.10.10') def test_map_no_fast_success(self, _mock_volume_type, mock_wrap_group, - mock_wrap_device, mock_find_ip): + mock_wrap_device): self.driver.initialize_connection(self.data.test_volume, self.data.connector) @@ -1362,6 +1358,13 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase): self.data.test_ctxt, self.data.test_volume, self.data.new_type, self.data.diff, self.data.test_host) + def test_check_for_setup_error(self): + self.driver.configuration.iscsi_ip_address = '1.1.1.1' + self.driver.check_for_setup_error() + self.driver.configuration.iscsi_ip_address = None + self.assertRaises(exception.InvalidInput, + self.driver.check_for_setup_error) + def _cleanup(self): bExists = os.path.exists(self.config_file_path) if bExists: @@ -1470,7 +1473,7 @@ class EMCVMAXISCSIDriverFastTestCase(test.TestCase): conn = FakeEcomConnection() return conn - def fake_do_iscsi_discovery(self, volume, ipAddress): + def fake_do_iscsi_discovery(self, volume): output = [] item = '10.10.0.50: 3260,1 iqn.1992-04.com.emc: 50000973f006dd80' output.append(item) @@ -1621,12 +1624,8 @@ class EMCVMAXISCSIDriverFastTestCase(test.TestCase): '_wrap_find_device_number', return_value={'hostlunid': 1, 'storagesystem': EMCVMAXCommonData.storage_system}) - @mock.patch.object( - EMCVMAXUtils, - 'find_ip_protocol_endpoint', - return_value='10.10.10.10') def test_map_fast_success(self, _mock_volume_type, mock_wrap_group, - mock_wrap_device, mock_find_ip): + mock_wrap_device): self.driver.initialize_connection(self.data.test_volume, self.data.connector) @@ -2109,12 +2108,8 @@ class EMCVMAXFCDriverNoFastTestCase(test.TestCase): '_wrap_find_device_number', return_value={'hostlunid': 1, 'storagesystem': EMCVMAXCommonData.storage_system}) - @mock.patch.object( - EMCVMAXUtils, - 'find_ip_protocol_endpoint', - return_value='10.10.10.10') def test_map_no_fast_success(self, _mock_volume_type, mock_wrap_group, - mock_wrap_device, mock_find_ip): + mock_wrap_device): self.driver.initialize_connection(self.data.test_volume, self.data.connector) diff --git a/cinder/volume/drivers/emc/emc_vmax_common.py b/cinder/volume/drivers/emc/emc_vmax_common.py index 08553305e..20a0f6ba4 100644 --- a/cinder/volume/drivers/emc/emc_vmax_common.py +++ b/cinder/volume/drivers/emc/emc_vmax_common.py @@ -344,10 +344,8 @@ class EMCVMAXCommon(object): :param volume: volume Object :param connector: the connector Object :returns: deviceInfoDict, device information tuple - :returns: ipAddress, required for ISCSI command :raises: VolumeBackendAPIException """ - ipAddress = None extraSpecs = self._initial_setup(volume) volumeName = volume['name'] @@ -390,15 +388,8 @@ class EMCVMAXCommon(object): % {'vol': volumeName}) raise exception.VolumeBackendAPIException( data=exception_message) - if self.protocol.lower() == 'iscsi': - ipAddress = self.utils.find_ip_protocol_endpoint( - self.conn, deviceInfoDict['storagesystem']) - if ipAddress is None: - LOG.info(_("Unable to get iscsi IP address " - "for storagesystem %(storageSystem)s") - % {'storageSystem': deviceInfoDict['storagesystem']}) - - return deviceInfoDict, ipAddress + + return deviceInfoDict def _wrap_find_device_number(self, volume, connector): """Aid for unit testing diff --git a/cinder/volume/drivers/emc/emc_vmax_fc.py b/cinder/volume/drivers/emc/emc_vmax_fc.py index 6d83a4f78..b5aba2851 100644 --- a/cinder/volume/drivers/emc/emc_vmax_fc.py +++ b/cinder/volume/drivers/emc/emc_vmax_fc.py @@ -149,7 +149,7 @@ class EMCVMAXFCDriver(driver.FibreChannelDriver): } } """ - device_info, ipAddress = self.common.initialize_connection( + device_info = self.common.initialize_connection( volume, connector) device_number = device_info['hostlunid'] storage_system = device_info['storagesystem'] diff --git a/cinder/volume/drivers/emc/emc_vmax_iscsi.py b/cinder/volume/drivers/emc/emc_vmax_iscsi.py index c3f595dfd..8a8ab6762 100644 --- a/cinder/volume/drivers/emc/emc_vmax_iscsi.py +++ b/cinder/volume/drivers/emc/emc_vmax_iscsi.py @@ -48,7 +48,9 @@ class EMCVMAXISCSIDriver(driver.ISCSIDriver): configuration=self.configuration) def check_for_setup_error(self): - pass + if not self.configuration.iscsi_ip_address: + raise exception.InvalidInput( + reason=_('iscsi_ip_address is not set.')) def create_volume(self, volume): """Creates a EMC(VMAX/VNX) volume.""" @@ -138,11 +140,10 @@ class EMCVMAXISCSIDriver(driver.ISCSIDriver): } } """ - devInfo, ipAddress = self.common.initialize_connection( - volume, connector) + self.common.initialize_connection(volume, connector) iscsi_properties = self.smis_get_iscsi_properties( - volume, connector, ipAddress) + volume, connector) LOG.info(_("Leaving initialize_connection: %s") % (iscsi_properties)) return { @@ -150,13 +151,13 @@ class EMCVMAXISCSIDriver(driver.ISCSIDriver): 'data': iscsi_properties } - def smis_do_iscsi_discovery(self, volume, ipAddress): + def smis_do_iscsi_discovery(self, volume): - LOG.warn(_("ISCSI provider_location not stored, using discovery")) + LOG.info(_("ISCSI provider_location not stored, using discovery.")) (out, _err) = self._execute('iscsiadm', '-m', 'discovery', '-t', 'sendtargets', '-p', - ipAddress, + self.configuration.iscsi_ip_address, run_as_root=True) LOG.info(_( @@ -168,7 +169,7 @@ class EMCVMAXISCSIDriver(driver.ISCSIDriver): return targets - def smis_get_iscsi_properties(self, volume, connector, ipAddress): + def smis_get_iscsi_properties(self, volume, connector): """Gets iscsi configuration. We ideally get saved information in the volume entity, but fall back @@ -186,7 +187,7 @@ class EMCVMAXISCSIDriver(driver.ISCSIDriver): """ properties = {} - location = self.smis_do_iscsi_discovery(volume, ipAddress) + location = self.smis_do_iscsi_discovery(volume) if not location: raise exception.InvalidVolume(_("Could not find iSCSI export " " for volume %(volumeName)s") -- 2.45.2