]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix return value inconsistency in VNX Driver
authorJeegn Chen <jeegn.chen@emc.com>
Tue, 17 Feb 2015 05:05:26 +0000 (13:05 +0800)
committerJeegn Chen <jeegn.chen@emc.com>
Wed, 18 Feb 2015 09:05:41 +0000 (17:05 +0800)
When iscsi_initiators option for EMC Cinder Driver has no value,
a dict object is returned by find_available_iscsi_targets() in
EMC Cinder Driver while a list is expected. Thus an
initialize_connection() will fail due to the inconsistency.

This patch is to fix this inconsistency in the driver.

Change-Id: I094340cc60da4a8b423233983a1d00784bbbb8ea
Closes-Bug: 1422563

cinder/tests/test_emc_vnxdirect.py
cinder/volume/drivers/emc/emc_vnx_cli.py

index 56a557ace675d098eac67509d099e3a2713054f5..039dad60820664ffd61ea49bcf86a18a5edf9355 100644 (file)
@@ -1460,7 +1460,7 @@ Time Remaining:  0 second(s)
                                                           '10.0.0.2'))]
         fake_cli.assert_has_calls(expected)
 
-        # Test for manaul registration
+        # Test for manual registration
         self.configuration.initiator_auto_registration = False
 
         commands = [('storagegroup', '-list', '-gname', 'fakehost'),
@@ -1496,6 +1496,38 @@ Time Remaining:  0 second(s)
                                                           '10.0.0.2'))]
         fake_cli.assert_has_calls(expected)
 
+        # Test No Ping
+        self.configuration.iscsi_initiators = None
+
+        commands = [('storagegroup', '-list', '-gname', 'fakehost'),
+                    self.testData.CONNECTHOST_CMD('fakehost', 'fakehost')]
+        results = [
+            [("No group", 83),
+             self.testData.STORAGE_GROUP_HAS_MAP('fakehost')],
+            ('', 0)]
+        fake_cli = self.driverSetup(commands, results)
+        test_volume_rw = self.testData.test_volume_rw.copy()
+        test_volume_rw['provider_location'] = 'system^fakesn|type^lun|id^1'
+        connection_info = self.driver.initialize_connection(
+            test_volume_rw,
+            self.testData.connector)
+
+        self.assertEqual(self.testData.iscsi_connection_info_rw,
+                         connection_info)
+
+        expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost',
+                              poll=False),
+                    mock.call('storagegroup', '-create', '-gname', 'fakehost'),
+                    mock.call('storagegroup', '-connecthost',
+                              '-host', 'fakehost', '-gname', 'fakehost', '-o'),
+                    mock.call('storagegroup', '-list', '-gname', 'fakehost',
+                              poll=True),
+                    mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1,
+                              '-gname', 'fakehost', poll=False),
+                    mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
+                              poll=False)]
+        fake_cli.assert_has_calls(expected)
+
     @mock.patch('random.randint',
                 mock.Mock(return_value=0))
     def test_initialize_connection_multipath(self):
@@ -1525,8 +1557,8 @@ Time Remaining:  0 second(s)
             test_volume_rw,
             connector_m)
 
-        self.assertEqual(connection_info,
-                         self.testData.iscsi_connection_info_mp)
+        self.assertEqual(self.testData.iscsi_connection_info_mp,
+                         connection_info)
 
         expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost',
                               poll=False),
index ff3d1f2b44c8a5b45d38294c831e3bb84657b2da..08b56e0c1cef074790abb5c6fd460e3686cb3970 100644 (file)
@@ -1396,7 +1396,7 @@ class CommandLineHelper(object):
                               "Return a random target portal %(portal)s.",
                               {'hostname': hostname,
                                'portal': target_portal})
-                    return target_portal
+                    return [target_portal]
 
         return None
 
@@ -1557,7 +1557,7 @@ class CommandLineHelper(object):
 class EMCVnxCliBase(object):
     """This class defines the functions to use the native CLI functionality."""
 
-    VERSION = '05.02.00'
+    VERSION = '05.02.01'
     stats = {'driver_version': VERSION,
              'storage_protocol': None,
              'vendor_name': 'EMC',