From: Jeegn Chen Date: Tue, 17 Feb 2015 05:05:26 +0000 (+0800) Subject: Fix return value inconsistency in VNX Driver X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c973511fbb436909e25ac47dfe47aaf6aa465af0;p=openstack-build%2Fcinder-build.git Fix return value inconsistency in VNX Driver 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 --- diff --git a/cinder/tests/test_emc_vnxdirect.py b/cinder/tests/test_emc_vnxdirect.py index 56a557ace..039dad608 100644 --- a/cinder/tests/test_emc_vnxdirect.py +++ b/cinder/tests/test_emc_vnxdirect.py @@ -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), diff --git a/cinder/volume/drivers/emc/emc_vnx_cli.py b/cinder/volume/drivers/emc/emc_vnx_cli.py index ff3d1f2b4..08b56e0c1 100644 --- a/cinder/volume/drivers/emc/emc_vnx_cli.py +++ b/cinder/volume/drivers/emc/emc_vnx_cli.py @@ -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',