]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix getting wwpn information in infortrend driver for DS4000
authorLee <jessy1092@gmail.com>
Tue, 23 Jun 2015 07:20:20 +0000 (15:20 +0800)
committerJessy Lee <jessy1092@gmail.com>
Tue, 30 Jun 2015 07:48:20 +0000 (07:48 +0000)
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
cinder/tests/unit/test_infortrend_common.py
cinder/volume/drivers/infortrend/eonstor_ds_cli/common_cli.py
cinder/volume/drivers/infortrend/infortrend_fc_cli.py
cinder/volume/drivers/infortrend/infortrend_iscsi_cli.py

index 9573c6385b20c86d41be6c2a527c2abe14c00c48..ba96b96ffe0f31d0868982a78e71bb19259cc3a5 100644 (file)
@@ -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',
index 65600cb236f8e36d6bf3f87769de8c9b52991d9b..a400e2dfab2d473333aaa25ccb9d415218936d74 100644 (file)
@@ -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):
 
index 59502826a8bc50547b34c645539522abc2d5f3fd..a382b6aca95854d6c5d75e5994c88cac3bcc6cb2 100644 (file)
@@ -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'
index 42514a6db41080bc63b7d1ff0ecf39219e03c252..0135176098990f92e15bbbe900f6f1431b724dc8 100644 (file)
@@ -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):
index 6c86228712b3ff2a85d78a2821728bd4ce906417..96209b853fb523598f4487735d5cae99927c0064 100644 (file)
@@ -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):