]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
More validation logic for VNX CG creation
authorJeegn Chen <jeegn.chen@emc.com>
Fri, 27 Feb 2015 06:59:48 +0000 (14:59 +0800)
committerJeegn Chen <jeegn.chen@emc.com>
Fri, 27 Feb 2015 06:59:48 +0000 (14:59 +0800)
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
cinder/volume/drivers/emc/emc_vnx_cli.py

index c78dd6295e765f197d1cd9fcc7fa50c8975de3db..89b2bbae4c6ea77fca34300e29a45638a62c61fe 100644 (file)
@@ -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),
index d034a59a26c20dd23d232a94e86678881330001f..705354c86bd30eb3282080c4950e4d965556630f 100644 (file)
@@ -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)