]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Storwize/SVC driver detach volume failed
authorLi Min Liu <liminliu@cn.ibm.com>
Tue, 22 Apr 2014 02:56:54 +0000 (10:56 +0800)
committerLi Min Liu <liminliu@cn.ibm.com>
Sun, 27 Apr 2014 06:32:13 +0000 (14:32 +0800)
If config two backends on the same storage, but the protocol is
different, one is FC and the other is iSCSI,  that will create two
hosts on the storage.

When detaching the volume which is attached to the iSCSI host, the
driver will get FC host by default, that causes volume status keeps
'detaching'.

Change-Id: Idbdb3861574197549625b4a6b6141197e42857ff
Closes-Bug: #1310559

cinder/tests/test_storwize_svc.py
cinder/volume/drivers/ibm/storwize_svc/__init__.py

index 1b747854ad23987988515e65e0ae8e3af1fe8c27..39a06dfab1dcef62580c52a2c746ef9bfaad9fc2 100644 (file)
@@ -2398,15 +2398,13 @@ class StorwizeSVCDriverTestCase(test.TestCase):
             self.assertNotIn(volume['id'], self.driver._vdiskcopyops)
 
     def test_storwize_initiator_multiple_preferred_nodes_matching(self):
-        # Set the context.
-        ctxt = context.get_admin_context()
 
         # Generate us a test volume
-        volume = self._generate_vol_info(None, None)
-        self.driver.create_volume(volume)
+        volume = self._create_volume()
 
         # Fibre Channel volume type
-        vol_type = volume_types.create(ctxt, 'FC', {'protocol': 'FC'})
+        extra_spec = {'capabilities:storage_protocol': '<in> FC'}
+        vol_type = volume_types.create(self.ctxt, 'FC', extra_spec)
 
         volume['volume_type_id'] = vol_type['id']
 
@@ -2435,15 +2433,12 @@ class StorwizeSVCDriverTestCase(test.TestCase):
                              'AABBCCDDEEFF0010')
 
     def test_storwize_initiator_multiple_preferred_nodes_no_matching(self):
-        # Set the context.
-        ctxt = context.get_admin_context()
-
         # Generate us a test volume
-        volume = self._generate_vol_info(None, None)
-        self.driver.create_volume(volume)
+        volume = self._create_volume()
 
         # Fibre Channel volume type
-        vol_type = volume_types.create(ctxt, 'FC', {'protocol': 'FC'})
+        extra_spec = {'capabilities:storage_protocol': '<in> FC'}
+        vol_type = volume_types.create(self.ctxt, 'FC', extra_spec)
 
         volume['volume_type_id'] = vol_type['id']
 
@@ -2472,15 +2467,12 @@ class StorwizeSVCDriverTestCase(test.TestCase):
                              'AABBCCDDEEFF0001')
 
     def test_storwize_initiator_single_preferred_node_matching(self):
-        # Set the context
-        ctxt = context.get_admin_context()
-
         # Generate us a test volume
-        volume = self._generate_vol_info(None, None)
-        self.driver.create_volume(volume)
+        volume = self._create_volume()
 
         # Fibre Channel volume type
-        vol_type = volume_types.create(ctxt, 'FC', {'protocol': 'FC'})
+        extra_spec = {'capabilities:storage_protocol': '<in> FC'}
+        vol_type = volume_types.create(self.ctxt, 'FC', extra_spec)
 
         volume['volume_type_id'] = vol_type['id']
 
@@ -2507,16 +2499,36 @@ class StorwizeSVCDriverTestCase(test.TestCase):
             self.assertEqual(init_ret['data']['target_wwn'],
                              'AABBCCDDEEFF0012')
 
-    def test_storwize_initiator_target_map(self):
-        # Create two volumes to be used in mappings
-        ctxt = context.get_admin_context()
+    def test_storwize_terminate_connection(self):
+        # create a FC volume
+        volume_fc = self._create_volume()
+        extra_spec = {'capabilities:storage_protocol': '<in> FC'}
+        vol_type_fc = volume_types.create(self.ctxt, 'FC', extra_spec)
+        volume_fc['volume_type_id'] = vol_type_fc['id']
+
+        # create a iSCSI volume
+        volume_iSCSI = self._create_volume()
+        extra_spec = {'capabilities:storage_protocol': '<in> iSCSI'}
+        vol_type_iSCSI = volume_types.create(self.ctxt, 'iSCSI', extra_spec)
+        volume_iSCSI['volume_type_id'] = vol_type_iSCSI['id']
+
+        connector = {'host': 'storwize-svc-host',
+                     'wwnns': ['20000090fa17311e', '20000090fa17311f'],
+                     'wwpns': ['ff00000000000000', 'ff00000000000001'],
+                     'initiator': 'iqn.1993-08.org.debian:01:eac5ccc1aaa'}
+
+        self.driver.initialize_connection(volume_fc, connector)
+        self.driver.initialize_connection(volume_iSCSI, connector)
+        self.driver.terminate_connection(volume_iSCSI, connector)
+        self.driver.terminate_connection(volume_fc, connector)
 
+    def test_storwize_initiator_target_map(self):
         # Generate us a test volume
-        volume = self._generate_vol_info(None, None)
-        self.driver.create_volume(volume)
+        volume = self._create_volume()
 
         # FIbre Channel volume type
-        vol_type = volume_types.create(ctxt, 'FC', {'protocol': 'FC'})
+        extra_spec = {'capabilities:storage_protocol': '<in> FC'}
+        vol_type = volume_types.create(self.ctxt, 'FC', extra_spec)
 
         volume['volume_type_id'] = vol_type['id']
 
index b1f26f947a3af5ae6ffa7f8a388b26613b6f83ad..e2bd9ea9b7ce40e216a6edf96280926e34b3b465 100644 (file)
@@ -471,6 +471,16 @@ class StorwizeSVCDriver(san.SanDriver):
 
         vol_name = volume['name']
         if 'host' in connector:
+            # maybe two hosts on the storage, one is for FC and the other for
+            # iSCSI, so get host according to protocol
+            vol_opts = self._get_vdisk_params(volume['volume_type_id'])
+            connector = connector.copy()
+            if vol_opts['protocol'] == 'FC':
+                connector.pop('initiator', None)
+            elif vol_opts['protocol'] == 'iSCSI':
+                connector.pop('wwnns', None)
+                connector.pop('wwpns', None)
+
             host_name = self._helpers.get_host_from_connector(connector)
             if host_name is None:
                 msg = (_('terminate_connection: Failed to get host name from'