From: Tina Date: Thu, 6 Aug 2015 03:11:13 +0000 (-0400) Subject: Fix the virtual port support in VNX driver X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=65fb5f817eca2049c6872d63c1332c7c337ff9e2;p=openstack-build%2Fcinder-build.git Fix the virtual port support in VNX driver VNX support virtual port on each physical iSCSI port. The driver used some incorrect command which cannot get the virtual port id information. This causes the driver to not be able to tell whether the registered port is a virtaul port or not. This change fixes the driver to use correct command and handle the virtual port id correctly. Change-Id: I11994dd5a0c8da74fcf15668f49796a45719b5e4 Closes-Bug: #1485484 --- diff --git a/cinder/tests/unit/test_emc_vnxdirect.py b/cinder/tests/unit/test_emc_vnxdirect.py index 0cb240a03..efe84d573 100644 --- a/cinder/tests/unit/test_emc_vnxdirect.py +++ b/cinder/tests/unit/test_emc_vnxdirect.py @@ -571,7 +571,8 @@ class EMCVNXCLIDriverTestData(object): def STORAGEGROUP_LIST_CMD(self, gname=None): if gname: - return ('storagegroup', '-list', '-gname', gname) + return ('storagegroup', '-list', + '-gname', gname, '-host', '-iscsiAttributes') else: return ('storagegroup', '-list') @@ -984,8 +985,25 @@ IP Address: 192.168.4.53 HBA UID SP Name SPPort ------- ------- ------ iqn.1993-08.org.debian:01:222 SP A 4 + Host name: fakehost + SPPort: A-4v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid + 22:34:56:78:90:12:34:56:12:34:56:78:90:12:34:56 SP B 2 + Host name: fakehost2 + SPPort: B-2v0 + Initiator IP: N/A + TPGT: 0 + ISID: N/A + 22:34:56:78:90:54:32:16:12:34:56:78:90:54:32:16 SP B 2 + Host name: fakehost2 + SPPort: B-2v0 + Initiator IP: N/A + TPGT: 0 + ISID: N/A HLU/ALU Pairs: @@ -1010,6 +1028,11 @@ IP Address: 192.168.4.53 HBA UID SP Name SPPort ------- ------- ------ iqn.1993-08.org.debian:01:222 SP A 4 + Host name: fakehost + SPPort: A-4v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid HLU/ALU Pairs: @@ -1028,8 +1051,25 @@ IP Address: 192.168.4.53 HBA UID SP Name SPPort ------- ------- ------ iqn.1993-08.org.debian:01:222 SP A 2 + Host name: fakehost + SPPort: A-2v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid + iqn.1993-08.org.debian:01:222 SP A 0 + Host name: fakehost + SPPort: A-0v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid + iqn.1993-08.org.debian:01:222 SP B 2 + Host name: fakehost + SPPort: B-2v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid HLU/ALU Pairs: @@ -1048,7 +1088,18 @@ IP Address: 192.168.4.53 HBA UID SP Name SPPort ------- ------- ------ iqn.1993-08.org.debian:01:222 SP A 4 + Host name: fakehost + SPPort: A-4v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid + iqn.1993-08.org.debian:01:222 SP A 5 + Host name: fakehost + SPPort: A-5v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid HLU/ALU Pairs: @@ -1067,6 +1118,11 @@ IP Address: 192.168.4.53 HBA UID SP Name SPPort ------- ------- ------ iqn.1993-08.org.debian:01:222 SP A 4 + Host name: fakehost + SPPort: A-4v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid HLU/ALU Pairs: @@ -1096,6 +1152,11 @@ IP Address: 192.168.4.53 HBA UID SP Name SPPort ------- ------- ------ iqn.1993-08.org.debian:01:5741c6307e60 SP A 6 + Host name: fakehost + SPPort: A-6v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid Storage Group Name: %(sgname1)s Storage Group UID: 54:46:57:0F:15:A2:E3:11:9A:8D:FF:E5:3A:03:FD:6D @@ -1104,6 +1165,11 @@ IP Address: 192.168.4.53 HBA UID SP Name SPPort ------- ------- ------ iqn.1993-08.org.debian:01:222 SP A 4 + Host name: fakehost + SPPort: A-4v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid HLU/ALU Pairs: @@ -1120,6 +1186,11 @@ IP Address: 192.168.4.53 HBA UID SP Name SPPort ------- ------- ------ iqn.1993-08.org.debian:01:5741c6307e60 SP A 6 + Host name: fakehost + SPPort: A-6v0 + Initiator IP: fakeip + TPGT: 3 + ISID: fakeid HLU/ALU Pairs: @@ -1140,6 +1211,17 @@ IP Address: 192.168.4.53 "Host LUN/LUN mapping still exists.", 0) + def set_path_cmd(self, gname, hba, sp, spport, vport=None, ip=None): + if vport is None: + return ('storagegroup', '-setpath', '-gname', gname, + '-hbauid', hba, + '-sp', sp, '-spport', spport, + '-ip', ip, '-host', gname, '-o') + return ('storagegroup', '-setpath', '-gname', gname, + '-hbauid', hba, + '-sp', sp, '-spport', spport, '-spvport', vport, + '-ip', ip, '-host', gname, '-o') + class DriverTestCaseBase(test.TestCase): def setUp(self): @@ -1933,7 +2015,7 @@ Time Remaining: 0 second(s) def test_initialize_connection(self): # Test for auto registration self.configuration.initiator_auto_registration = True - commands = [('storagegroup', '-list', '-gname', 'fakehost'), + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost'), self.testData.PINGNODE_CMD('A', 4, 0, '10.0.0.2')] results = [[("No group", 83), self.testData.STORAGE_GROUP_HAS_MAP('fakehost')], @@ -1948,22 +2030,19 @@ Time Remaining: 0 second(s) self.assertEqual(self.testData.iscsi_connection_info, connection_info) - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-create', '-gname', 'fakehost'), - mock.call('storagegroup', '-gname', 'fakehost', '-setpath', - '-hbauid', 'iqn.1993-08.org.debian:01:222', - '-sp', 'A', '-spport', 4, '-spvport', 0, - '-ip', '10.0.0.2', '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-gname', 'fakehost', '-setpath', - '-hbauid', 'iqn.1993-08.org.debian:01:222', - '-sp', 'A', '-spport', 0, '-spvport', 0, - '-ip', '10.0.0.2', '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-gname', 'fakehost', '-setpath', - '-hbauid', 'iqn.1993-08.org.debian:01:222', - '-sp', 'B', '-spport', 2, '-spvport', 0, - '-ip', '10.0.0.2', '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.set_path_cmd( + 'fakehost', 'iqn.1993-08.org.debian:01:222', 'A', + 4, 0, '10.0.0.2')), + mock.call(*self.testData.set_path_cmd( + 'fakehost', 'iqn.1993-08.org.debian:01:222', + 'A', 0, 0, '10.0.0.2')), + mock.call(*self.testData.set_path_cmd( + 'fakehost', 'iqn.1993-08.org.debian:01:222', + 'B', 2, 0, '10.0.0.2')), + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', @@ -1977,7 +2056,7 @@ Time Remaining: 0 second(s) # Test for manual registration self.configuration.initiator_auto_registration = False - commands = [('storagegroup', '-list', '-gname', 'fakehost'), + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost'), self.testData.CONNECTHOST_CMD('fakehost', 'fakehost'), self.testData.PINGNODE_CMD('A', 4, 0, '10.0.0.2')] results = [ @@ -1995,12 +2074,12 @@ Time Remaining: 0 second(s) self.assertEqual(self.testData.iscsi_connection_info, connection_info) - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-create', '-gname', 'fakehost'), mock.call('storagegroup', '-connecthost', '-host', 'fakehost', '-gname', 'fakehost', '-o'), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', poll=False), @@ -2013,7 +2092,7 @@ Time Remaining: 0 second(s) # Test No Ping self.configuration.iscsi_initiators = None - commands = [('storagegroup', '-list', '-gname', 'fakehost'), + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost'), self.testData.CONNECTHOST_CMD('fakehost', 'fakehost')] results = [ [("No group", 83), @@ -2029,12 +2108,12 @@ Time Remaining: 0 second(s) self.assertEqual(self.testData.iscsi_connection_info, connection_info) - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-create', '-gname', 'fakehost'), mock.call('storagegroup', '-connecthost', '-host', 'fakehost', '-gname', 'fakehost', '-o'), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', poll=False), @@ -2051,7 +2130,7 @@ Time Remaining: 0 second(s) def test_initialize_connection_multipath(self): self.configuration.initiator_auto_registration = False - commands = [('storagegroup', '-list', '-gname', 'fakehost')] + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost')] results = [self.testData.STORAGE_GROUP_HAS_MAP_MP('fakehost')] fake_cli = self.driverSetup(commands, results) self.driver.cli.iscsi_targets = { @@ -2064,7 +2143,7 @@ Time Remaining: 0 second(s) {'Port WWN': 'iqn.1992-04.com.emc:cx.fnm00124000215.a5', 'SP': 'A', 'Port ID': 5, - 'Virtual Port ID': 1, + 'Virtual Port ID': 0, 'IP Address': '10.244.214.119'}], 'B': []} test_volume_rw = self.testData.test_volume_rw.copy() @@ -2078,7 +2157,7 @@ Time Remaining: 0 second(s) self.assertEqual(self.testData.iscsi_connection_info_mp, connection_info) - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', poll=False), @@ -2106,7 +2185,7 @@ Time Remaining: 0 second(s) # Test for auto registration self.configuration.initiator_auto_registration = True self.configuration.max_luns_per_storage_group = 2 - commands = [('storagegroup', '-list', '-gname', 'fakehost'), + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost'), ('storagegroup', '-addhlu', '-hlu', 2, '-alu', 3, '-gname', 'fakehost', '-o'), self.testData.PINGNODE_CMD('A', 4, 0, '10.0.0.2')] @@ -2123,12 +2202,12 @@ Time Remaining: 0 second(s) ) self.assertTrue(iscsi_data['data']['target_lun'] == 2, "iSCSI initialize connection returned wrong HLU") - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 3, '-gname', 'fakehost', '-o', poll=False), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'), poll=False), @@ -2144,7 +2223,7 @@ Time Remaining: 0 second(s) test_volume['provider_location'] = 'system^fakesn|type^lun|id^1' # Test for auto registration self.configuration.initiator_auto_registration = True - commands = [('storagegroup', '-list', '-gname', 'fakehost')] + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost')] results = [[("No group", 83), self.testData.STORAGE_GROUP_HAS_MAP_ISCSI('fakehost')]] fake_cli = self.driverSetup(commands, results) @@ -2159,18 +2238,16 @@ Time Remaining: 0 second(s) self.driver.initialize_connection( test_volume, self.testData.connector) - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-create', '-gname', 'fakehost'), - mock.call('storagegroup', '-gname', 'fakehost', '-setpath', - '-hbauid', 'iqn.1993-08.org.debian:01:222', - '-sp', 'A', '-spport', 0, '-spvport', 0, - '-ip', '10.0.0.2', '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-gname', 'fakehost', '-setpath', - '-hbauid', 'iqn.1993-08.org.debian:01:222', - '-sp', 'B', '-spport', 2, '-spvport', 0, - '-ip', '10.0.0.2', '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.set_path_cmd( + 'fakehost', 'iqn.1993-08.org.debian:01:222', + 'A', 0, 0, '10.0.0.2')), + mock.call(*self.testData.set_path_cmd( + 'fakehost', 'iqn.1993-08.org.debian:01:222', + 'B', 2, 0, '10.0.0.2')), + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', @@ -2224,7 +2301,7 @@ Time Remaining: 0 second(s) # Test for auto registration self.configuration.initiator_auto_registration = True self.configuration.max_luns_per_storage_group = 2 - commands = [('storagegroup', '-list', '-gname', 'fakehost'), + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost'), ('storagegroup', '-addhlu', '-hlu', 2, '-alu', 4, '-gname', 'fakehost', '-o'), self.testData.PINGNODE_CMD('A', 4, 0, '10.0.0.2')] @@ -2240,9 +2317,9 @@ Time Remaining: 0 second(s) self.testData.connector) self.assertTrue(iscsi_data['data']['target_lun'] == 2, "iSCSI initialize connection returned wrong HLU") - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 4, '-gname', 'fakehost', '-o', @@ -2269,7 +2346,7 @@ Time Remaining: 0 second(s) # Test for auto registration self.configuration.initiator_auto_registration = True self.configuration.max_luns_per_storage_group = 2 - commands = [('storagegroup', '-list', '-gname', 'fakehost')] + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost')] results = [ [self.testData.STORAGE_GROUP_HAS_MAP_2('fakehost'), self.testData.STORAGE_GROUP_HAS_MAP_2('fakehost')] @@ -2282,9 +2359,9 @@ Time Remaining: 0 second(s) self.testData.test_volume, self.testData.connector) expected = [ - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), ] fake_cli.assert_has_calls(expected) @@ -2314,10 +2391,6 @@ Time Remaining: 0 second(s) self.testData.connector) cli_helper.remove_hlu_from_storagegroup.assert_called_once_with( 16, self.testData.connector["host"]) -# expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost'), -# mock.call('lun', '-list', '-name', 'vol1'), -# mock.call('storagegroup', '-list', '-gname', 'fakehost'), -# mock.call('lun', '-list', '-l', '10', '-owner')] def test_create_volume_cli_failed(self): commands = [self.testData.LUN_CREATION_CMD( @@ -4083,7 +4156,7 @@ Time Remaining: 0 second(s) targets = self.driver.cli._client.find_available_iscsi_targets( 'fakehost', 'B', - {('A', 2), ('B', 1)}, + {('A', 2, 0), ('B', 1, 0)}, all_targets) self.assertEqual([port_b1, port_a2], targets) @@ -4115,14 +4188,14 @@ Time Remaining: 0 second(s) targets = self.driver.cli._client.find_available_iscsi_targets( 'fakehost', 'B', - {('A', 2), ('A', 1), ('B', 1)}, + {('A', 2, 0), ('A', 1, 0), ('B', 1, 0)}, all_targets) self.assertEqual([port_a1, port_b1, port_a2], targets) ping_node.side_effect = [False, False, True] targets = self.driver.cli._client.find_available_iscsi_targets( 'fakehost', 'B', - {('A', 2), ('A', 1), ('B', 1)}, + {('A', 2, 0), ('A', 1, 0), ('B', 1, 0)}, all_targets) self.assertEqual([port_a2, port_b1, port_a1], targets) @@ -4455,6 +4528,48 @@ class EMCVNXCLIDArrayBasedDriverTestCase(DriverTestCaseBase): 1))] fake_cli.assert_has_calls(expect_cmd) + def test_get_registered_spport_set(self): + self.driverSetup() + spport_set = self.driver.cli._client.get_registered_spport_set( + 'iqn.1993-08.org.debian:01:222', 'fakehost', + self.testData.STORAGE_GROUP_HAS_MAP_ISCSI('fakehost')[0]) + self.assertEqual({('A', 2, 0), ('A', 0, 0), ('B', 2, 0)}, spport_set) + + def test_validate_iscsi_port(self): + self.driverSetup() + port_list = ( + "SP: A\n" + "Port ID: 6\n" + "Port WWN: iqn.fake.a6\n" + "iSCSI Alias: 1111.a6\n" + "\n" + "Virtual Port ID: 0\n" + "VLAN ID: Disabled\n" + "\n" + "SP: B\n" + "Port ID: 7\n" + "Port WWN: iqn.fake.b7\n" + "iSCSI Alias: 0235.b7" + "\n" + "Virtual Port ID: 0\n" + "VLAN ID: Disabled\n" + "\n" + "Virtual Port ID: 1\n" + "VLAN ID: 200\n" + "\n\n") + self.assertFalse(self.driver.cli._validate_iscsi_port( + 'A', 5, 0, port_list)) + self.assertTrue(self.driver.cli._validate_iscsi_port( + 'A', 6, 0, port_list)) + self.assertFalse(self.driver.cli._validate_iscsi_port( + 'A', 6, 2, port_list)) + self.assertTrue(self.driver.cli._validate_iscsi_port( + 'B', 7, 1, port_list)) + self.assertTrue(self.driver.cli._validate_iscsi_port( + 'B', 7, 0, port_list)) + self.assertFalse(self.driver.cli._validate_iscsi_port( + 'B', 7, 2, port_list)) + class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): def generate_driver(self, conf): @@ -4472,7 +4587,7 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): test_volume = self.testData.test_volume.copy() test_volume['provider_location'] = 'system^fakesn|type^lun|id^1' self.configuration.initiator_auto_registration = True - commands = [('storagegroup', '-list', '-gname', 'fakehost'), + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost'), self.testData.GETFCPORT_CMD(), ('port', '-list', '-gname', 'fakehost')] results = [[("No group", 83), @@ -4485,35 +4600,23 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): test_volume, self.testData.connector) - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-create', '-gname', 'fakehost'), mock.call('port', '-list', '-sp'), - mock.call('storagegroup', '-gname', 'fakehost', - '-setpath', '-hbauid', - '22:34:56:78:90:12:34:56:12:34:56:78:' - '90:12:34:56', - '-sp', 'A', '-spport', '0', '-ip', '10.0.0.2', - '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-gname', 'fakehost', - '-setpath', '-hbauid', - '22:34:56:78:90:12:34:56:12:34:56:78:' - '90:12:34:56', - '-sp', 'B', '-spport', '2', '-ip', '10.0.0.2', - '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-gname', 'fakehost', - '-setpath', '-hbauid', - '22:34:56:78:90:54:32:16:12:34:56:78:' - '90:54:32:16', - '-sp', 'A', '-spport', '0', '-ip', '10.0.0.2', - '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-gname', 'fakehost', - '-setpath', '-hbauid', - '22:34:56:78:90:54:32:16:12:34:56:78:' - '90:54:32:16', - '-sp', 'B', '-spport', '2', '-ip', '10.0.0.2', - '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.set_path_cmd( + 'fakehost', '22:34:56:78:90:12:34:56:12:34:56:78:90' + ':12:34:56', 'A', '0', None, '10.0.0.2')), + mock.call(*self.testData.set_path_cmd( + 'fakehost', '22:34:56:78:90:12:34:56:12:34:56:78:90' + ':12:34:56', 'B', '2', None, '10.0.0.2')), + mock.call(*self.testData.set_path_cmd( + 'fakehost', '22:34:56:78:90:54:32:16:12:34:56:78:90' + ':54:32:16', 'A', '0', None, '10.0.0.2')), + mock.call(*self.testData.set_path_cmd( + 'fakehost', '22:34:56:78:90:54:32:16:12:34:56:78:90' + ':54:32:16', 'B', '2', None, '10.0.0.2')), + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', @@ -4525,7 +4628,7 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): # Test for manaul registration self.configuration.initiator_auto_registration = False - commands = [('storagegroup', '-list', '-gname', 'fakehost'), + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost'), self.testData.CONNECTHOST_CMD('fakehost', 'fakehost'), self.testData.GETFCPORT_CMD(), ('port', '-list', '-gname', 'fakehost')] @@ -4539,12 +4642,12 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): test_volume, self.testData.connector) - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-create', '-gname', 'fakehost'), mock.call('storagegroup', '-connecthost', '-host', 'fakehost', '-gname', 'fakehost', '-o'), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 1, '-alu', 1, '-gname', 'fakehost', '-o', poll=False), @@ -4562,7 +4665,7 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): # Test for auto zoning self.configuration.zoning_mode = 'fabric' self.configuration.initiator_auto_registration = False - commands = [('storagegroup', '-list', '-gname', 'fakehost'), + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost'), self.testData.CONNECTHOST_CMD('fakehost', 'fakehost'), self.testData.GETFCPORT_CMD()] results = [[("No group", 83), @@ -4582,12 +4685,12 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): conn_info['data']['initiator_target_map']) self.assertEqual(['1122334455667777'], conn_info['data']['target_wwn']) - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-create', '-gname', 'fakehost'), mock.call('storagegroup', '-connecthost', '-host', 'fakehost', '-gname', 'fakehost', '-o'), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 1, '-alu', 1, '-gname', 'fakehost', '-o', @@ -4604,7 +4707,7 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): test_volume = self.testData.test_volume.copy() test_volume['provider_location'] = 'system^fakesn|type^lun|id^1' self.configuration.initiator_auto_registration = True - commands = [('storagegroup', '-list', '-gname', 'fakehost'), + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost'), self.testData.GETFCPORT_CMD(), ('port', '-list', '-gname', 'fakehost')] results = [[("No group", 83), @@ -4617,34 +4720,22 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): test_volume, self.testData.connector) - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-create', '-gname', 'fakehost'), - mock.call('storagegroup', '-gname', 'fakehost', - '-setpath', '-hbauid', - '22:34:56:78:90:12:34:56:' - '12:34:56:78:90:12:34:56', - '-sp', 'A', '-spport', 0, '-ip', '10.0.0.2', - '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-gname', 'fakehost', - '-setpath', '-hbauid', - '22:34:56:78:90:12:34:56:' - '12:34:56:78:90:12:34:56', - '-sp', 'B', '-spport', 2, '-ip', '10.0.0.2', - '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-gname', 'fakehost', - '-setpath', '-hbauid', - '22:34:56:78:90:54:32:16:' - '12:34:56:78:90:54:32:16', - '-sp', 'A', '-spport', 0, '-ip', '10.0.0.2', - '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-gname', 'fakehost', - '-setpath', '-hbauid', - '22:34:56:78:90:54:32:16:' - '12:34:56:78:90:54:32:16', - '-sp', 'B', '-spport', 2, '-ip', '10.0.0.2', - '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.set_path_cmd( + 'fakehost', '22:34:56:78:90:12:34:56:12:34:56:78:' + '90:12:34:56', 'A', 0, None, '10.0.0.2')), + mock.call(*self.testData.set_path_cmd( + 'fakehost', '22:34:56:78:90:12:34:56:12:34:56:78:' + '90:12:34:56', 'B', 2, None, '10.0.0.2')), + mock.call(*self.testData.set_path_cmd( + 'fakehost', '22:34:56:78:90:54:32:16:12:34:56:78' + ':90:54:32:16', 'A', 0, None, '10.0.0.2')), + mock.call(*self.testData.set_path_cmd( + 'fakehost', '22:34:56:78:90:54:32:16:12:34:56:78' + ':90:54:32:16', 'B', 2, None, '10.0.0.2')), + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', @@ -4661,7 +4752,7 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): test_volume = self.testData.test_volume.copy() test_volume['provider_location'] = 'system^fakesn|type^lun|id^1' self.configuration.initiator_auto_registration = True - commands = [('storagegroup', '-list', '-gname', 'fakehost'), + commands = [self.testData.STORAGEGROUP_LIST_CMD('fakehost'), self.testData.GETFCPORT_CMD(), ('port', '-list', '-gname', 'fakehost')] results = [self.testData.STORAGE_GROUP_ISCSI_FC_HBA('fakehost'), @@ -4673,21 +4764,15 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): test_volume, self.testData.connector) - expected = [mock.call('storagegroup', '-list', '-gname', 'fakehost', + expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), - mock.call('storagegroup', '-gname', 'fakehost', - '-setpath', '-hbauid', - '22:34:56:78:90:12:34:56:' - '12:34:56:78:90:12:34:56', - '-sp', 'A', '-spport', 0, '-ip', '10.0.0.2', - '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-gname', 'fakehost', - '-setpath', '-hbauid', - '22:34:56:78:90:54:32:16:' - '12:34:56:78:90:54:32:16', - '-sp', 'A', '-spport', 0, '-ip', '10.0.0.2', - '-host', 'fakehost', '-o'), - mock.call('storagegroup', '-list', '-gname', 'fakehost', + mock.call(*self.testData.set_path_cmd( + 'fakehost', '22:34:56:78:90:12:34:56:12:34:56:78:90' + ':12:34:56', 'A', 0, None, '10.0.0.2')), + mock.call(*self.testData.set_path_cmd( + 'fakehost', '22:34:56:78:90:54:32:16:12:34:56:78:' + '90:54:32:16', 'A', 0, None, '10.0.0.2')), + mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', diff --git a/cinder/volume/drivers/emc/emc_vnx_cli.py b/cinder/volume/drivers/emc/emc_vnx_cli.py index 1d22b92fb..614372f15 100644 --- a/cinder/volume/drivers/emc/emc_vnx_cli.py +++ b/cinder/volume/drivers/emc/emc_vnx_cli.py @@ -1096,7 +1096,8 @@ class CommandLineHelper(object): 'raw_output': ''} command_get_storage_group = ('storagegroup', '-list', - '-gname', name) + '-gname', name, '-host', + '-iscsiAttributes') out, rc = self.command_execute(*command_get_storage_group, poll=poll) @@ -1561,14 +1562,14 @@ class CommandLineHelper(object): def get_registered_spport_set(self, initiator_iqn, sgname, sg_raw_out): spport_set = set() - for m_spport in re.finditer(r'\n\s+%s\s+SP\s(A|B)\s+(\d+)' % - initiator_iqn, - sg_raw_out, - flags=re.IGNORECASE): - spport_set.add((m_spport.group(1), int(m_spport.group(2)))) - LOG.debug('See path %(path)s in %(sg)s', - {'path': m_spport.group(0), - 'sg': sgname}) + for m_spport in re.finditer( + r'\n\s+%s\s+SP\s.*\n.*\n\s*SPPort:\s+(A|B)-(\d+)v(\d+)\s*\n' + % initiator_iqn, sg_raw_out, flags=re.IGNORECASE): + spport_set.add((m_spport.group(1), int(m_spport.group(2)), + int(m_spport.group(3)))) + LOG.debug('See path %(path)s in %(sg)s.', + {'path': spport_set, + 'sg': sgname}) return spport_set def ping_node(self, target_portal, initiator_ip): @@ -1620,7 +1621,9 @@ class CommandLineHelper(object): sp_portals = all_iscsi_targets[target_sp] random.shuffle(sp_portals) for portal in sp_portals: - spport = (portal['SP'], portal['Port ID']) + spport = (portal['SP'], + portal['Port ID'], + portal['Virtual Port ID']) if spport not in registered_spport_set: LOG.debug( "Skip SP Port %(port)s since " @@ -1903,14 +1906,16 @@ class EMCVnxCliBase(object): raise exception.VolumeBackendAPIException(data=msg) return valid_ports - def _validate_iscsi_port(self, sp, port_id, vlan_id, cmd_output): - """Validates whether the iSCSI port is existed on VNX""" - iscsi_pattern = ('SP:\s+' + sp.upper() + - '\nPort ID:\s+' + str(port_id) + - '\nPort WWN:\s+.*' + - '\niSCSI Alias:\s+.*\n' - '\nVirtual Port ID:\s+' + str(vlan_id)) - return re.search(iscsi_pattern, cmd_output) + def _validate_iscsi_port(self, sp, port_id, vport_id, cmd_output): + """Validates whether the iSCSI port is existed on VNX.""" + sp_port_pattern = (r'SP:\s+%(sp)s\nPort ID:\s+%(port_id)s\n' % + {'sp': sp.upper(), 'port_id': port_id}) + sp_port_fields = re.split(sp_port_pattern, cmd_output) + if len(sp_port_fields) < 2: + return False + sp_port_info = re.split('SP:\s+(A|B)', sp_port_fields[1])[0] + vport_pattern = '\nVirtual Port ID:\s+%s\nVLAN ID:' % vport_id + return re.search(vport_pattern, sp_port_info) is not None def _validate_fc_port(self, sp, port_id, cmd_output): """Validates whether the FC port is existed on VNX""" @@ -2884,13 +2889,13 @@ class EMCVnxCliBase(object): ip, host, vport_id=None): gname = host if vport_id is not None: - cmd_iscsi_setpath = ('storagegroup', '-gname', gname, '-setpath', + cmd_iscsi_setpath = ('storagegroup', '-setpath', '-gname', gname, '-hbauid', initiator_uid, '-sp', sp, '-spport', port_id, '-spvport', vport_id, '-ip', ip, '-host', host, '-o') out, rc = self._client.command_execute(*cmd_iscsi_setpath) else: - cmd_fc_setpath = ('storagegroup', '-gname', gname, '-setpath', + cmd_fc_setpath = ('storagegroup', '-setpath', '-gname', gname, '-hbauid', initiator_uid, '-sp', sp, '-spport', port_id, '-ip', ip, '-host', host, '-o') @@ -2917,7 +2922,9 @@ class EMCVnxCliBase(object): # Normalize io_ports for sp in ('A', 'B'): new_ports = filter( - lambda pt: (pt['SP'], pt['Port ID']) not in sp_ports, + lambda pt: (pt['SP'], pt['Port ID'], + pt['Virtual Port ID']) + not in sp_ports, self.iscsi_targets[sp]) new_white[sp] = map(lambda white: {'SP': white['SP'],