From 3fd6af2ce490f4b1fb3bb320fcb903043de1a998 Mon Sep 17 00:00:00 2001 From: Jeegn Chen Date: Fri, 27 Feb 2015 14:59:48 +0800 Subject: [PATCH] More validation logic for VNX CG creation In VNX array, compressed LUNs cannot be added into a Consistency Group. VNX Cinder Driver should check the volume types. If storagetype:provisioning=compressed is specified, VNX Cinder Driver should reject the CG creation operation. Change-Id: I221260217f875d39a119f06ce327f7ce6b5eb1ad Closes-Bug: #1421163 --- cinder/tests/test_emc_vnxdirect.py | 22 ++++++++++++++++++++++ cinder/volume/drivers/emc/emc_vnx_cli.py | 15 +++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/cinder/tests/test_emc_vnxdirect.py b/cinder/tests/test_emc_vnxdirect.py index c78dd6295..89b2bbae4 100644 --- a/cinder/tests/test_emc_vnxdirect.py +++ b/cinder/tests/test_emc_vnxdirect.py @@ -313,6 +313,13 @@ class EMCVNXCLIDriverTestData(): 'name': 'group_name', 'status': 'deleting'} + test_cg_with_type = {'id': 'consistencygroup_id', + 'name': 'group_name', + 'status': 'creating', + 'volume_type_id': + 'abc1-2320-9013-8813-8941-1374-8112-1231,' + '19fdd0dd-03b3-4d7c-b541-f4df46f308c8'} + test_cgsnapshot = { 'consistencygroup_id': 'consistencygroup_id', 'id': 'cgsnapshot_id', @@ -2728,6 +2735,21 @@ Time Remaining: 0 second(s) cg_name))] fake_cli.assert_has_calls(expect_cmd) + @mock.patch( + "cinder.volume.volume_types.get_volume_type_extra_specs", + mock.Mock(side_effect=[{'storagetype:provisioning': 'thin'}, + {'storagetype:provisioning': 'compressed'}])) + def test_create_consistency_group_failed_with_compression(self): + self.driverSetup([], []) + self.assertRaisesRegexp(exception.VolumeBackendAPIException, + "Failed to create consistency group " + "consistencygroup_id " + "because VNX consistency group cannot " + "accept compressed LUNs as members.", + self.driver.create_consistencygroup, + None, + self.testData.test_cg_with_type) + def test_delete_consistency_group(self): cg_name = self.testData.test_cg['id'] commands = [self.testData.DELETE_CONSISTENCYGROUP_CMD(cg_name), diff --git a/cinder/volume/drivers/emc/emc_vnx_cli.py b/cinder/volume/drivers/emc/emc_vnx_cli.py index d034a59a2..705354c86 100644 --- a/cinder/volume/drivers/emc/emc_vnx_cli.py +++ b/cinder/volume/drivers/emc/emc_vnx_cli.py @@ -2158,12 +2158,27 @@ class EMCVnxCliBase(object): if len(fields) == 2 and fields[0] == key: return fields[1] + def _consistencygroup_creation_check(self, group): + """Check extra spec for consistency group.""" + + if group.get('volume_type_id') is not None: + for id in group['volume_type_id'].split(","): + provisioning, tiering = self._get_extra_spec_value( + volume_types.get_volume_type_extra_specs(id)) + if provisioning == 'compressed': + msg = _("Failed to create consistency group %s " + "because VNX consistency group cannot " + "accept compressed LUNs as members.") % group['id'] + raise exception.VolumeBackendAPIException(data=msg) + def create_consistencygroup(self, context, group): """Creates a consistency group.""" LOG.info(_LI('Start to create consistency group: %(group_name)s ' 'id: %(id)s'), {'group_name': group['name'], 'id': group['id']}) + self._consistencygroup_creation_check(group) + model_update = {'status': 'available'} try: self._client.create_consistencygroup(context, group) -- 2.45.2