]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add initiator target map in EMC SMI-S FC driver.
authorXing Yang <xing.yang@emc.com>
Sun, 2 Mar 2014 04:45:45 +0000 (23:45 -0500)
committerXing Yang <xing.yang@emc.com>
Sun, 2 Mar 2014 04:50:00 +0000 (23:50 -0500)
This patch add the initiator target map in initialize_connection
and terminate_connection as it is required by the FC Zone Manager.

Change-Id: I84729968b8e4e6ee74536fb28d3d921a9baf9f6e
Closes-Bug: #1286694

cinder/tests/test_emc_smis.py [moved from cinder/tests/test_emc.py with 96% similarity]
cinder/volume/drivers/emc/emc_smis_fc.py

similarity index 96%
rename from cinder/tests/test_emc.py
rename to cinder/tests/test_emc_smis.py
index 1496dfe04a1b585b3b289038722fcb576159d492..7e5a7ccc24d3f004520c1cd101bbaeeee7019d46 100644 (file)
@@ -1186,17 +1186,58 @@ class EMCSMISFCDriverTestCase(test.TestCase):
         self.data.test_volume['volume_type_id'] = None
         self.driver.create_volume(self.data.test_volume)
 
-        output = {'driver_volume_type': 'fibre_channel',
-                  'data': {'target_lun': 0,
-                           'target_wwn': ['1234567890123', '0987654321321'],
-                           'target_discovered': True}}
+        output = {
+            'driver_volume_type': 'fibre_channel',
+            'data': {
+                'target_lun': 0,
+                'target_wwn': ['1234567890123', '0987654321321'],
+                'target_discovered': True,
+                'initiator_target_map': {'123456789012345':
+                                         ['1234567890123', '0987654321321'],
+                                         '123456789054321':
+                                         ['1234567890123', '0987654321321'],
+                                         }}}
+
         connection_info = self.driver.initialize_connection(
             self.data.test_volume,
             self.data.connector)
         self.assertEqual(connection_info, output)
 
-        self.driver.terminate_connection(self.data.test_volume,
-                                         self.data.connector)
+        connection_info = self.driver.terminate_connection(
+            self.data.test_volume,
+            self.data.connector)
+
+        # Verify calls in terminate_connection are executed
+        conf_service = {}
+        conf_service['SystemName'] = self.data.storage_system
+        conf_service['CreationClassName'] =\
+            self.data.ctrlconf_service_creationclass
+
+        vol_instance = self.driver.common._find_lun(self.data.test_volume)
+
+        expected = [
+            mock.call._get_ecom_connection(),
+            mock.call.find_device_number(self.data.test_volume),
+            mock.call._find_lun(self.data.test_volume),
+            mock.call.self._find_controller_configuration_service(
+                self.data.storage_system),
+            mock.call._remove_members(conf_service, vol_instance),
+            mock.call.get_target_wwns(
+                self.data.storage_system,
+                self.data.connector)]
+
+        output = {
+            'driver_volume_type': 'fibre_channel',
+            'data': {
+                'target_wwn': ['1234567890123', '0987654321321'],
+                'initiator_target_map': {'123456789012345':
+                                         ['1234567890123', '0987654321321'],
+                                         '123456789054321':
+                                         ['1234567890123', '0987654321321'],
+                                         }}}
+
+        self.assertEqual(connection_info, output)
+
         self.driver.delete_volume(self.data.test_volume)
 
     def test_create_volume_failed(self):
index 742044937c26d9d44a98379da79ed962737912f1..d05800b4562700109ded6193adf0aafa36c53124 100644 (file)
@@ -157,12 +157,14 @@ class EMCSMISFCDriver(driver.FibreChannelDriver):
                                                         connector)
         device_number = device_info['hostlunid']
         storage_system = device_info['storagesystem']
-        ports = self.common.get_target_wwns(storage_system, connector)
+        target_wwns, init_targ_map = self._build_initiator_target_map(
+            storage_system, connector)
 
         data = {'driver_volume_type': 'fibre_channel',
                 'data': {'target_lun': device_number,
                          'target_discovered': True,
-                         'target_wwn': ports}}
+                         'target_wwn': target_wwns,
+                         'initiator_target_map': init_targ_map}}
 
         LOG.debug(_('Return FC data: %(data)s.')
                   % {'data': data})
@@ -173,6 +175,33 @@ class EMCSMISFCDriver(driver.FibreChannelDriver):
         """Disallow connection from connector."""
         self.common.terminate_connection(volume, connector)
 
+        loc = volume['provider_location']
+        name = eval(loc)
+        storage_system = name['keybindings']['SystemName']
+        target_wwns, init_targ_map = self._build_initiator_target_map(
+            storage_system, connector)
+        data = {'driver_volume_type': 'fibre_channel',
+                'data': {'target_wwn': target_wwns,
+                         'initiator_target_map': init_targ_map}}
+
+        LOG.debug(_('Return FC data: %(data)s.')
+                  % {'data': data})
+
+        return data
+
+    def _build_initiator_target_map(self, storage_system, connector):
+        """Build the target_wwns and the initiator target map."""
+
+        target_wwns = self.common.get_target_wwns(storage_system, connector)
+
+        initiator_wwns = connector['wwpns']
+
+        init_targ_map = {}
+        for initiator in initiator_wwns:
+            init_targ_map[initiator] = target_wwns
+
+        return target_wwns, init_targ_map
+
     def extend_volume(self, volume, new_size):
         """Extend an existing volume."""
         self.common.extend_volume(volume, new_size)