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
This commit is contained in:
Jeegn Chen 2015-02-27 14:59:48 +08:00
parent 33ccaf8efc
commit 3fd6af2ce4
2 changed files with 37 additions and 0 deletions

View 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),

View 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)