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
This commit is contained in:
TaoBai 2014-09-18 11:49:47 +03:00
parent d5d2744a70
commit ea32e07f36
3 changed files with 43 additions and 5 deletions

View 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()

View 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'],

View 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)