]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Getting iscsi_ip_address from cinder.conf
authorXing Yang <xing.yang@emc.com>
Sun, 14 Sep 2014 23:50:01 +0000 (19:50 -0400)
committerXing Yang <xing.yang@emc.com>
Mon, 15 Sep 2014 03:46:00 +0000 (23:46 -0400)
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
cinder/volume/drivers/emc/emc_vmax_common.py
cinder/volume/drivers/emc/emc_vmax_fc.py
cinder/volume/drivers/emc/emc_vmax_iscsi.py

index eee0025ee1e91cffa40e94082d3b7cce5c3a4198..de26053bb4a5f92f1a9b44dd22c7d8051ace144d 100644 (file)
@@ -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)
 
index 08553305e947e9e4bd9b6e608ee7baf308e389ec..20a0f6ba46a413cd046925f0878de5a13e392147 100644 (file)
@@ -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
index 6d83a4f781fedd6cd54ebdb1b8dfb41d7c3d72c1..b5aba28515817d8b3c43276df17f3398f5e4f552 100644 (file)
@@ -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']
index c3f595dfdc3410d7122833ba3bf10965cb34d32f..8a8ab6762d8d706fa536b1f741ccc42ecdfc5b66 100644 (file)
@@ -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")