Merge "DS8K: block in-use volume to be added to consistency group"

This commit is contained in:
Zuul 2018-01-18 17:33:38 +00:00 committed by Gerrit Code Review
commit b7b3e9be8a
2 changed files with 51 additions and 0 deletions

View File

@ -2999,6 +2999,43 @@ class DS8KProxyTest(test.TestCase):
self.driver.delete_group,
self.ctxt, group, [volume])
def test_add_in_use_vol_into_group_by_using_update_group(self):
self.driver = FakeDS8KProxy(self.storage_info, self.logger,
self.exception, self)
self.driver.setup(self.ctxt)
group_type = group_types.create(
self.ctxt,
'group',
{'consistent_group_snapshot_enabled': '<is> True'}
)
group = self._create_group(host=TEST_GROUP_HOST,
group_type_id=group_type.id)
location = six.text_type({'vol_hex_id': TEST_VOLUME_ID})
volume = self._create_volume(provider_location=location,
status='in-use')
self.assertRaises(exception.VolumeDriverException,
self.driver.update_group,
self.ctxt, group, [volume], [])
def test_remove_in_use_vol_from_group_by_using_update_group(self):
self.driver = FakeDS8KProxy(self.storage_info, self.logger,
self.exception, self)
self.driver.setup(self.ctxt)
group_type = group_types.create(
self.ctxt,
'group',
{'consistent_group_snapshot_enabled': '<is> True'}
)
group = self._create_group(host=TEST_GROUP_HOST,
group_type_id=group_type.id)
location = six.text_type({'vol_hex_id': TEST_VOLUME_ID})
volume = self._create_volume(provider_location=location,
status='in-use',
group_id=group.id)
self.assertRaises(exception.VolumeDriverException,
self.driver.update_group,
self.ctxt, group, [], [volume])
def test_update_replication_group_is_not_implemented(self):
"""update replication group is not implemented."""
self.configuration.replication_device = [TEST_REPLICATION_DEVICE]

View File

@ -1195,6 +1195,13 @@ class DS8KProxy(proxy.IBMStorageProxy):
@proxy.logger
def _add_volumes_into_consisgroup(self, grp, add_volumes):
add_volumes_update = []
for vol in add_volumes:
if vol.status == 'in-use':
msg = (_("add volume %(vol)s into group %(grp)s failed "
"since this volume is 'in-use' status")
% {'vol': vol.id, 'grp': grp.id})
LOG.error(msg)
raise exception.VolumeDriverException(message=msg)
new_add_luns, old_add_luns = (
self._clone_lun_for_consisgroup(add_volumes, grp))
for new_add_lun, old_add_lun in zip(new_add_luns, old_add_luns):
@ -1208,6 +1215,13 @@ class DS8KProxy(proxy.IBMStorageProxy):
def _remove_volumes_from_consisgroup(self, grp, add_volumes,
remove_volumes):
remove_volumes_update = []
for vol in remove_volumes:
if vol.status == 'in-use':
msg = (_("remove volume %(vol)s from group %(grp)s failed "
"since this volume is 'in-use' status")
% {'vol': vol.id, 'grp': grp.id})
LOG.error(msg)
raise exception.VolumeDriverException(message=msg)
new_remove_luns, old_remove_luns = (
self._clone_lun_for_consisgroup(remove_volumes))
for new_remove_lun, old_remove_lun in zip(new_remove_luns,