From: TaoBai Date: Thu, 18 Sep 2014 08:49:47 +0000 (+0300) Subject: IBM Storwize:Failed to retype from non-type to replication enable X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ea32e07f36781c2c0c7a0aa28817cc2df23df32d;p=openstack-build%2Fcinder-build.git IBM Storwize:Failed to retype from non-type to replication enable 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 --- diff --git a/cinder/tests/test_storwize_svc.py b/cinder/tests/test_storwize_svc.py index 6e474476a..0ecaa64e5 100644 --- a/cinder/tests/test_storwize_svc.py +++ b/cinder/tests/test_storwize_svc.py @@ -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() diff --git a/cinder/volume/drivers/ibm/storwize_svc/__init__.py b/cinder/volume/drivers/ibm/storwize_svc/__init__.py index 4bdb194f8..d6ad506aa 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/__init__.py +++ b/cinder/volume/drivers/ibm/storwize_svc/__init__.py @@ -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'], diff --git a/cinder/volume/drivers/ibm/storwize_svc/replication.py b/cinder/volume/drivers/ibm/storwize_svc/replication.py index 6d9694216..a05b44ded 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/replication.py +++ b/cinder/volume/drivers/ibm/storwize_svc/replication.py @@ -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)