From: Xi Yang Date: Wed, 9 Sep 2015 08:26:20 +0000 (-0400) Subject: Attaching enhancement for EMC VNX driver X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=e48f293001fb776b49991c959ef9da545a4f0cdd;p=openstack-build%2Fcinder-build.git Attaching enhancement for EMC VNX driver Remove the lun list command after adding the lun into a storage group. This could improve the performance of initialize connection. Change-Id: Id49725f50cd0e7600feb2ffc98a5b1ef14bc531c Closes-Bug: #1495806 --- diff --git a/cinder/tests/unit/test_emc_vnxdirect.py b/cinder/tests/unit/test_emc_vnxdirect.py index d5143225a..7e48f003e 100644 --- a/cinder/tests/unit/test_emc_vnxdirect.py +++ b/cinder/tests/unit/test_emc_vnxdirect.py @@ -2054,8 +2054,6 @@ Time Remaining: 0 second(s) mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', poll=False), - mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'), - poll=False), mock.call(*self.testData.PINGNODE_CMD('A', 4, 0, '10.0.0.2'))] fake_cli.assert_has_calls(expected) @@ -2090,8 +2088,6 @@ Time Remaining: 0 second(s) poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', poll=False), - mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'), - poll=False), mock.call(*self.testData.PINGNODE_CMD('A', 4, 0, '10.0.0.2'))] fake_cli.assert_has_calls(expected) @@ -2123,9 +2119,7 @@ Time Remaining: 0 second(s) mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, - '-gname', 'fakehost', '-o', poll=False), - mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'), - poll=False)] + '-gname', 'fakehost', '-o', poll=False)] fake_cli.assert_has_calls(expected) @mock.patch('random.randint', @@ -2167,9 +2161,7 @@ Time Remaining: 0 second(s) expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=False), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, - '-gname', 'fakehost', '-o', poll=False), - mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'), - poll=False)] + '-gname', 'fakehost', '-o', poll=False)] fake_cli.assert_has_calls(expected) @mock.patch( @@ -2216,8 +2208,6 @@ Time Remaining: 0 second(s) poll=False), mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'), poll=True), - mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'), - poll=False), mock.call(*self.testData.PINGNODE_CMD('A', 4, 0, '10.0.0.2'))] fake_cli.assert_has_calls(expected) @@ -2258,8 +2248,6 @@ Time Remaining: 0 second(s) poll=True), mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1, '-gname', 'fakehost', '-o', - poll=False), - mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'), poll=False)] fake_cli.assert_has_calls(expected) @@ -2331,8 +2319,6 @@ Time Remaining: 0 second(s) mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 4, '-gname', 'fakehost', '-o', poll=False), - mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'), - poll=False), mock.call(*self.testData.PINGNODE_CMD('A', 4, 0, u'10.0.0.2'))] fake_cli.assert_has_calls(expected) @@ -4162,12 +4148,11 @@ Time Remaining: 0 second(s) 'B': [port_b1]} targets = self.driver.cli._client.find_available_iscsi_targets( 'fakehost', - 'B', {('A', 2, 0), ('B', 1, 0)}, all_targets) - self.assertEqual([port_b1, port_a2], targets) + self.assertTrue(port_a2 in targets) + self.assertTrue(port_b1 in targets) - @mock.patch("random.shuffle", mock.Mock()) @mock.patch.object(emc_vnx_cli.CommandLineHelper, 'ping_node') def test_find_available_iscsi_targets_with_pingnode(self, ping_node): @@ -4191,20 +4176,14 @@ Time Remaining: 0 second(s) 'IP Address': 'fake_ip_b1'} all_targets = {'A': [port_a1, port_a2], 'B': [port_b1]} - ping_node.side_effect = [False, True] - targets = self.driver.cli._client.find_available_iscsi_targets( - 'fakehost', - 'B', - {('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, 0), ('A', 1, 0), ('B', 1, 0)}, all_targets) - self.assertEqual([port_a2, port_b1, port_a1], targets) + self.assertTrue(port_a1 in targets) + self.assertTrue(port_a2 in targets) + self.assertTrue(port_b1 in targets) @mock.patch('cinder.volume.drivers.emc.emc_vnx_cli.' 'EMCVnxCliBase.get_lun_owner', diff --git a/cinder/volume/drivers/emc/emc_vnx_cli.py b/cinder/volume/drivers/emc/emc_vnx_cli.py index b16624c5b..f56220aae 100644 --- a/cinder/volume/drivers/emc/emc_vnx_cli.py +++ b/cinder/volume/drivers/emc/emc_vnx_cli.py @@ -1591,7 +1591,6 @@ class CommandLineHelper(object): return False def find_available_iscsi_targets(self, hostname, - preferred_sp, registered_spport_set, all_iscsi_targets): """Finds available iscsi targets for a host. @@ -1610,28 +1609,22 @@ class CommandLineHelper(object): else: iscsi_initiator_ips = None - # Check the targets on the owner first - if preferred_sp == 'A': - target_sps = ('A', 'B') - else: - target_sps = ('B', 'A') - target_portals = [] - for target_sp in target_sps: - sp_portals = all_iscsi_targets[target_sp] - random.shuffle(sp_portals) - for portal in sp_portals: - 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 " - "no path from %(host)s is through it.", - {'port': spport, - 'host': hostname}) - continue - target_portals.append(portal) + + all_portals = all_iscsi_targets['A'] + all_iscsi_targets['B'] + random.shuffle(all_portals) + for portal in all_portals: + 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 " + "no path from %(host)s is through it.", + {'port': spport, + 'host': hostname}) + continue + target_portals.append(portal) main_portal_index = None if iscsi_initiator_ips: @@ -3192,13 +3185,12 @@ class EMCVnxCliBase(object): def vnx_get_iscsi_properties(self, volume, connector, hlu, sg_raw_output): storage_group = connector['host'] - owner_sp = self.get_lun_owner(volume) registered_spports = self._client.get_registered_spport_set( connector['initiator'], storage_group, sg_raw_output) targets = self._client.find_available_iscsi_targets( - storage_group, owner_sp, + storage_group, registered_spports, self.iscsi_targets) properties = {'target_discovered': False,