]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add I/T mapping check for IBM FlashSystem
authorEdwin Wang <edwin@oohoo.org>
Mon, 20 Jul 2015 12:25:25 +0000 (20:25 +0800)
committerEdwin Wang <edwin.wang@cn.ibm.com>
Fri, 24 Jul 2015 02:46:46 +0000 (10:46 +0800)
No initiator_target_map within properties is needed if no more I/T
connection. Otherwise the FCZone manager will remove the zoning
between I/T. This patch is to add host check in terminate_connection.
If no I/T exists, host will be removed in _unmap_vdisk_from_host.

Closes-Bug: #1469581
Change-Id: Ide5d2f5cb3557bd167f065fc168722c143f8f267

cinder/tests/unit/test_ibm_flashsystem.py
cinder/volume/drivers/ibm/flashsystem_common.py
cinder/volume/drivers/ibm/flashsystem_fc.py
cinder/volume/drivers/ibm/flashsystem_iscsi.py

index 48b79b60f4ad99c903bd12584a0d62a578aaa928..231be396a82861fb1c29479ab0567955212a307e 100644 (file)
@@ -885,8 +885,34 @@ class FlashSystemDriverTestCase(test.TestCase):
                               self.driver.initialize_connection,
                               vol1, self.connector)
 
+        # case 4: terminate_connection with no host
+        with mock.patch.object(flashsystem_fc.FlashSystemFCDriver,
+                               '_get_hostvdisk_mappings') as mock_host:
+            mock_host.return_value = {}
+            vol3 = self._generate_vol_info(None)
+            self.driver.create_volume(vol3)
+            self.driver.initialize_connection(vol3, self.connector)
+            return_value = self.driver.terminate_connection(vol3,
+                                                            self.connector)
+            self.assertNotEqual({}, return_value['data'])
+
+        # case 5: terminate_connection with host
+        vol4 = self._generate_vol_info(None)
+        self.driver.create_volume(vol4)
+        self.driver.initialize_connection(vol4, self.connector)
+        vol5 = self._generate_vol_info(None)
+        self.driver.create_volume(vol5)
+        self.driver.initialize_connection(vol5, self.connector)
+        return_value = self.driver.terminate_connection(vol4,
+                                                        self.connector)
+        self.assertEqual({}, return_value['data'])
+
         # clear environment
         self.driver.delete_volume(vol1)
+        self.driver.delete_volume(vol2)
+        self.driver.delete_volume(vol3)
+        self.driver.delete_volume(vol4)
+        self.driver.delete_volume(vol5)
 
     @mock.patch.object(flashsystem_fc.FlashSystemFCDriver,
                        '_create_and_copy_vdisk_data')
index 678eecb8a5843bc61116d9575eba3536e56e2e32..87562f82dbf5d9e2457b6d5a9035be2716aa918c 100644 (file)
@@ -73,10 +73,12 @@ class FlashSystemDriver(san.SanDriver):
     1.0.3 - Initial driver for iSCSI
     1.0.4 - Split Flashsystem driver into common and FC
     1.0.5 - Report capability of volume multiattach
+    1.0.6 - Fix bug #1469581, add I/T mapping check in
+            terminate_connection
 
     """
 
-    VERSION = "1.0.5"
+    VERSION = "1.0.6"
 
     def __init__(self, *args, **kwargs):
         super(FlashSystemDriver, self).__init__(*args, **kwargs)
index 329b0207fef2dec9757595ad92500154b1a20477..3f0a63cfe1e3c7ad4303796dff0fcf3adc94def1 100644 (file)
@@ -64,10 +64,12 @@ class FlashSystemFCDriver(fscommon.FlashSystemDriver,
     1.0.3 - Initial driver for iSCSI
     1.0.4 - Split Flashsystem driver into common and FC
     1.0.5 - Report capability of volume multiattach
+    1.0.6 - Fix bug #1469581, add I/T mapping check in
+            terminate_connection
 
     """
 
-    VERSION = "1.0.5"
+    VERSION = "1.0.6"
 
     def __init__(self, *args, **kwargs):
         super(FlashSystemFCDriver, self).__init__(*args, **kwargs)
@@ -317,27 +319,30 @@ class FlashSystemFCDriver(fscommon.FlashSystemDriver,
             'connector %(conn)s.',
             {'vol': volume, 'conn': connector})
 
+        return_data = {
+            'driver_volume_type': 'fibre_channel',
+            'data': {},
+        }
+
         vdisk_name = volume['name']
         self._wait_vdisk_copy_completed(vdisk_name)
         self._unmap_vdisk_from_host(vdisk_name, connector)
 
-        properties = {}
-        conn_wwpns = self._get_conn_fc_wwpns()
-        properties['target_wwn'] = conn_wwpns
-        # TODO(edwin): add judgement here. No initiator_target_map within
-        # properties need if no more I/T connection. Otherwise the FCZone
-        # manager will remove the zoning between I/T.
-        properties['initiator_target_map'] = self._build_initiator_target_map(
-            connector['wwpns'], conn_wwpns)
+        host_name = self._get_host_from_connector(connector)
+        if not host_name:
+            properties = {}
+            conn_wwpns = self._get_conn_fc_wwpns()
+            properties['target_wwn'] = conn_wwpns
+            properties['initiator_target_map'] = (
+                self._build_initiator_target_map(
+                    connector['wwpns'], conn_wwpns))
+            return_data['data'] = properties
 
         LOG.debug(
             'leave: terminate_connection: volume %(vol)s with '
             'connector %(conn)s.', {'vol': volume, 'conn': connector})
 
-        return {
-            'driver_volume_type': 'fibre_channel',
-            'data': properties
-        }
+        return return_data
 
     def do_setup(self, ctxt):
         """Check that we have all configuration details from the storage."""
index 5634a0b2025496d0e61ea407656695e63d4a1307..edec1082e32ab1fc967852742a8beddc517f408b 100644 (file)
@@ -63,10 +63,12 @@ class FlashSystemISCSIDriver(fscommon.FlashSystemDriver,
     1.0.3 - Initial driver for iSCSI
     1.0.4 - Split Flashsystem driver into common and FC
     1.0.5 - Report capability of volume multiattach
+    1.0.6 - Fix bug #1469581, add I/T mapping check in
+            terminate_connection
 
     """
 
-    VERSION = "1.0.5"
+    VERSION = "1.0.6"
 
     def __init__(self, *args, **kwargs):
         super(FlashSystemISCSIDriver, self).__init__(*args, **kwargs)