From bb310bf635e84ceccfb4b3c575df4998a4e360d6 Mon Sep 17 00:00:00 2001 From: "rick.chen" Date: Wed, 12 Nov 2014 11:50:37 +0800 Subject: [PATCH] Fix a problem in creating consistency group in ProphetStor driver. a.Failed to create CG in the storage: Storage site cannot accept CG uuid including "-" word. Before sending API to back-end storage, the "-" word in the CG uuid needs to be removed. b.Failed to delete volume of CG: Corrected api leaving group operation key. Change-Id: I017b2f65c4da6961219f0b972edae2b1cb447878 Closes-Bug: 1391724 --- cinder/tests/test_prophetstor_dpl.py | 40 +++++++++++++------ .../volume/drivers/prophetstor/dplcommon.py | 9 +++-- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/cinder/tests/test_prophetstor_dpl.py b/cinder/tests/test_prophetstor_dpl.py index 1539eef07..c390af722 100644 --- a/cinder/tests/test_prophetstor_dpl.py +++ b/cinder/tests/test_prophetstor_dpl.py @@ -90,7 +90,7 @@ DATA_OUTPUT = 0, None MOD_OUTPUT = {'status': 'available'} -DATA_IN_GROUP = {'id': 'group123', +DATA_IN_GROUP = {'id': 'fe2dbc51-5810-451d-ab2f-8c8a48d15bee', 'name': 'group123', 'description': 'des123', 'status': ''} @@ -104,7 +104,8 @@ DATA_IN_VOLUME_VG = {'id': 'abc123', 'display_name': 'abc123', 'display_description': '', 'size': 1, - 'consistencygroup_id': 'group123', + 'consistencygroup_id': + 'fe2dbc51-5810-451d-ab2f-8c8a48d15bee', 'status': 'available'} DATA_IN_VOLUME1 = {'id': 'abc456', @@ -112,22 +113,24 @@ DATA_IN_VOLUME1 = {'id': 'abc456', 'display_description': '', 'size': 1} -DATA_IN_CG_SNAPSHOT = {'consistencygroup_id': 'group123', - 'id': 'cgsnapshot1', - 'name': 'cgsnapshot1', - 'description': 'cgsnapshot1', - 'status': ''} +DATA_IN_CG_SNAPSHOT = { + 'consistencygroup_id': 'fe2dbc51-5810-451d-ab2f-8c8a48d15bee', + 'id': 'cgsnapshot1', + 'name': 'cgsnapshot1', + 'description': 'cgsnapshot1', + 'status': ''} DATA_IN_SNAPSHOT = {'id': 'snapshot1', 'volume_id': 'abc123', 'display_name': 'snapshot1', 'display_description': ''} -DATA_OUT_SNAPSHOT_CG = {'id': 'snapshot1', - 'volume_id': 'abc123', - 'display_name': 'snapshot1', - 'display_description': '', - 'cgsnapshot_id': 'cgsnapshot1'} +DATA_OUT_SNAPSHOT_CG = { + 'id': 'snapshot1', + 'volume_id': 'abc123', + 'display_name': 'snapshot1', + 'display_description': '', + 'cgsnapshot_id': 'fe2dbc51-5810-451d-ab2f-8c8a48d15bee'} class TestProphetStorDPLVolume(test.TestCase): @@ -484,6 +487,17 @@ class TestProphetStorDPLDriver(test.TestCase): self.DPL_MOCK.delete_vdev.assert_called_once_with( self._conver_uuid2hex(DATA_IN_VOLUME['id'])) + def test_delete_volume_of_group(self): + self.DPL_MOCK.delete_vdev.return_value = DATA_OUTPUT + self.DPL_MOCK.leave_vg.return_volume = DATA_OUTPUT + self.dpldriver.delete_volume(DATA_IN_VOLUME_VG) + self.DPL_MOCK.leave_vg.assert_called_once_with( + self._conver_uuid2hex(DATA_IN_VOLUME_VG['id']), + self._conver_uuid2hex(DATA_IN_GROUP['id']) + ) + self.DPL_MOCK.delete_vdev.assert_called_once_with( + self._conver_uuid2hex(DATA_IN_VOLUME['id'])) + def test_create_volume_from_snapshot(self): self.DPL_MOCK.create_vdev_from_snapshot.return_value = DATA_OUTPUT self.dpldriver.create_volume_from_snapshot(DATA_IN_VOLUME, @@ -589,7 +603,7 @@ class TestProphetStorDPLDriver(test.TestCase): model_update = self.dpldriver.create_consistencygroup(self.context, DATA_IN_GROUP) self.DPL_MOCK.create_vg.assert_called_once_with( - DATA_IN_GROUP['id'], DATA_IN_GROUP['name'], + self._conver_uuid2hex(DATA_IN_GROUP['id']), DATA_IN_GROUP['name'], DATA_IN_GROUP['description']) self.assertDictMatch({'status': 'available'}, model_update) diff --git a/cinder/volume/drivers/prophetstor/dplcommon.py b/cinder/volume/drivers/prophetstor/dplcommon.py index 26d55bba0..92557a557 100644 --- a/cinder/volume/drivers/prophetstor/dplcommon.py +++ b/cinder/volume/drivers/prophetstor/dplcommon.py @@ -667,7 +667,7 @@ class DPLVolume(object): metadata = {} params = {} url = '/%s/%s/' % (DPL_OBJ_VOLUMEGROUP, groupID) - metadata['volume_group_operation'] = 'level' + metadata['volume_group_operation'] = 'leave' metadata['volume'] = [] metadata['volume'].append(volumeID) params['metadata'] = metadata @@ -831,8 +831,10 @@ class DPLCOMMONDriver(driver.VolumeDriver): {'group_name': group['name'], 'id': group['id']}) model_update = {'status': 'available'} try: - ret, output = self.dpl.create_vg(group['id'], group['name'], - group['description']) + ret, output = self.dpl.create_vg( + self._conver_uuid2hex(group['id']), + group['name'], + group['description']) if ret: msg = _('Failed to create consistency group ' '%(id)s:%(ret)s.') % {'id': group['id'], @@ -1156,6 +1158,7 @@ class DPLCOMMONDriver(driver.VolumeDriver): def delete_volume(self, volume): """Deletes a volume.""" + ret = 0 if volume.get('consistencygroup_id', None): msg = '' try: -- 2.45.2