Merge "[SVF] Update rccg details for mirror volumes"
This commit is contained in:
commit
eb9deed8e3
@ -12340,10 +12340,14 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
|
|||||||
group = self._create_test_rccg(self.rccg_type, [self.mm_type.id])
|
group = self._create_test_rccg(self.rccg_type, [self.mm_type.id])
|
||||||
mm_vol, model_update = self._create_test_volume(self.mm_type)
|
mm_vol, model_update = self._create_test_volume(self.mm_type)
|
||||||
gm_vol, model_update = self._create_test_volume(self.gm_type)
|
gm_vol, model_update = self._create_test_volume(self.gm_type)
|
||||||
|
with mock.patch.object(storwize_svc_common.StorwizeSVCCommonDriver,
|
||||||
|
'_update_rccg_properties') as update_rccg_prop:
|
||||||
add_vols = [mm_vol, gm_vol]
|
add_vols = [mm_vol, gm_vol]
|
||||||
(model_update, add_volumes_update,
|
(model_update, add_volumes_update,
|
||||||
remove_volumes_update) = self.driver.update_group(
|
remove_volumes_update) = self.driver.update_group(
|
||||||
self.ctxt, group, add_vols, [])
|
self.ctxt, group, add_vols, [])
|
||||||
|
update_rccg_prop.assert_called()
|
||||||
|
self.assertEqual(1, update_rccg_prop.call_count)
|
||||||
self.assertEqual(fields.GroupStatus.ERROR, model_update['status'])
|
self.assertEqual(fields.GroupStatus.ERROR, model_update['status'])
|
||||||
self.assertEqual([{'id': mm_vol.id, 'group_id': group.id}],
|
self.assertEqual([{'id': mm_vol.id, 'group_id': group.id}],
|
||||||
add_volumes_update)
|
add_volumes_update)
|
||||||
@ -12366,17 +12370,22 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
|
|||||||
rcrel = self.driver._helpers.get_relationship_info(mm_vol4.name)
|
rcrel = self.driver._helpers.get_relationship_info(mm_vol4.name)
|
||||||
self.sim._rc_state_transition('wait', rcrel)
|
self.sim._rc_state_transition('wait', rcrel)
|
||||||
|
|
||||||
|
with mock.patch.object(storwize_svc_common.StorwizeSVCCommonDriver,
|
||||||
|
'_update_rccg_properties') as update_rccg_prop:
|
||||||
add_vols = [mm_vol1, mm_vol2]
|
add_vols = [mm_vol1, mm_vol2]
|
||||||
(model_update, add_volumes_update,
|
(model_update, add_volumes_update,
|
||||||
remove_volumes_update) = self.driver.update_group(
|
remove_volumes_update) = self.driver.update_group(
|
||||||
self.ctxt, group, add_vols, [])
|
self.ctxt, group, add_vols, [])
|
||||||
|
update_rccg_prop.assert_called()
|
||||||
|
self.assertEqual(2, update_rccg_prop.call_count)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
rccg_name,
|
rccg_name,
|
||||||
self.driver._helpers.get_rccg_info(mm_vol1.name)['name'])
|
self.driver._helpers.get_rccg_info(mm_vol1.name)['name'])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
rccg_name,
|
rccg_name,
|
||||||
self.driver._helpers.get_rccg_info(mm_vol2.name)['name'])
|
self.driver._helpers.get_rccg_info(mm_vol2.name)['name'])
|
||||||
self.assertEqual(fields.GroupStatus.AVAILABLE, model_update['status'])
|
self.assertEqual(fields.GroupStatus.AVAILABLE,
|
||||||
|
model_update['status'])
|
||||||
self.assertEqual([{'id': mm_vol1.id, 'group_id': group.id},
|
self.assertEqual([{'id': mm_vol1.id, 'group_id': group.id},
|
||||||
{'id': mm_vol2.id, 'group_id': group.id}],
|
{'id': mm_vol2.id, 'group_id': group.id}],
|
||||||
add_volumes_update)
|
add_volumes_update)
|
||||||
@ -12387,6 +12396,15 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
|
|||||||
(model_update, add_volumes_update,
|
(model_update, add_volumes_update,
|
||||||
remove_volumes_update) = self.driver.update_group(
|
remove_volumes_update) = self.driver.update_group(
|
||||||
self.ctxt, group, add_volumes=add_vols, remove_volumes=rmv_vols)
|
self.ctxt, group, add_volumes=add_vols, remove_volumes=rmv_vols)
|
||||||
|
# Validating the rccg property value from metadata of the volume
|
||||||
|
# mm_vol3 that is added to a group
|
||||||
|
self.assertEqual(rccg_name, mm_vol3.metadata['Consistency Group Name'])
|
||||||
|
# Validating the rccg property value from metadata of the volume
|
||||||
|
# mm_vol1 that is removed from a group
|
||||||
|
exp_rccg_name = ''
|
||||||
|
self.assertEqual(exp_rccg_name,
|
||||||
|
mm_vol1.metadata['Consistency Group Name'])
|
||||||
|
|
||||||
self.assertIsNone(self.driver._helpers.get_rccg_info(mm_vol1.name))
|
self.assertIsNone(self.driver._helpers.get_rccg_info(mm_vol1.name))
|
||||||
self.assertIsNone(self.driver._helpers.get_rccg_info(mm_vol2.name))
|
self.assertIsNone(self.driver._helpers.get_rccg_info(mm_vol2.name))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -12405,6 +12423,28 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
|
|||||||
self.driver.delete_group(self.ctxt, group, [mm_vol1, mm_vol2,
|
self.driver.delete_group(self.ctxt, group, [mm_vol1, mm_vol2,
|
||||||
mm_vol3, mm_vol4])
|
mm_vol3, mm_vol4])
|
||||||
|
|
||||||
|
def test_storwize_rep_volume_rccg_properties_update(self):
|
||||||
|
"""Test rep volume rccg_properties update."""
|
||||||
|
self.driver.configuration.set_override('replication_device',
|
||||||
|
[self.rep_target])
|
||||||
|
self.driver.do_setup(self.ctxt)
|
||||||
|
group = self._create_test_rccg(self.rccg_type, [self.mm_type.id])
|
||||||
|
# Create metro mirror replication.
|
||||||
|
mm_vol, model_update = self._create_test_volume(self.mm_type)
|
||||||
|
# Validating the rccg property value of volume-metadata that updated
|
||||||
|
# during the call to the function _update_rccg_properties by passing
|
||||||
|
# the parameter 'group'
|
||||||
|
self.driver._update_rccg_properties(self.ctxt, mm_vol, group)
|
||||||
|
rccg_name = self.driver._get_rccg_name(group)
|
||||||
|
self.assertEqual(rccg_name, mm_vol.metadata['Consistency Group Name'])
|
||||||
|
# Validating the rccg property value of volume-metadata that updated
|
||||||
|
# during the call to the function _update_rccg_properties by not
|
||||||
|
# passing the parameter 'group'
|
||||||
|
self.driver._update_rccg_properties(self.ctxt, mm_vol)
|
||||||
|
exp_rccg_name = ""
|
||||||
|
self.assertEqual(exp_rccg_name,
|
||||||
|
mm_vol.metadata['Consistency Group Name'])
|
||||||
|
|
||||||
@mock.patch.object(storwize_svc_common.StorwizeSSH,
|
@mock.patch.object(storwize_svc_common.StorwizeSSH,
|
||||||
'startrcconsistgrp')
|
'startrcconsistgrp')
|
||||||
def test_storwize_enable_replication_error(self, startrccg):
|
def test_storwize_enable_replication_error(self, startrccg):
|
||||||
@ -13044,13 +13084,17 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
|
|||||||
clone_volumes = self.db.volume_get_all_by_generic_group(
|
clone_volumes = self.db.volume_get_all_by_generic_group(
|
||||||
self.ctxt.elevated(), clone_group.id)
|
self.ctxt.elevated(), clone_group.id)
|
||||||
|
|
||||||
|
with mock.patch.object(
|
||||||
|
storwize_svc_common.StorwizeSVCCommonDriver,
|
||||||
|
'_update_rccg_properties'):
|
||||||
model_update, volumes_model_update = (
|
model_update, volumes_model_update = (
|
||||||
self.driver.create_group_from_src(self.ctxt, clone_group,
|
self.driver.create_group_from_src(self.ctxt, clone_group,
|
||||||
clone_volumes, None, None,
|
clone_volumes, None, None,
|
||||||
src_group,
|
src_group,
|
||||||
src_volumes))
|
src_volumes))
|
||||||
|
|
||||||
self.assertEqual(fields.GroupStatus.AVAILABLE, model_update['status'])
|
self.assertEqual(fields.GroupStatus.AVAILABLE,
|
||||||
|
model_update['status'])
|
||||||
for vol_model_update in volumes_model_update:
|
for vol_model_update in volumes_model_update:
|
||||||
self.assertEqual(fields.VolumeStatus.AVAILABLE,
|
self.assertEqual(fields.VolumeStatus.AVAILABLE,
|
||||||
vol_model_update['status'])
|
vol_model_update['status'])
|
||||||
@ -13085,14 +13129,16 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
|
|||||||
|
|
||||||
group_snapshot, snapshots = self._create_group_snapshot(
|
group_snapshot, snapshots = self._create_group_snapshot(
|
||||||
src_group.id, group_type_id=self.rccg_type.id)
|
src_group.id, group_type_id=self.rccg_type.id)
|
||||||
|
with mock.patch.object(
|
||||||
|
storwize_svc_common.StorwizeSVCCommonDriver,
|
||||||
|
'_update_rccg_properties'):
|
||||||
model_update, volumes_model_update = (
|
model_update, volumes_model_update = (
|
||||||
self.driver.create_group_from_src(self.ctxt,
|
self.driver.create_group_from_src(
|
||||||
group_from_src_group_snapshot,
|
self.ctxt, group_from_src_group_snapshot, group_volumes,
|
||||||
group_volumes,
|
group_snapshot, snapshots, None, None))
|
||||||
group_snapshot,
|
|
||||||
snapshots, None, None))
|
|
||||||
|
|
||||||
self.assertEqual(fields.GroupStatus.AVAILABLE, model_update['status'])
|
self.assertEqual(fields.GroupStatus.AVAILABLE,
|
||||||
|
model_update['status'])
|
||||||
for vol_model_update in volumes_model_update:
|
for vol_model_update in volumes_model_update:
|
||||||
self.assertEqual(fields.VolumeStatus.AVAILABLE,
|
self.assertEqual(fields.VolumeStatus.AVAILABLE,
|
||||||
vol_model_update['status'])
|
vol_model_update['status'])
|
||||||
@ -13145,7 +13191,9 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
|
|||||||
)
|
)
|
||||||
@mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall',
|
@mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall',
|
||||||
new=testutils.ZeroIntervalLoopingCall)
|
new=testutils.ZeroIntervalLoopingCall)
|
||||||
def test_create_group_from_src_grp(self, vol_spec):
|
@mock.patch.object(storwize_svc_common.StorwizeSVCCommonDriver,
|
||||||
|
'_update_rccg_properties')
|
||||||
|
def test_create_group_from_src_grp(self, vol_spec, update_rccg_properties):
|
||||||
self.driver.configuration.set_override('replication_device',
|
self.driver.configuration.set_override('replication_device',
|
||||||
[self.rep_target])
|
[self.rep_target])
|
||||||
|
|
||||||
@ -13259,9 +13307,12 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
|
|||||||
)
|
)
|
||||||
@mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall',
|
@mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall',
|
||||||
new=testutils.ZeroIntervalLoopingCall)
|
new=testutils.ZeroIntervalLoopingCall)
|
||||||
|
@mock.patch.object(storwize_svc_common.StorwizeSVCCommonDriver,
|
||||||
|
'_update_rccg_properties')
|
||||||
@mock.patch('cinder.volume.volume_utils.is_group_a_cg_snapshot_type')
|
@mock.patch('cinder.volume.volume_utils.is_group_a_cg_snapshot_type')
|
||||||
def test_create_group_from_grp_snapshot(self, vol_spec,
|
def test_create_group_from_grp_snapshot(self, vol_spec,
|
||||||
is_group_a_cg_snap_type):
|
is_group_a_cg_snap_type,
|
||||||
|
update_rccg_properties):
|
||||||
self.driver.configuration.set_override('replication_device',
|
self.driver.configuration.set_override('replication_device',
|
||||||
[self.rep_target])
|
[self.rep_target])
|
||||||
is_group_a_cg_snap_type.return_value = False
|
is_group_a_cg_snap_type.return_value = False
|
||||||
|
@ -3510,6 +3510,13 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
|||||||
model_update['metadata'][key] = rel_info.get(value)
|
model_update['metadata'][key] = rel_info.get(value)
|
||||||
return model_update
|
return model_update
|
||||||
|
|
||||||
|
def _update_rccg_properties(self, ctxt, volume, group=None):
|
||||||
|
rccg_name = self._get_rccg_name(group) if group else ""
|
||||||
|
if not volume.metadata:
|
||||||
|
volume.metadata = dict()
|
||||||
|
volume.metadata['Consistency Group Name'] = rccg_name
|
||||||
|
volume.save()
|
||||||
|
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
LOG.debug('enter: create_volume: volume %s', volume['name'])
|
LOG.debug('enter: create_volume: volume %s', volume['name'])
|
||||||
# Create a replication or hyperswap volume with group_id is not
|
# Create a replication or hyperswap volume with group_id is not
|
||||||
@ -6383,6 +6390,8 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
|||||||
rccg = self._helpers.get_rccg(rccg_name)
|
rccg = self._helpers.get_rccg(rccg_name)
|
||||||
added_vols.append({'id': volume.id,
|
added_vols.append({'id': volume.id,
|
||||||
'group_id': group.id})
|
'group_id': group.id})
|
||||||
|
# Updating RCCG properties for a volume
|
||||||
|
self._update_rccg_properties(context, volume, group)
|
||||||
except exception.VolumeBackendAPIException as err:
|
except exception.VolumeBackendAPIException as err:
|
||||||
model_update['status'] = fields.GroupStatus.ERROR
|
model_update['status'] = fields.GroupStatus.ERROR
|
||||||
LOG.error("Failed to add the remote copy of volume %(vol)s to "
|
LOG.error("Failed to add the remote copy of volume %(vol)s to "
|
||||||
@ -6414,6 +6423,8 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
|||||||
self._helpers.chrcrelationship(rcrel['name'])
|
self._helpers.chrcrelationship(rcrel['name'])
|
||||||
removed_vols.append({'id': volume.id,
|
removed_vols.append({'id': volume.id,
|
||||||
'group_id': None})
|
'group_id': None})
|
||||||
|
# Updating RCCG properties for a volume
|
||||||
|
self._update_rccg_properties(context, volume)
|
||||||
except exception.VolumeBackendAPIException as err:
|
except exception.VolumeBackendAPIException as err:
|
||||||
model_update['status'] = fields.GroupStatus.ERROR
|
model_update['status'] = fields.GroupStatus.ERROR
|
||||||
LOG.error("Failed to remove the remote copy of volume %(vol)s "
|
LOG.error("Failed to remove the remote copy of volume %(vol)s "
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
IBM Spectrum Virtualize Family driver
|
||||||
|
`Bug #1926491 <https://bugs.launchpad.net/cinder/+bug/1926491>`_:
|
||||||
|
Updating volume metadata with rccg properties for the volumes with
|
||||||
|
replication enabled and added to a group or removed from a group.
|
Loading…
Reference in New Issue
Block a user