Merge "VMAX driver - No support for creating CG from CG source"

This commit is contained in:
Jenkins 2016-10-30 00:52:23 +00:00 committed by Gerrit Code Review
commit 51411b6299
3 changed files with 116 additions and 120 deletions

View File

@ -27,6 +27,7 @@ import six
from cinder import exception
from cinder.i18n import _
from cinder.objects import consistencygroup
from cinder.objects import fields
from cinder import test
from cinder.tests.unit import utils
@ -418,22 +419,13 @@ class EMCVMAXCommonData(object):
'host': fake_host
}
test_volume_CG_v3 = {'name': 'volInCG',
'consistencygroup_id': 'abc',
'size': 1,
'volume_name': 'volInCG',
'id': 'volInCG',
'device_id': '1',
'provider_auth': None,
'project_id': 'project',
'display_name': 'volInCG',
'display_description':
'test volume in Consistency group',
'volume_type_id': 'abc',
'provider_location':
six.text_type(provider_location),
'status': 'available',
'host': fake_host_v3}
test_volume_CG_v3 = consistencygroup.ConsistencyGroup(
context=None, name='volInCG', consistencygroup_id='abc', size=1,
volume_name='volInCG', id='volInCG', device_id='1', status='available',
provider_auth=None, volume_type_id='abc', project_id='project',
display_name='volInCG',
display_description='test volume in Consistency group',
host=fake_host_v3, provider_location=six.text_type(provider_location))
test_failed_volume = {'name': 'failed_vol',
'size': 1,
@ -489,11 +481,10 @@ class EMCVMAXCommonData(object):
six.text_type(provider_location),
'display_description': 'snapshot source volume'}
test_CG = {'name': 'myCG1',
'id': '12345abcde',
'volume_type_id': 'abc',
'status': fields.ConsistencyGroupStatus.AVAILABLE
}
test_CG = consistencygroup.ConsistencyGroup(
context=None, name='myCG1', id='12345abcde',
volume_type_id='abc', status=fields.ConsistencyGroupStatus.AVAILABLE)
test_snapshot = {'name': 'myCG1',
'id': '12345abcde',
'status': 'available',
@ -3594,10 +3585,6 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase):
self.driver.create_consistencygroup(
self.data.test_ctxt, self.data.test_CG)
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
'_get_members_of_replication_group',
return_value=None)
@mock.patch.object(
FakeDB,
'volume_get_all_by_group',
@ -3612,7 +3599,7 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase):
return_value={'volume_backend_name': 'ISCSINoFAST'})
def test_delete_CG_no_volumes_no_fast_success(
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
_mock_db_volumes):
self.driver.delete_consistencygroup(
self.data.test_ctxt, self.data.test_CG, [])
@ -3913,7 +3900,7 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase):
utils = self.driver.common.utils
status = 'status-string'
volumes = utils.get_volume_model_updates(
None, self.driver.db.volume_get_all_by_group("", 5),
self.driver.db.volume_get_all_by_group("", 5),
self.data.test_CG['id'],
status)
self.assertEqual(status, volumes[0]['status'])
@ -4481,10 +4468,6 @@ class EMCVMAXISCSIDriverFastTestCase(test.TestCase):
self.driver.create_consistencygroup(
self.data.test_ctxt, self.data.test_CG)
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
'_get_members_of_replication_group',
return_value=None)
@mock.patch.object(
FakeDB,
'volume_get_all_by_group',
@ -4499,7 +4482,7 @@ class EMCVMAXISCSIDriverFastTestCase(test.TestCase):
return_value={'volume_backend_name': 'ISCSIFAST'})
def test_delete_CG_no_volumes_fast_success(
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
_mock_db_volumes):
self.driver.delete_consistencygroup(
self.data.test_ctxt, self.data.test_CG, [])
@ -4957,10 +4940,6 @@ class EMCVMAXFCDriverNoFastTestCase(test.TestCase):
self.driver.create_consistencygroup(
self.data.test_ctxt, self.data.test_CG)
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
'_get_members_of_replication_group',
return_value=None)
@mock.patch.object(
FakeDB,
'volume_get_all_by_group',
@ -4975,7 +4954,7 @@ class EMCVMAXFCDriverNoFastTestCase(test.TestCase):
return_value={'volume_backend_name': 'FCNoFAST'})
def test_delete_CG_no_volumes_no_fast_success(
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
_mock_db_volumes):
self.driver.delete_consistencygroup(
self.data.test_ctxt, self.data.test_CG, [])
@ -5724,10 +5703,6 @@ class EMCVMAXFCDriverFastTestCase(test.TestCase):
self.driver.create_consistencygroup(
self.data.test_ctxt, self.data.test_CG)
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
'_get_members_of_replication_group',
return_value=None)
@mock.patch.object(
FakeDB,
'volume_get_all_by_group',
@ -5742,7 +5717,7 @@ class EMCVMAXFCDriverFastTestCase(test.TestCase):
return_value={'volume_backend_name': 'FCFAST'})
def test_delete_CG_no_volumes_fast_success(
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
_mock_db_volumes):
self.driver.delete_consistencygroup(
self.data.test_ctxt, self.data.test_CG, [])
@ -6291,10 +6266,6 @@ class EMCV3DriverTestCase(test.TestCase):
self.driver.create_consistencygroup(
self.data.test_ctxt, self.data.test_volume_CG_v3)
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
'_get_members_of_replication_group',
return_value=None)
@mock.patch.object(
FakeDB,
'volume_get_all_by_group',
@ -6309,7 +6280,7 @@ class EMCV3DriverTestCase(test.TestCase):
return_value={'volume_backend_name': 'V3_BE'})
def test_delete_CG_no_volumes_v3_success(
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
_mock_db_volumes):
self.driver.delete_consistencygroup(
self.data.test_ctxt, self.data.test_CG, [])
@ -6931,10 +6902,6 @@ class EMCV2MultiPoolDriverTestCase(test.TestCase):
self.driver.create_consistencygroup(
self.data.test_ctxt, self.data.test_CG)
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
'_get_members_of_replication_group',
return_value=None)
@mock.patch.object(
FakeDB,
'volume_get_all_by_group',
@ -6949,7 +6916,7 @@ class EMCV2MultiPoolDriverTestCase(test.TestCase):
return_value={'volume_backend_name': 'MULTI_POOL_BE'})
def test_delete_CG_no_volumes_multi_pool_success(
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
_mock_db_volumes):
self.driver.delete_consistencygroup(
self.data.test_ctxt, self.data.test_CG, [])
@ -7234,10 +7201,6 @@ class EMCV3MultiSloDriverTestCase(test.TestCase):
self.driver.create_consistencygroup(
self.data.test_ctxt, self.data.test_CG)
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
'_get_members_of_replication_group',
return_value=None)
@mock.patch.object(
FakeDB,
'volume_get_all_by_group',
@ -7252,7 +7215,7 @@ class EMCV3MultiSloDriverTestCase(test.TestCase):
return_value={'volume_backend_name': 'MULTI_SLO_BE'})
def test_delete_CG_no_volumes_multi_slo_success(
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
_mock_db_volumes):
self.driver.delete_consistencygroup(
self.data.test_ctxt, self.data.test_CG, [])
@ -8643,6 +8606,24 @@ class EMCVMAXCommonTest(test.TestCase):
self.driver.common._extend_volume(
volumeInstance, volumeName, new_size_gb, old_size_gbs, extraSpecs)
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
'_get_pool_and_storage_system',
return_value=(None, EMCVMAXCommonData.storage_system))
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
'_initial_setup',
return_value=(EMCVMAXCommonData.extra_specs))
def test_get_consistency_group_utils(self, mock_init, mock_pool):
common = self.driver.common
common.conn = FakeEcomConnection()
replicationService, storageSystem, extraSpecs = (
common._get_consistency_group_utils(
common.conn, EMCVMAXCommonData.test_CG))
self.assertEqual(self.data.extra_specs, extraSpecs)
self.assertEqual(common.conn.EnumerateInstanceNames(
'EMC_ReplicationService')[0], replicationService)
class EMCVMAXProvisionTest(test.TestCase):
def setUp(self):

View File

@ -2522,21 +2522,13 @@ class EMCVMAXCommon(object):
{'group': group['id']})
modelUpdate = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
volumeTypeId = group['volume_type_id'].replace(",", "")
cgName = self.utils.truncate_string(group['id'], 8)
extraSpecs = self._initial_setup(None, volumeTypeId)
_poolInstanceName, storageSystem = (
self._get_pool_and_storage_system(extraSpecs))
self.conn = self._get_ecom_connection()
# Find storage system.
try:
replicationService = self.utils.find_replication_service(
self.conn, storageSystem)
replicationService, storageSystem, extraSpecs = (
self._get_consistency_group_utils(self.conn, group))
self.provision.create_consistency_group(
self.conn, replicationService, cgName, extraSpecs)
except Exception:
@ -2564,17 +2556,12 @@ class EMCVMAXCommon(object):
cgName = self.utils.truncate_string(group['id'], 8)
modelUpdate = {}
modelUpdate['status'] = group['status']
volumeTypeId = group['volume_type_id'].replace(",", "")
extraSpecs = self._initial_setup(None, volumeTypeId)
_poolInstanceName, storageSystem = (
self._get_pool_and_storage_system(extraSpecs))
if not self.conn:
self.conn = self._get_ecom_connection()
try:
replicationService = self.utils.find_replication_service(
self.conn, storageSystem)
replicationService, storageSystem, extraSpecs = (
self._get_consistency_group_utils(self.conn, group))
storageConfigservice = (
self.utils.find_storage_configuration_service(
@ -2582,10 +2569,13 @@ class EMCVMAXCommon(object):
cgInstanceName = self._find_consistency_group(
replicationService, cgName)
if cgInstanceName is None:
exception_message = (_("Cannot find CG group %s.") %
cgName)
raise exception.VolumeBackendAPIException(
data=exception_message)
LOG.error(_LE("Cannot find CG group %(cgName)s."),
{'cgName': cgName})
modelUpdate = {'status': fields.ConsistencyGroupStatus.DELETED}
volumes_model_update = self.utils.get_volume_model_updates(
volumes, group.id,
status='deleted')
return modelUpdate, volumes_model_update
memberInstanceNames = self._get_members_of_replication_group(
cgInstanceName)
@ -2597,9 +2587,9 @@ class EMCVMAXCommon(object):
# Do a bulk delete, a lot faster than single deletes.
if memberInstanceNames:
volumes, modelUpdate = self._do_bulk_delete(
volumes_model_update, modelUpdate = self._do_bulk_delete(
storageSystem, memberInstanceNames, storageConfigservice,
volumes, modelUpdate, extraSpecs[ISV3], extraSpecs)
volumes, group, extraSpecs[ISV3], extraSpecs)
except Exception:
exceptionMessage = (_(
@ -2608,10 +2598,10 @@ class EMCVMAXCommon(object):
LOG.exception(exceptionMessage)
raise exception.VolumeBackendAPIException(data=exceptionMessage)
return modelUpdate, volumes
return modelUpdate, volumes_model_update
def _do_bulk_delete(self, storageSystem, memberInstanceNames,
storageConfigservice, volumes, modelUpdate, isV3,
storageConfigservice, volumes, group, isV3,
extraSpecs):
"""Do a bulk delete.
@ -2641,13 +2631,15 @@ class EMCVMAXCommon(object):
self.provision.delete_volume_from_pool(
self.conn, storageConfigservice,
memberInstanceNames, None, extraSpecs)
for volumeRef in volumes:
volumeRef['status'] = 'deleted'
modelUpdate = {'status': fields.ConsistencyGroupStatus.DELETED}
except Exception:
for volumeRef in volumes:
volumeRef['status'] = 'error_deleting'
modelUpdate['status'] = 'error_deleting'
return volumes, modelUpdate
modelUpdate = {
'status': fields.ConsistencyGroupStatus.ERROR_DELETING}
finally:
volumes_model_update = self.utils.get_volume_model_updates(
volumes, group['id'], status=modelUpdate['status'])
return volumes_model_update, modelUpdate
def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a cgsnapshot.
@ -2672,16 +2664,11 @@ class EMCVMAXCommon(object):
cgName = self.utils.truncate_string(
cgsnapshot['consistencygroup_id'], 8)
volumeTypeId = consistencyGroup['volume_type_id'].replace(",", "")
extraSpecs = self._initial_setup(None, volumeTypeId)
self.conn = self._get_ecom_connection()
_poolInstanceName, storageSystem = (
self._get_pool_and_storage_system(extraSpecs))
try:
replicationService = self.utils.find_replication_service(
self.conn, storageSystem)
replicationService, storageSystem, extraSpecs = (
self._get_consistency_group_utils(self.conn, consistencyGroup))
cgInstanceName = (
self._find_consistency_group(replicationService, cgName))
@ -2807,14 +2794,12 @@ class EMCVMAXCommon(object):
'cgId': cgsnapshot['consistencygroup_id']})
model_update['status'] = cgsnapshot['status']
volumeTypeId = consistencyGroup['volume_type_id'].replace(",", "")
extraSpecs = self._initial_setup(None, volumeTypeId)
self.conn = self._get_ecom_connection()
_poolInstanceName, storageSystem = (
self._get_pool_and_storage_system(extraSpecs))
try:
replicationService, storageSystem, extraSpecs = (
self._get_consistency_group_utils(self.conn, consistencyGroup))
targetCgName = self.utils.truncate_string(cgsnapshot['id'], 8)
model_update, snapshots = self._delete_cg_and_members(
storageSystem, targetCgName, model_update,
@ -4300,14 +4285,8 @@ class EMCVMAXCommon(object):
{'group': group['id']})
modelUpdate = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
volumeTypeId = group['volume_type_id'].replace(",", "")
cg_name = self.utils.truncate_string(group['id'], 8)
extraSpecs = self._initial_setup(None, volumeTypeId)
_poolInstanceName, storageSystem = (
self._get_pool_and_storage_system(extraSpecs))
add_vols = [vol for vol in add_volumes] if add_volumes else []
add_instance_names = self._get_volume_instance_names(add_vols)
remove_vols = [vol for vol in remove_volumes] if remove_volumes else []
@ -4315,8 +4294,8 @@ class EMCVMAXCommon(object):
self.conn = self._get_ecom_connection()
try:
replicationService = self.utils.find_replication_service(
self.conn, storageSystem)
replicationService, storageSystem, extraSpecs = (
self._get_consistency_group_utils(self.conn, group))
cgInstanceName = (
self._find_consistency_group(replicationService, cg_name))
if cgInstanceName is None:
@ -4381,15 +4360,17 @@ class EMCVMAXCommon(object):
volumes_model_update is a list of dictionaries of volume
update
"""
if source_cg or source_vols:
LOG.debug("The VMAX driver does not support creating a "
"consistency group from a consistency group in "
"this version.")
raise NotImplementedError()
LOG.debug("Enter EMCVMAXCommon::create_consistencygroup_from_src. "
"Group to be created: %(cgId)s, "
"Source snapshot: %(cgSnapshot)s.",
{'cgId': group['id'],
'cgSnapshot': cgsnapshot['consistencygroup_id']})
volumeTypeId = group['volume_type_id'].replace(",", "")
extraSpecs = self._initial_setup(None, volumeTypeId)
self.create_consistencygroup(context, group)
targetCgName = self.utils.truncate_string(group['id'], TRUNCATE_8)
@ -4401,11 +4382,9 @@ class EMCVMAXCommon(object):
modelUpdate = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
_poolInstanceName, storageSystem = (
self._get_pool_and_storage_system(extraSpecs))
try:
replicationService = self.utils.find_replication_service(
self.conn, storageSystem)
replicationService, storageSystem, extraSpecs = (
self._get_consistency_group_utils(self.conn, group))
if replicationService is None:
exceptionMessage = (_(
"Cannot find replication service on system %s.") %
@ -4493,7 +4472,7 @@ class EMCVMAXCommon(object):
LOG.exception(exceptionMessage)
raise exception.VolumeBackendAPIException(data=exceptionMessage)
volumes_model_update = self.utils.get_volume_model_updates(
context, volumes, group['id'], modelUpdate['status'])
volumes, group['id'], modelUpdate['status'])
return modelUpdate, volumes_model_update
@ -4602,3 +4581,40 @@ class EMCVMAXCommon(object):
endpoint['ip'] = ipaddress
return endpoint
def _get_consistency_group_utils(self, conn, group):
"""Standard utility for consistency group.
:param conn: ecom connection
:param group: the consistency group object to be created
:return: replicationService, storageSystem, extraSpecs
"""
storageSystems = set()
volumeTypeIds = group.volume_type_id.split(",")
for volumeTypeId in volumeTypeIds:
if volumeTypeId:
extraSpecs = self._initial_setup(None, volumeTypeId)
__, storageSystem = (
self._get_pool_and_storage_system(extraSpecs))
if storageSystem:
storageSystems.add(storageSystem)
if len(storageSystems) != 1:
if not storageSystems:
msg = (_("Failed to get a single storage system "
"associated with consistencygroup_id: %(groupid)s.")
% {'groupid': group.id})
else:
msg = (_("There are multiple storage systems "
"associated with consistencygroup_id: %(groupid)s.")
% {'groupid': group.id})
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
storageSystem = storageSystems.pop()
replicationService = self.utils.find_replication_service(
conn, storageSystem)
return replicationService, storageSystem, extraSpecs

View File

@ -2330,10 +2330,9 @@ class EMCVMAXUtils(object):
return foundSyncInstanceName
def get_volume_model_updates(
self, context, volumes, cgId, status='available'):
self, volumes, cgId, status='available'):
"""Update the volume model's status and return it.
:param context: the context
:param volumes: volumes object api
:param cgId: cg id
:param status: string value reflects the status of the member volume