From 89a9703042a1b4849adbbf31af23cfaa31590269 Mon Sep 17 00:00:00 2001 From: Lee Date: Tue, 23 Jun 2015 15:20:20 +0800 Subject: [PATCH] Fix getting wwpn information in infortrend driver for DS4000 For DS4000, we need to use 'BID' to get the wwpn information because target ID was not 112 or 113 on DS4000. It is compatible with other infortrend product. Closes-Bug: 1469983 Change-Id: I230f79c1efe78bc49edb81ab605a2c70ffbdd31c --- cinder/tests/unit/test_infortrend_cli.py | 86 +++++++++++++++++++ cinder/tests/unit/test_infortrend_common.py | 50 +++++++++++ .../infortrend/eonstor_ds_cli/common_cli.py | 5 +- .../drivers/infortrend/infortrend_fc_cli.py | 1 + .../infortrend/infortrend_iscsi_cli.py | 1 + 5 files changed, 141 insertions(+), 2 deletions(-) diff --git a/cinder/tests/unit/test_infortrend_cli.py b/cinder/tests/unit/test_infortrend_cli.py index 9573c6385..ba96b96ff 100644 --- a/cinder/tests/unit/test_infortrend_cli.py +++ b/cinder/tests/unit/test_infortrend_cli.py @@ -1538,6 +1538,69 @@ Return: 0x0000 """ return msg + def get_test_show_channel_r_model_diff_target_id(self): + return (0, [{ + 'Mode': 'Host', + 'AID': '32', + 'defClock': 'Auto', + 'MCS': 'N/A', + 'Ch': '0', + 'BID': '33', + 'curClock': '---', + 'Width': '---', + 'Type': 'FIBRE', + }, { + 'Mode': 'Host', + 'AID': '0', + 'defClock': 'Auto', + 'MCS': '0', + 'Ch': '1', + 'BID': '1', + 'curClock': '---', + 'Width': 'iSCSI', + 'Type': 'NETWORK', + }, { + 'Mode': 'Host', + 'AID': '0', + 'defClock': 'Auto', + 'MCS': '1', + 'Ch': '2', + 'BID': '1', + 'curClock': '---', + 'Width': 'iSCSI', + 'Type': 'NETWORK', + }, { + 'Mode': 'Drive', + 'AID': '---', + 'defClock': '6.0 Gbps', + 'MCS': 'N/A', + 'Ch': '3', + 'BID': '---', + 'curClock': '6.0 Gbps', + 'Width': 'SAS', + 'Type': 'SAS', + }, { + 'Mode': 'Host', + 'AID': '0', + 'defClock': 'Auto', + 'MCS': '2', + 'Ch': '4', + 'BID': '1', + 'curClock': '---', + 'Width': 'iSCSI', + 'Type': 'NETWORK', + }, { + 'Mode': 'Host', + 'AID': '48', + 'defClock': 'Auto', + 'MCS': 'N/A', + 'Ch': '5', + 'BID': '49', + 'curClock': '---', + 'Width': '---', + 'Type': 'FIBRE', + }]) + def get_test_show_channel_r_model(self): return (0, [{ 'Mode': 'Host', @@ -1820,6 +1883,29 @@ Return: 0x0000 'WWNN': self.fake_target_wwnns[0], }]) + def get_test_show_wwn_with_diff_target_id(self): + return (0, [{ + 'ID': 'AID:32', + 'WWPN': self.fake_target_wwpns[0], + 'CH': '0', + 'WWNN': self.fake_target_wwnns[0], + }, { + 'ID': 'BID:33', + 'WWPN': self.fake_target_wwpns[2], + 'CH': '0', + 'WWNN': self.fake_target_wwnns[1], + }, { + 'ID': 'AID:48', + 'WWPN': self.fake_target_wwpns[1], + 'CH': '5', + 'WWNN': self.fake_target_wwnns[0], + }, { + 'ID': 'BID:49', + 'WWPN': self.fake_target_wwpns[3], + 'CH': '5', + 'WWNN': self.fake_target_wwnns[1], + }]) + def get_test_show_wwn(self): return (0, [{ 'ID': 'AID:112', diff --git a/cinder/tests/unit/test_infortrend_common.py b/cinder/tests/unit/test_infortrend_common.py index 65600cb23..a400e2dfa 100644 --- a/cinder/tests/unit/test_infortrend_common.py +++ b/cinder/tests/unit/test_infortrend_common.py @@ -356,6 +356,56 @@ class InfortrendFCCommonTestCase(InfortrendTestCass): self.assertDictMatch( properties, self.cli_data.test_fc_properties_zoning_r_model) + @mock.patch.object(common_cli.LOG, 'info', mock.Mock()) + def test_initialize_connection_with_zoning_r_model_diff_target_id(self): + + test_volume = self.cli_data.test_volume + test_connector = self.cli_data.test_connector_fc + test_initiator_wwpns = test_connector['wwpns'] + test_partition_id = self.cli_data.fake_partition_id[0] + test_all_target_wwpns = self.cli_data.fake_target_wwpns[:] + test_all_target_wwpns[1] = self.cli_data.fake_target_wwpns[2] + test_all_target_wwpns[2] = self.cli_data.fake_target_wwpns[1] + test_lookup_map = self.cli_data.fake_lookup_map_r_model + + mock_commands = { + 'ShowChannel': + self.cli_data.get_test_show_channel_r_model_diff_target_id(), + 'ShowMap': self.cli_data.get_test_show_map(), + 'CreateMap': SUCCEED, + 'ShowWWN': self.cli_data.get_test_show_wwn_with_diff_target_id(), + } + self._driver_setup(mock_commands) + self.driver.fc_lookup_service = mock.Mock() + get_device_mapping_from_network = ( + self.driver.fc_lookup_service.get_device_mapping_from_network + ) + get_device_mapping_from_network.return_value = test_lookup_map + + properties = self.driver.initialize_connection( + test_volume, test_connector) + + get_device_mapping_from_network.assert_has_calls( + [mock.call(test_connector['wwpns'], test_all_target_wwpns)]) + + expect_cli_cmd = [ + mock.call('ShowChannel'), + mock.call('ShowMap'), + mock.call('ShowWWN'), + mock.call('CreateMap', 'part', test_partition_id, '5', '48', '0', + 'wwn=%s' % test_initiator_wwpns[0]), + mock.call('CreateMap', 'part', test_partition_id, '0', '33', '0', + 'wwn=%s' % test_initiator_wwpns[0]), + mock.call('CreateMap', 'part', test_partition_id, '5', '48', '0', + 'wwn=%s' % test_initiator_wwpns[1]), + mock.call('CreateMap', 'part', test_partition_id, '0', '33', '0', + 'wwn=%s' % test_initiator_wwpns[1]), + ] + self._assert_cli_has_calls(expect_cli_cmd) + + self.assertDictMatch( + properties, self.cli_data.test_fc_properties_zoning_r_model) + @mock.patch.object(common_cli.LOG, 'info', mock.Mock()) def test_terminate_connection(self): diff --git a/cinder/volume/drivers/infortrend/eonstor_ds_cli/common_cli.py b/cinder/volume/drivers/infortrend/eonstor_ds_cli/common_cli.py index 59502826a..a382b6aca 100644 --- a/cinder/volume/drivers/infortrend/eonstor_ds_cli/common_cli.py +++ b/cinder/volume/drivers/infortrend/eonstor_ds_cli/common_cli.py @@ -155,9 +155,10 @@ class InfortrendCommon(object): Version history: 1.0.0 - Initial driver + 1.0.1 - Support DS4000 """ - VERSION = '1.0.0' + VERSION = '1.0.1' constants = { 'ISCSI_PORT': 3260, @@ -1466,7 +1467,7 @@ class InfortrendCommon(object): for entry in wwn_list: channel_id = entry['CH'] - if 'BID:113' == entry['ID']: + if 'BID' in entry['ID']: slot_name = 'slot_b' else: slot_name = 'slot_a' diff --git a/cinder/volume/drivers/infortrend/infortrend_fc_cli.py b/cinder/volume/drivers/infortrend/infortrend_fc_cli.py index 42514a6db..013517609 100644 --- a/cinder/volume/drivers/infortrend/infortrend_fc_cli.py +++ b/cinder/volume/drivers/infortrend/infortrend_fc_cli.py @@ -32,6 +32,7 @@ class InfortrendCLIFCDriver(driver.FibreChannelDriver): Version history: 1.0.0 - Initial driver + 1.0.1 - Support DS4000 """ def __init__(self, *args, **kwargs): diff --git a/cinder/volume/drivers/infortrend/infortrend_iscsi_cli.py b/cinder/volume/drivers/infortrend/infortrend_iscsi_cli.py index 6c8622871..96209b853 100644 --- a/cinder/volume/drivers/infortrend/infortrend_iscsi_cli.py +++ b/cinder/volume/drivers/infortrend/infortrend_iscsi_cli.py @@ -30,6 +30,7 @@ class InfortrendCLIISCSIDriver(driver.ISCSIDriver): Version history: 1.0.0 - Initial driver + 1.0.1 - Support DS4000 """ def __init__(self, *args, **kwargs): -- 2.45.2