]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
IBM Storwize:Failed to retype from non-type to replication enable
authorTaoBai <baitaosh@cn.ibm.com>
Thu, 18 Sep 2014 08:49:47 +0000 (11:49 +0300)
committerTaoBai <baitaosh@cn.ibm.com>
Wed, 24 Sep 2014 05:01:55 +0000 (05:01 +0000)
It used none as volume type to create replication. Storwize Driver
did not check whether it's none.
Change to use new type to create replication.

Closes-bug: #1369815

Change-Id: I78501e1d3558bd6c3e6e1abb0c312cec7d11efd4

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

index 6e474476a0bc887a92a7b55e1a43e0f8c26a38cf..0ecaa64e52a641381ef9640d891a8463f63b5144 100644 (file)
@@ -2888,7 +2888,6 @@ class StorwizeSVCDriverTestCase(test.TestCase):
     def test_storwize_retype_with_strech_cluster_replication(self):
         self._set_flag('storwize_svc_stretched_cluster_partner', 'openstack2')
         self.driver.do_setup(self.ctxt)
-        self.driver.do_setup(None)
         loc = ('StorwizeSVCDriver:' + self.driver._state['system_id'] +
                ':openstack')
         cap = {'location_info': loc, 'extent_size': '128'}
@@ -2922,6 +2921,42 @@ class StorwizeSVCDriverTestCase(test.TestCase):
         self.assertIs('copying', model_update['replication_status'])
         self.driver.delete_volume(volume)
 
+    def test_storwize_retype_from_none_to_strech_cluster_replication(self):
+        self._set_flag('storwize_svc_stretched_cluster_partner', 'openstack2')
+        self.driver.do_setup(self.ctxt)
+        loc = ('StorwizeSVCDriver:' + self.driver._state['system_id'] +
+               ':openstack')
+        cap = {'location_info': loc, 'extent_size': '128'}
+        self.driver._stats = {'location_info': loc}
+        host = {'host': 'foo', 'capabilities': cap}
+        ctxt = context.get_admin_context()
+
+        volume = self._generate_vol_info(None, None)
+        volume['volume_type_id'] = None
+        volume['volume_type'] = None
+        volume['replication_status'] = "disabled"
+        volume['replication_extended_status'] = None
+
+        # Create volume which is not volume replication
+        model_update = self.driver.create_volume(volume)
+        self.assertIsNone(model_update)
+        # volume should be DB object in this parameter
+        model_update = self.driver.get_replication_status(self.ctxt, volume)
+        self.assertIsNone(model_update)
+
+        enable_type = self._create_replication_volume_type(True)
+        diff, equal = volume_types.volume_types_diff(ctxt,
+                                                     None,
+                                                     enable_type['id'])
+
+        # Enable replica
+        self.driver.retype(ctxt, volume, enable_type, diff, host)
+        # In DB replication_status will be updated
+        volume['replication_status'] = None
+        model_update = self.driver.get_replication_status(self.ctxt, volume)
+        self.assertIs('copying', model_update['replication_status'])
+        self.driver.delete_volume(volume)
+
     def test_storwize_initiator_target_map_npiv(self):
         # Create two volumes to be used in mappings
         ctxt = context.get_admin_context()
index 4bdb194f8ceea8a5842efd8f1246cab536e7fe65..d6ad506aa8f35b8fafa6ec116e42f490ee0715cf 100644 (file)
@@ -926,7 +926,8 @@ class StorwizeSVCDriver(san.SanDriver):
 
         # Add replica if needed
         if not old_type_replication and new_type_replication:
-            model_update = self.replication.create_replica(ctxt, volume)
+            model_update = self.replication.create_replica(ctxt, volume,
+                                                           new_type)
 
         LOG.debug('exit: retype: ild=%(id)s, new_type=%(new_type)s,'
                   'diff=%(diff)s, host=%(host)s' % {'id': volume['id'],
index 6d9694216347d73dd21d414c8454f2a8dd0c9634..a05b44dedc83c3369abddc161a198a0dd0f3f4dc 100644 (file)
@@ -67,10 +67,12 @@ class StorwizeSVCReplicationStretchedCluster(StorwizeSVCReplication):
     def __init__(self, driver):
         super(StorwizeSVCReplicationStretchedCluster, self).__init__(driver)
 
-    def create_replica(self, ctxt, volume):
+    def create_replica(self, ctxt, volume, vol_type = None):
+        # if vol_type is None, use the source volume type
+        if vol_type is None:
+            vol_type = volume['volume_type_id']
+            vol_type = volume_types.get_volume_type(ctxt, vol_type)
         conf = self.driver.configuration
-        vol_type = volume['volume_type_id']
-        vol_type = volume_types.get_volume_type(ctxt, vol_type)
         dest_pool = conf.storwize_svc_stretched_cluster_partner
 
         self.driver.add_vdisk_copy(volume['name'], dest_pool, vol_type)