group = {'id': 'fc8f2fec-fab2-4e34-9148-c094c913b9a3',
'status': 'deleted'}
model_update, volumes = self.driver.delete_consistencygroup(context,
- group)
+ group,
+ [])
mock_find_replay_profile.assert_called_once_with(group['id'])
mock_delete_replay_profile.assert_called_once_with(self.SCRPLAYPROFILE)
mock_delete_volume.assert_called_once_with(mock_volume)
group = {'id': 'fc8f2fec-fab2-4e34-9148-c094c913b9a3',
'status': 'deleted'}
model_update, volumes = self.driver.delete_consistencygroup(context,
- group)
+ group,
+ [])
mock_find_replay_profile.assert_called_once_with(group['id'])
self.assertFalse(mock_delete_replay_profile.called)
mock_delete_volume.assert_called_once_with(mock_volume)
context = {}
cggrp = {'consistencygroup_id': 'fc8f2fec-fab2-4e34-9148-c094c913b9a3',
'id': '100'}
- model_update, snapshots = self.driver.create_cgsnapshot(context, cggrp)
+ model_update, snapshots = self.driver.create_cgsnapshot(context, cggrp,
+ [])
mock_find_replay_profile.assert_called_once_with(
cggrp['consistencygroup_id'])
mock_snap_cg_replay.assert_called_once_with(self.SCRPLAYPROFILE,
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.create_cgsnapshot,
context,
- cggrp)
+ cggrp,
+ [])
mock_find_replay_profile.assert_called_once_with(
cggrp['consistencygroup_id'])
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.create_cgsnapshot,
context,
- cggrp)
+ cggrp,
+ [])
mock_find_replay_profile.assert_called_once_with(
cggrp['consistencygroup_id'])
mock_snap_cg_replay.assert_called_once_with(self.SCRPLAYPROFILE,
'id': '100',
'status': 'deleted'}
model_update, snapshots = self.driver.delete_cgsnapshot(context,
- cgsnap)
+ cgsnap,
+ [])
mock_find_replay_profile.assert_called_once_with(
cgsnap['consistencygroup_id'])
mock_delete_cg_replay.assert_called_once_with(self.SCRPLAYPROFILE,
'id': '100',
'status': 'deleted'}
model_update, snapshots = self.driver.delete_cgsnapshot(context,
- cgsnap)
+ cgsnap,
+ [])
mock_find_replay_profile.assert_called_once_with(
cgsnap['consistencygroup_id'])
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.delete_cgsnapshot,
context,
- cgsnap)
+ cgsnap,
+ [])
mock_find_replay_profile.assert_called_once_with(
cgsnap['consistencygroup_id'])
mock_delete_cg_replay.assert_called_once_with(self.SCRPLAYPROFILE,
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_CG_with_volumes_no_fast_success(
self, _mock_volume_type, _mock_storage_system):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_utils.EMCVMAXUtils,
self, _mock_volume_type, _mock_storage, _mock_cg, _mock_members,
_mock_rg):
self.driver.create_cgsnapshot(
- self.data.test_ctxt, self.data.test_CG_snapshot)
+ self.data.test_ctxt, self.data.test_CG_snapshot, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_snapshot_for_CG_no_fast_success(
self, _mock_volume_type, _mock_storage):
self.driver.delete_cgsnapshot(
- self.data.test_ctxt, self.data.test_CG_snapshot)
+ self.data.test_ctxt, self.data.test_CG_snapshot, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_CG_with_volumes_fast_success(
self, _mock_volume_type, _mock_storage_system):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_utils.EMCVMAXUtils,
self, _mock_volume_type, _mock_storage, _mock_cg, _mock_members,
_mock_rg):
self.driver.create_cgsnapshot(
- self.data.test_ctxt, self.data.test_CG_snapshot)
+ self.data.test_ctxt, self.data.test_CG_snapshot, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_snapshot_for_CG_no_fast_success(
self, _mock_volume_type, _mock_storage):
self.driver.delete_cgsnapshot(
- self.data.test_ctxt, self.data.test_CG_snapshot)
+ self.data.test_ctxt, self.data.test_CG_snapshot, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_CG_with_volumes_no_fast_success(
self, _mock_volume_type, _mock_storage_system):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_utils.EMCVMAXUtils,
self, _mock_volume_type, _mock_storage, _mock_cg, _mock_members,
_mock_rg):
self.driver.create_cgsnapshot(
- self.data.test_ctxt, self.data.test_CG_snapshot)
+ self.data.test_ctxt, self.data.test_CG_snapshot, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_snapshot_for_CG_no_fast_success(
self, _mock_volume_type, _mock_storage):
self.driver.delete_cgsnapshot(
- self.data.test_ctxt, self.data.test_CG_snapshot)
+ self.data.test_ctxt, self.data.test_CG_snapshot, [])
def test_manage_existing_get_size(self):
volume = {}
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_CG_with_volumes_fast_success(
self, _mock_volume_type, _mock_storage_system):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_utils.EMCVMAXUtils,
self, _mock_volume_type, _mock_storage, _mock_cg, _mock_members,
_mock_rg):
self.driver.create_cgsnapshot(
- self.data.test_ctxt, self.data.test_CG_snapshot)
+ self.data.test_ctxt, self.data.test_CG_snapshot, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_snapshot_for_CG_no_fast_success(
self, _mock_volume_type, _mock_storage):
self.driver.delete_cgsnapshot(
- self.data.test_ctxt, self.data.test_CG_snapshot)
+ self.data.test_ctxt, self.data.test_CG_snapshot, [])
# Bug 1385450
def test_create_clone_without_license(self):
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_CG_with_volumes_v3_success(
self, _mock_volume_type, _mock_storage_system):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
volume_types,
provisionv3 = self.driver.common.provisionv3
provisionv3.create_group_replica = mock.Mock(return_value=(0, None))
self.driver.create_cgsnapshot(
- self.data.test_ctxt, self.data.test_CG_snapshot)
+ self.data.test_ctxt, self.data.test_CG_snapshot, [])
repServ = self.conn.EnumerateInstanceNames("EMC_ReplicationService")[0]
provisionv3.create_group_replica.assert_called_once_with(
self.conn, repServ,
def test_delete_cgsnapshot_v3_success(
self, _mock_volume_type, _mock_storage):
self.driver.delete_cgsnapshot(
- self.data.test_ctxt, self.data.test_CG_snapshot)
+ self.data.test_ctxt, self.data.test_CG_snapshot, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_CG_with_volumes_multi_pool_success(
self, _mock_volume_type, _mock_storage_system):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
def _cleanup(self):
bExists = os.path.exists(self.config_file_path)
self, _mock_volume_type, _mock_storage_system,
_mock_db_volumes, _mock_members):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
def test_delete_CG_with_volumes_multi_slo_success(
self, _mock_volume_type, _mock_storage_system):
self.driver.delete_consistencygroup(
- self.data.test_ctxt, self.data.test_CG)
+ self.data.test_ctxt, self.data.test_CG, [])
def _cleanup(self):
bExists = os.path.exists(self.config_file_path)
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.delete_consistencygroup,
self.data.test_ctxt,
- self.data.test_CG)
+ self.data.test_CG,
+ [])
@mock.patch.object(
emc_vmax_common.EMCVMAXCommon,
self.driver.db.volume_get_all_by_group.return_value =\
self.testData.CONSISTENCY_GROUP_VOLUMES()
self.driver.delete_consistencygroup(None,
- self.testData.test_cg)
+ self.testData.test_cg,
+ [])
expect_cmd = [
mock.call(
*self.testData.DELETE_CONSISTENCYGROUP_CMD(
self.testData.SNAPS_IN_SNAP_GROUP())
snapshot_obj.consistencygroup_id = cg_name
get_all_for_cgsnapshot.return_value = [snapshot_obj]
- self.driver.create_cgsnapshot(None, self.testData.test_cgsnapshot)
+ self.driver.create_cgsnapshot(None, self.testData.test_cgsnapshot, [])
expect_cmd = [
mock.call(
*self.testData.CREATE_CG_SNAPSHOT(
snapshot_obj.consistencygroup_id = cg_name
get_all_for_cgsnapshot.return_value = [snapshot_obj]
self.driver.delete_cgsnapshot(None,
- self.testData.test_cgsnapshot)
+ self.testData.test_cgsnapshot,
+ [])
expect_cmd = [
mock.call(
*self.testData.DELETE_CG_SNAPSHOT(
self.driver.db = mock.Mock()
(self.driver.db.
volume_get_all_by_group.return_value) = [mock.MagicMock()]
- self.driver.create_cgsnapshot(d.context, d.cgsnapshot)
+ self.driver.create_cgsnapshot(d.context, d.cgsnapshot, [])
snapset_name = self.driver._get_cgsnap_name(d.cgsnapshot)
self.assertEqual(snapset_name,
'192eb39b6c2f420cbae33cfd117f0345192eb39b6c2f420cbae'
'name': snapset_name,
'index': 1}
xms_data['snapshot-sets'] = {snapset_name: snapset1, 1: snapset1}
- self.driver.delete_cgsnapshot(d.context, d.cgsnapshot)
- self.driver.delete_consistencygroup(d.context, d.group)
+ self.driver.delete_cgsnapshot(d.context, d.cgsnapshot, [])
+ self.driver.delete_consistencygroup(d.context, d.group, [])
xms_data['snapshot-sets'] = {}
@mock.patch('cinder.objects.snapshot.SnapshotList.get_all_for_cgsnapshot')
self.driver.create_consistencygroup(d.context, d.group)
self.driver.create_volume(d.test_volume)
- self.driver.create_cgsnapshot(d.context, d.cgsnapshot)
+ self.driver.create_cgsnapshot(d.context, d.cgsnapshot, [])
xms_data['volumes'][2]['ancestor-vol-id'] = (xms_data['volumes'][1]
['vol-id'])
snapset_name = self.driver._get_cgsnap_name(d.cgsnapshot)
self.driver.db.volume_get_all_by_group = mock.Mock()
self.driver.db.volume_get_all_by_group.return_value = volumes
- self.driver.delete_consistencygroup(ctxt, group)
+ self.driver.delete_consistencygroup(ctxt, group, [])
fsdev = self.driver._gpfs_device
cgname = "consisgroup-%s" % group['id']
cmd = ['mmunlinkfileset', fsdev, cgname, '-f']
mock_exec.side_effect = (
processutils.ProcessExecutionError(stdout='test', stderr='test'))
self.assertRaises(exception.VolumeBackendAPIException,
- self.driver.delete_consistencygroup, ctxt, group)
+ self.driver.delete_consistencygroup, ctxt, group, [])
@mock.patch('cinder.volume.drivers.ibm.gpfs.GPFSDriver.create_snapshot')
def test_create_cgsnapshot(self, mock_create_snap):
snapshot1 = self._fake_snapshot()
snapshots = [snapshot1]
self.driver.db.snapshot_get_all_for_cgsnapshot.return_value = snapshots
- model_update, snapshots = self.driver.create_cgsnapshot(ctxt, cgsnap)
+ model_update, snapshots = self.driver.create_cgsnapshot(ctxt, cgsnap,
+ [])
self.driver.create_snapshot.assert_called_once_with(snapshot1)
self.assertEqual({'status': cgsnap['status']}, model_update)
self.assertEqual('available', snapshot1['status'])
self.driver.db.snapshot_get_all_for_cgsnapshot = mock.Mock()
snapshots = []
self.driver.db.snapshot_get_all_for_cgsnapshot.return_value = snapshots
- model_update, snapshots = self.driver.create_cgsnapshot(ctxt, cgsnap)
+ model_update, snapshots = self.driver.create_cgsnapshot(ctxt, cgsnap,
+ [])
self.assertFalse(self.driver.create_snapshot.called)
self.assertEqual({'status': cgsnap['status']}, model_update)
self.driver.db.snapshot_get_all_for_cgsnapshot.\
snapshot1 = self._fake_snapshot()
snapshots = [snapshot1]
self.driver.db.snapshot_get_all_for_cgsnapshot.return_value = snapshots
- model_update, snapshots = self.driver.delete_cgsnapshot(ctxt, cgsnap)
+ model_update, snapshots = self.driver.delete_cgsnapshot(ctxt, cgsnap,
+ [])
self.driver.delete_snapshot.assert_called_once_with(snapshot1)
self.assertEqual({'status': cgsnap['status']}, model_update)
self.assertEqual('deleted', snapshot1['status'])
self.driver.db.snapshot_get_all_for_cgsnapshot = mock.Mock()
snapshots = []
self.driver.db.snapshot_get_all_for_cgsnapshot.return_value = snapshots
- model_update, snapshots = self.driver.delete_cgsnapshot(ctxt, cgsnap)
+ model_update, snapshots = self.driver.delete_cgsnapshot(ctxt, cgsnap,
+ [])
self.assertFalse(self.driver.delete_snapshot.called)
self.assertEqual({'status': cgsnap['status']}, model_update)
self.driver.db.snapshot_get_all_for_cgsnapshot.\
# create a snapshot of the consistency group
self.driver.create_cgsnapshot(context.get_admin_context(),
- self.cgsnapshot)
+ self.cgsnapshot, [])
expected = [
mock.call.createSnapshotOfVolumeSet(
# remove the consistency group
group.status = 'deleting'
self.driver.delete_consistencygroup(context.get_admin_context(),
- group)
+ group, [])
expected = [
mock.call.deleteVolumeSet(
# create a snapshot of the consistency group
self.driver.create_cgsnapshot(context.get_admin_context(),
- self.cgsnapshot)
+ self.cgsnapshot, [])
expected = [
mock.call.createSnapshotOfVolumeSet(
# create a snapshot of the consistency group
self.driver.create_cgsnapshot(context.get_admin_context(),
- cgsnapshot)
+ cgsnapshot, [])
expected = [
mock.call.createSnapshotOfVolumeSet(
# delete the snapshot of the consistency group
cgsnapshot['status'] = 'deleting'
self.driver.delete_cgsnapshot(context.get_admin_context(),
- cgsnapshot)
+ cgsnapshot, [])
mock_client.assert_has_calls(
[mock.call.getWsApiVersion()] +
# delete the consistency group
group.status = 'deleting'
- cg, vols = self.driver.delete_consistencygroup(ctxt, group)
+ cg, vols = self.driver.delete_consistencygroup(ctxt, group, [])
self.assertEqual('deleting', cg['status'])
@mock.patch('hplefthandclient.version', "1.0.6")
# delete the consistency group
group.status = 'deleting'
- cg, vols = self.driver.delete_consistencygroup(ctxt, group)
+ cg, vols = self.driver.delete_consistencygroup(ctxt, group, [])
self.assertEqual('deleting', cg['status'])
@mock.patch('hplefthandclient.version', "1.0.6")
# delete the consistency group
group.status = 'deleting'
- cg, vols = self.driver.delete_consistencygroup(ctxt, group)
+ cg, vols = self.driver.delete_consistencygroup(ctxt, group, [])
self.assertEqual('deleting', cg['status'])
@mock.patch('cinder.objects.snapshot.SnapshotList.get_all_for_cgsnapshot')
# create the conistency group snapshot
cgsnap, snaps = self.driver.create_cgsnapshot(
- ctxt, self.cgsnapshot)
+ ctxt, self.cgsnapshot, [])
self.assertEqual('available', cgsnap['status'])
@mock.patch('cinder.objects.snapshot.SnapshotList.get_all_for_cgsnapshot')
# delete the consistency group snapshot
self.cgsnapshot['status'] = 'deleting'
cgsnap, snaps = self.driver.delete_cgsnapshot(
- ctxt, self.cgsnapshot)
+ ctxt, self.cgsnapshot, [])
self.assertEqual('deleting', cgsnap['status'])
# Delete consistency group
model_update, volumes = \
- self.driver.delete_consistencygroup(ctxt, CONSISTGROUP)
+ self.driver.delete_consistencygroup(ctxt, CONSISTGROUP, [])
# Verify the result
self.assertEqual('deleted',
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.delete_consistencygroup,
- ctxt, CONSISTGROUP)
+ ctxt, CONSISTGROUP, [])
def test_create_cgsnapshot(self):
"""Test that create_cgsnapshot return successfully."""
# Create consistency group snapshot
model_update, snapshots = \
- self.driver.create_cgsnapshot(ctxt, CG_SNAPSHOT)
+ self.driver.create_cgsnapshot(ctxt, CG_SNAPSHOT, [])
# Verify the result
self.assertEqual('available',
snap['status'])
# Clean the environment
- self.driver.delete_cgsnapshot(ctxt, CG_SNAPSHOT)
- self.driver.delete_consistencygroup(ctxt, CONSISTGROUP)
+ self.driver.delete_cgsnapshot(ctxt, CG_SNAPSHOT, [])
+ self.driver.delete_consistencygroup(ctxt, CONSISTGROUP, [])
def test_create_cgsnapshot_fail_on_no_pool_space_left(self):
"""Test that create_cgsnapshot return fail when no pool space left."""
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.create_cgsnapshot,
- ctxt, CG_SNAPSHOT)
+ ctxt, CG_SNAPSHOT, [])
# Clean the environment
self.driver.volumes = None
- self.driver.delete_consistencygroup(ctxt, CONSISTGROUP)
+ self.driver.delete_consistencygroup(ctxt, CONSISTGROUP, [])
def test_delete_cgsnapshot(self):
"""Test that delete_cgsnapshot return successfully."""
self.driver.create_volume(VOLUME)
# Create consistency group snapshot
- self.driver.create_cgsnapshot(ctxt, CG_SNAPSHOT)
+ self.driver.create_cgsnapshot(ctxt, CG_SNAPSHOT, [])
# Delete consistency group snapshot
model_update, snapshots = \
- self.driver.delete_cgsnapshot(ctxt, CG_SNAPSHOT)
+ self.driver.delete_cgsnapshot(ctxt, CG_SNAPSHOT, [])
# Verify the result
self.assertEqual('deleted',
snap['status'])
# Clean the environment
- self.driver.delete_consistencygroup(ctxt, CONSISTGROUP)
+ self.driver.delete_consistencygroup(ctxt, CONSISTGROUP, [])
def test_delete_cgsnapshot_fail_on_snapshot_not_delete(self):
"""Test delete_cgsnapshot when the snapshot cannot be deleted."""
self.driver.create_volume(volume)
# Create consistency group snapshot
- self.driver.create_cgsnapshot(ctxt, CG_SNAPSHOT)
+ self.driver.create_cgsnapshot(ctxt, CG_SNAPSHOT, [])
self.assertRaises(exception.VolumeBackendAPIException,
self.driver.delete_cgsnapshot,
- ctxt, CG_SNAPSHOT)
+ ctxt, CG_SNAPSHOT, [])
def test_update_consistencygroup_without_volumes(self):
"""Test update_consistencygroup when there are no volumes specified."""
self.DPL_MOCK.delete_vdev.return_value = DATA_OUTPUT
self.DPL_MOCK.delete_cg.return_value = DATA_OUTPUT
model_update, volumes = self.dpldriver.delete_consistencygroup(
- self.context, DATA_IN_GROUP)
+ self.context, DATA_IN_GROUP, [])
self.DPL_MOCK.delete_vg.assert_called_once_with(
self._conver_uuid2hex(DATA_IN_GROUP['id']))
self.DPL_MOCK.delete_vdev.assert_called_once_with(
get_all_for_cgsnapshot.return_value = [snapshot_obj]
self.DPL_MOCK.create_vdev_snapshot.return_value = DATA_OUTPUT
model_update, snapshots = self.dpldriver.create_cgsnapshot(
- self.context, snapshot_obj)
+ self.context, snapshot_obj, [])
self.assertDictMatch({'status': 'available'}, model_update)
@mock.patch('cinder.objects.snapshot.SnapshotList.get_all_for_cgsnapshot')
get_all_for_cgsnapshot.return_value = [snapshot_obj]
self.DPL_MOCK.delete_cgsnapshot.return_value = DATA_OUTPUT
model_update, snapshots = self.dpldriver.delete_cgsnapshot(
- self.context, DATA_IN_CG_SNAPSHOT)
+ self.context, DATA_IN_CG_SNAPSHOT, [])
self.DPL_MOCK.delete_vdev_snapshot.assert_called_once_with(
self._conver_uuid2hex(DATA_IN_CG_SNAPSHOT['consistencygroup_id']),
self._conver_uuid2hex(DATA_IN_CG_SNAPSHOT['id']),
self.driver.db.volume_get_all_by_group.return_value = expected_volumes
model_update, volumes = \
- self.driver.delete_consistencygroup(mock_context, mock_cgroup)
+ self.driver.delete_consistencygroup(mock_context, mock_cgroup, [])
expected_name = self.driver._get_pgroup_name_from_id(mock_cgroup.id)
self.array.destroy_pgroup.assert_called_with(expected_name)
code=400,
text="Protection group has been destroyed."
)
- self.driver.delete_consistencygroup(mock_context, mock_cgroup)
+ self.driver.delete_consistencygroup(mock_context, mock_cgroup, [])
self.array.destroy_pgroup.assert_called_with(expected_name)
mock_delete_volume.assert_called_with(self.driver, mock_volume)
code=400,
text="Protection group does not exist"
)
- self.driver.delete_consistencygroup(mock_context, mock_cgroup)
+ self.driver.delete_consistencygroup(mock_context, mock_cgroup, [])
self.array.destroy_pgroup.assert_called_with(expected_name)
mock_delete_volume.assert_called_with(self.driver, mock_volume)
self.assertRaises(self.purestorage_module.PureHTTPError,
self.driver.delete_consistencygroup,
mock_context,
- mock_volume)
+ mock_volume,
+ [])
self.array.destroy_pgroup.side_effect = \
self.purestorage_module.PureHTTPError(
self.assertRaises(self.purestorage_module.PureHTTPError,
self.driver.delete_consistencygroup,
mock_context,
- mock_volume)
+ mock_volume,
+ [])
self.array.destroy_pgroup.side_effect = None
self.assert_error_propagates(
[self.array.destroy_pgroup],
- self.driver.delete_consistencygroup, mock_context, mock_cgroup)
+ self.driver.delete_consistencygroup, mock_context, mock_cgroup, [])
def _create_mock_cg(self):
mock_group = mock.MagicMock()
mock_snap_list.return_value = expected_snaps
model_update, snapshots = \
- self.driver.create_cgsnapshot(mock_context, mock_cgsnap)
+ self.driver.create_cgsnapshot(mock_context, mock_cgsnap, [])
cg_id = mock_cgsnap.consistencygroup_id
expected_pgroup_name = self.driver._get_pgroup_name_from_id(cg_id)
self.assert_error_propagates(
[self.array.create_pgroup_snapshot],
- self.driver.create_cgsnapshot, mock_context, mock_cgsnap)
+ self.driver.create_cgsnapshot, mock_context, mock_cgsnap, [])
@mock.patch(BASE_DRIVER_OBJ + "._get_pgroup_snap_name",
spec=pure.PureBaseVolumeDriver._get_pgroup_snap_name)
mock_snap_list.return_value = expected_snaps
model_update, snapshots = \
- self.driver.delete_cgsnapshot(mock_context, mock_cgsnap)
+ self.driver.delete_cgsnapshot(mock_context, mock_cgsnap, [])
self.array.destroy_pgroup.assert_called_with(snap_name)
self.assertEqual({'status': mock_cgsnap.status}, model_update)
code=400,
text="Protection group snapshot has been destroyed."
)
- self.driver.delete_cgsnapshot(mock_context, mock_cgsnap)
+ self.driver.delete_cgsnapshot(mock_context, mock_cgsnap, [])
self.array.destroy_pgroup.assert_called_with(snap_name)
self.array.destroy_pgroup.side_effect = \
code=400,
text="Protection group snapshot does not exist"
)
- self.driver.delete_cgsnapshot(mock_context, mock_cgsnap)
+ self.driver.delete_cgsnapshot(mock_context, mock_cgsnap, [])
self.array.destroy_pgroup.assert_called_with(snap_name)
self.array.destroy_pgroup.side_effect = \
self.assertRaises(self.purestorage_module.PureHTTPError,
self.driver.delete_cgsnapshot,
mock_context,
- mock_cgsnap)
+ mock_cgsnap,
+ [])
self.array.destroy_pgroup.side_effect = \
self.purestorage_module.PureHTTPError(
self.assertRaises(self.purestorage_module.PureHTTPError,
self.driver.delete_cgsnapshot,
mock_context,
- mock_cgsnap)
+ mock_cgsnap,
+ [])
self.array.destroy_pgroup.side_effect = None
self.assert_error_propagates(
[self.array.destroy_pgroup],
- self.driver.delete_cgsnapshot, mock_context, mock_cgsnap)
+ self.driver.delete_cgsnapshot, mock_context, mock_cgsnap, [])
def test_manage_existing(self):
ref_name = 'vol1'
consistencygroup_id=cg['id'])
cg_snapshot = self._create_cgsnapshot_in_db(cg['id'])
- model_update = self.driver.create_cgsnapshot(self.ctxt, cg_snapshot)
+ model_update = self.driver.create_cgsnapshot(self.ctxt, cg_snapshot,
+ [])
self.assertEqual('available',
model_update[0]['status'],
"CGSnapshot created failed")
for snapshot in model_update[1]:
self.assertEqual('available', snapshot['status'])
- model_update = self.driver.delete_consistencygroup(self.ctxt, cg)
+ model_update = self.driver.delete_consistencygroup(self.ctxt, cg, [])
self.assertEqual('deleted', model_update[0]['status'])
for volume in model_update[1]:
def promote_replica(self, context, volume):
pass
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
pass
def create_consistencygroup_from_src(self, context, group, volumes,
def unmanage(self, volume):
pass
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
pass
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
pass
@six.add_metaclass(abc.ABCMeta)
class ConsistencyGroupVD(object):
@abc.abstractmethod
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a cgsnapshot."""
return
@abc.abstractmethod
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a cgsnapshot."""
return
return
@abc.abstractmethod
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Deletes a consistency group."""
return
"""Disallow connection from connector for a snapshot."""
def create_consistencygroup(self, context, group):
- """Creates a consistencygroup."""
+ """Creates a consistencygroup.
+
+ :param context: the context of the caller.
+ :param group: the dictionary of the consistency group to be created.
+ :return model_update
+
+ model_update will be in this format: {'status': xxx, ......}.
+
+ If the status in model_update is 'error', the manager will throw
+ an exception and it will be caught in the try-except block in the
+ manager. If the driver throws an exception, the manager will also
+ catch it in the try-except block. The group status in the db will
+ be changed to 'error'.
+
+ For a successful operation, the driver can either build the
+ model_update and return it or return None. The group status will
+ be set to 'available'.
+ """
raise NotImplementedError()
def create_consistencygroup_from_src(self, context, group, volumes,
cinder.db.sqlalchemy.models.Volume to be precise. It cannot be
assigned to volumes_model_update. volumes_model_update is a list of
dictionaries. It has to be built by the driver. An entry will be
- in this format: ['id': xxx, 'status': xxx, ......]. model_update
- will be in this format: ['status': xxx, ......].
+ in this format: {'id': xxx, 'status': xxx, ......}. model_update
+ will be in this format: {'status': xxx, ......}.
To be consistent with other volume operations, the manager will
assume the operation is successful if no exception is thrown by
"""
raise NotImplementedError()
- def delete_consistencygroup(self, context, group):
- """Deletes a consistency group."""
+ def delete_consistencygroup(self, context, group, volumes):
+ """Deletes a consistency group.
+
+ :param context: the context of the caller.
+ :param group: the dictionary of the consistency group to be deleted.
+ :param volumes: a list of volume dictionaries in the group.
+ :return model_update, volumes_model_update
+
+ param volumes is retrieved directly from the db. It is a list of
+ cinder.db.sqlalchemy.models.Volume to be precise. It cannot be
+ assigned to volumes_model_update. volumes_model_update is a list of
+ dictionaries. It has to be built by the driver. An entry will be
+ in this format: {'id': xxx, 'status': xxx, ......}. model_update
+ will be in this format: {'status': xxx, ......}.
+
+ The driver should populate volumes_model_update and model_update
+ and return them.
+
+ The manager will check volumes_model_update and update db accordingly
+ for each volume. If the driver successfully deleted some volumes
+ but failed to delete others, it should set statuses of the volumes
+ accordingly so that the manager can update db correctly.
+
+ If the status in any entry of volumes_model_update is 'error_deleting'
+ or 'error', the status in model_update will be set to the same if it
+ is not already 'error_deleting' or 'error'.
+
+ If the status in model_update is 'error_deleting' or 'error', the
+ manager will raise an exception and the status of the group will be
+ set to 'error' in the db. If volumes_model_update is not returned by
+ the driver, the manager will set the status of every volume in the
+ group to 'error' in the except block.
+
+ If the driver raises an exception during the operation, it will be
+ caught by the try-except block in the manager. The statuses of the
+ group and all volumes in it will be set to 'error'.
+
+ For a successful operation, the driver can either build the
+ model_update and volumes_model_update and return them or
+ return None, None. The statuses of the group and all volumes
+ will be set to 'deleted' after the manager deletes them from db.
+ """
raise NotImplementedError()
def update_consistencygroup(self, context, group,
"""
raise NotImplementedError()
- def create_cgsnapshot(self, context, cgsnapshot):
- """Creates a cgsnapshot."""
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
+ """Creates a cgsnapshot.
+
+ :param context: the context of the caller.
+ :param cgsnapshot: the dictionary of the cgsnapshot to be created.
+ :param snapshots: a list of snapshot dictionaries in the cgsnapshot.
+ :return model_update, snapshots_model_update
+
+ param snapshots is retrieved directly from the db. It is a list of
+ cinder.db.sqlalchemy.models.Snapshot to be precise. It cannot be
+ assigned to snapshots_model_update. snapshots_model_update is a list
+ of dictionaries. It has to be built by the driver. An entry will be
+ in this format: {'id': xxx, 'status': xxx, ......}. model_update
+ will be in this format: {'status': xxx, ......}.
+
+ The driver should populate snapshots_model_update and model_update
+ and return them.
+
+ The manager will check snapshots_model_update and update db accordingly
+ for each snapshot. If the driver successfully deleted some snapshots
+ but failed to delete others, it should set statuses of the snapshots
+ accordingly so that the manager can update db correctly.
+
+ If the status in any entry of snapshots_model_update is 'error', the
+ status in model_update will be set to the same if it is not already
+ 'error'.
+
+ If the status in model_update is 'error', the manager will raise an
+ exception and the status of cgsnapshot will be set to 'error' in the
+ db. If snapshots_model_update is not returned by the driver, the
+ manager will set the status of every snapshot to 'error' in the except
+ block.
+
+ If the driver raises an exception during the operation, it will be
+ caught by the try-except block in the manager and the statuses of
+ cgsnapshot and all snapshots will be set to 'error'.
+
+ For a successful operation, the driver can either build the
+ model_update and snapshots_model_update and return them or
+ return None, None. The statuses of cgsnapshot and all snapshots
+ will be set to 'available' at the end of the manager function.
+ """
raise NotImplementedError()
- def delete_cgsnapshot(self, context, cgsnapshot):
- """Deletes a cgsnapshot."""
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
+ """Deletes a cgsnapshot.
+
+ :param context: the context of the caller.
+ :param cgsnapshot: the dictionary of the cgsnapshot to be deleted.
+ :param snapshots: a list of snapshot dictionaries in the cgsnapshot.
+ :return model_update, snapshots_model_update
+
+ param snapshots is retrieved directly from the db. It is a list of
+ cinder.db.sqlalchemy.models.Snapshot to be precise. It cannot be
+ assigned to snapshots_model_update. snapshots_model_update is a list
+ of dictionaries. It has to be built by the driver. An entry will be
+ in this format: {'id': xxx, 'status': xxx, ......}. model_update
+ will be in this format: {'status': xxx, ......}.
+
+ The driver should populate snapshots_model_update and model_update
+ and return them.
+
+ The manager will check snapshots_model_update and update db accordingly
+ for each snapshot. If the driver successfully deleted some snapshots
+ but failed to delete others, it should set statuses of the snapshots
+ accordingly so that the manager can update db correctly.
+
+ If the status in any entry of snapshots_model_update is
+ 'error_deleting' or 'error', the status in model_update will be set to
+ the same if it is not already 'error_deleting' or 'error'.
+
+ If the status in model_update is 'error_deleting' or 'error', the
+ manager will raise an exception and the status of cgsnapshot will be
+ set to 'error' in the db. If snapshots_model_update is not returned by
+ the driver, the manager will set the status of every snapshot to
+ 'error' in the except block.
+
+ If the driver raises an exception during the operation, it will be
+ caught by the try-except block in the manager and the statuses of
+ cgsnapshot and all snapshots will be set to 'error'.
+
+ For a successful operation, the driver can either build the
+ model_update and snapshots_model_update and return them or
+ return None, None. The statuses of cgsnapshot and all snapshots
+ will be set to 'deleted' after the manager deletes them from db.
+ """
raise NotImplementedError()
def clone_image(self, volume, image_location, image_id, image_meta,
raise exception.VolumeBackendAPIException(
_('Unable to create consistency group %s') % gid)
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Delete the Dell SC profile associated with this consistency group.
:param context: the context of the caller.
raise exception.VolumeBackendAPIException(
_('Unable to update consistency group %s') % gid)
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Takes a snapshot of the consistency group.
:param context: the context of the caller.
raise exception.VolumeBackendAPIException(
_('Unable to snap Consistency Group %s') % cgid)
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a cgsnapshot.
If profile isn't found return success. If failed to delete the
"""Creates a consistencygroup."""
return self.cli.create_consistencygroup(context, group)
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Deletes a consistency group."""
return self.cli.delete_consistencygroup(
self, context, group)
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a cgsnapshot."""
return self.cli.create_cgsnapshot(
self, context, cgsnapshot)
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a cgsnapshot."""
return self.cli.delete_cgsnapshot(self, context, cgsnapshot)
"""Creates a consistencygroup."""
return self.cli.create_consistencygroup(context, group)
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Deletes a consistency group."""
return self.cli.delete_consistencygroup(
self, context, group)
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a cgsnapshot."""
return self.cli.create_cgsnapshot(
self, context, cgsnapshot)
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a cgsnapshot."""
return self.cli.delete_cgsnapshot(self, context, cgsnapshot)
"""Creates a consistencygroup."""
self.common.create_consistencygroup(context, group)
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Deletes a consistency group."""
- volumes = self.db.volume_get_all_by_group(context, group['id'])
return self.common.delete_consistencygroup(
context, group, volumes)
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a cgsnapshot."""
return self.common.create_cgsnapshot(context, cgsnapshot, self.db)
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a cgsnapshot."""
return self.common.delete_cgsnapshot(context, cgsnapshot, self.db)
"""Creates a consistencygroup."""
self.common.create_consistencygroup(context, group)
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Deletes a consistency group."""
- volumes = self.db.volume_get_all_by_group(context, group['id'])
return self.common.delete_consistencygroup(
context, group, volumes)
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a cgsnapshot."""
return self.common.create_cgsnapshot(context, cgsnapshot, self.db)
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a cgsnapshot."""
return self.common.delete_cgsnapshot(context, cgsnapshot, self.db)
ver='v2')
return {'status': 'available'}
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Deletes a consistency group."""
self.client.req('consistency-groups', 'DELETE', name=group['id'],
ver='v2')
.replace('-', ''),
'snap': cgsnapshot['id'].replace('-', '')}
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a cgsnapshot."""
data = {'consistency-group-id': cgsnapshot['consistencygroup_id'],
'snapshot-set-name': self._get_cgsnap_name(cgsnapshot)}
return model_update, snapshots
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a cgsnapshot."""
self.client.req('snapshot-sets', 'DELETE',
name=self._get_cgsnap_name(cgsnapshot), ver='v2')
model_update = {'status': 'available'}
return model_update
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Delete consistency group of GPFS volumes."""
cgname = "consisgroup-%s" % group['id']
fsdev = self._gpfs_device
return model_update, volumes
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Create snapshot of a consistency group of GPFS volumes."""
snapshots = self.db.snapshot_get_all_for_cgsnapshot(
context, cgsnapshot['id'])
return model_update, snapshots
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Delete snapshot of a consistency group of GPFS volumes."""
snapshots = self.db.snapshot_get_all_for_cgsnapshot(
context, cgsnapshot['id'])
model_update = {'status': 'available'}
return model_update
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Deletes a consistency group.
IBM Storwize will delete the volumes of the CG.
{'vol': volume['name'], 'exception': err})
return model_update, volumes
- def create_cgsnapshot(self, ctxt, cgsnapshot):
+ def create_cgsnapshot(self, ctxt, cgsnapshot, snapshots):
"""Creates a cgsnapshot."""
# Use cgsnapshot id as cg name
cg_name = 'cg_snap-' + cgsnapshot['id']
return model_update, snapshots_model
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a cgsnapshot."""
cgsnapshot_id = cgsnapshot['id']
cg_name = 'cg_snap-' + cgsnapshot_id
return self.xiv_ds8k_proxy.create_consistencygroup(context, group)
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Deletes a consistency group."""
return self.xiv_ds8k_proxy.delete_consistencygroup(context, group)
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a consistency group snapshot."""
return self.xiv_ds8k_proxy.create_cgsnapshot(context, cgsnapshot)
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a consistency group snapshot."""
return self.xiv_ds8k_proxy.delete_cgsnapshot(context, cgsnapshot)
'reason': six.text_type(e)}
raise exception.VolumeBackendAPIException(data=msg)
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Delete a consistency group."""
ret = 0
volumes = self.db.volume_get_all_by_group(
model_update['status'] = 'deleted'
return model_update, volumes
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a cgsnapshot."""
snapshots = objects.SnapshotList().get_all_for_cgsnapshot(
context, cgsnapshot['id'])
return model_update, snapshots
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a cgsnapshot."""
snapshots = objects.SnapshotList().get_all_for_cgsnapshot(
context, cgsnapshot['id'])
return None, None
@log_debug_trace
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Deletes a consistency group."""
try:
return None, None, None
@log_debug_trace
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a cgsnapshot."""
cg_id = cgsnapshot.consistencygroup_id
"Snapshot: %s"), err.text)
@log_debug_trace
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a cgsnapshot."""
pgsnap_name = self._get_pgroup_snap_name(cgsnapshot)
finally:
self._logout(common)
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
common = self._login()
try:
return common.delete_consistencygroup(context, group)
finally:
self._logout(common)
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
common = self._login()
try:
return common.create_cgsnapshot(context, cgsnapshot)
finally:
self._logout(common)
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
common = self._login()
try:
return common.delete_cgsnapshot(context, cgsnapshot)
finally:
self._logout(common)
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
common = self._login()
try:
return common.delete_consistencygroup(context, group)
finally:
self._logout(common)
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
common = self._login()
try:
return common.create_cgsnapshot(context, cgsnapshot)
finally:
self._logout(common)
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
common = self._login()
try:
return common.delete_cgsnapshot(context, cgsnapshot)
context, group, volumes, cgsnapshot, snapshots, source_cg,
source_vols)
- def delete_consistencygroup(self, context, group):
+ def delete_consistencygroup(self, context, group, volumes):
"""Deletes a consistency group."""
return self.proxy.delete_consistencygroup(context, group)
return self.proxy.update_consistencygroup(context, group, add_volumes,
remove_volumes)
- def create_cgsnapshot(self, context, cgsnapshot):
+ def create_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Creates a consistency group snapshot."""
return self.proxy.create_cgsnapshot(context, cgsnapshot)
- def delete_cgsnapshot(self, context, cgsnapshot):
+ def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
"""Deletes a consistency group snapshot."""
return self.proxy.delete_cgsnapshot(context, cgsnapshot)
context = context.elevated()
status = 'available'
- model_update = False
+ model_update = None
self._notify_about_consistencygroup_usage(
context, group, "create.start")
group)
if model_update:
- group.update(model_update)
- group.save()
+ if model_update['status'] == 'error':
+ msg = (_('Create consistency group failed.'))
+ LOG.error(msg,
+ resource={'type': 'consistency_group',
+ 'id': group.id})
+ raise exception.VolumeDriverException(message=msg)
+ else:
+ group.update(model_update)
+ group.save()
except Exception:
with excutils.save_and_reraise_exception():
group.status = 'error'
self._notify_about_consistencygroup_usage(
context, group, "delete.start")
+ volumes_model_update = None
+ model_update = None
try:
utils.require_driver_initialized(self.driver)
- model_update, volumes = self.driver.delete_consistencygroup(
- context, group)
+ model_update, volumes_model_update = (
+ self.driver.delete_consistencygroup(context, group, volumes))
- if volumes:
- for volume in volumes:
+ if volumes_model_update:
+ for volume in volumes_model_update:
update = {'status': volume['status']}
self.db.volume_update(context, volume['id'],
update)
except Exception:
with excutils.save_and_reraise_exception():
- group.status = 'error_deleting'
+ group.status = 'error'
group.save()
+ # Update volume status to 'error' if driver returns
+ # None for volumes_model_update.
+ if not volumes_model_update:
+ for vol in volumes:
+ self.db.volume_update(
+ context, vol['id'], {'status': 'error'})
# Get reservations for group
try:
self._notify_about_cgsnapshot_usage(
context, cgsnapshot, "create.start")
+ snapshots_model_update = None
+ model_update = None
try:
utils.require_driver_initialized(self.driver)
for snapshot in snapshots:
snapshot.context = caller_context
- model_update, snapshots = \
- self.driver.create_cgsnapshot(context, cgsnapshot)
+ model_update, snapshots_model_update = (
+ self.driver.create_cgsnapshot(context, cgsnapshot,
+ snapshots))
- if snapshots:
- for snapshot in snapshots:
+ if snapshots_model_update:
+ for snap_model in snapshots_model_update:
# Update db if status is error
- if snapshot['status'] == 'error':
- update = {'status': snapshot['status']}
-
- # TODO(thangp): Switch over to use snapshot.update()
- # after cgsnapshot-objects bugs are fixed
- self.db.snapshot_update(context, snapshot['id'],
- update)
- # If status for one snapshot is error, make sure
- # the status for the cgsnapshot is also error
- if model_update['status'] != 'error':
- model_update['status'] = snapshot['status']
+ if snap_model['status'] == 'error':
+ # NOTE(xyang): snapshots is a list of snapshot objects.
+ # snapshots_model_update should be a list of dicts.
+ snap = next((item for item in snapshots if
+ item.id == snap_model['id']), None)
+ if snap:
+ snap.status = snap_model['status']
+ snap.save()
+
+ if (snap_model['status'] in ['error_deleting', 'error'] and
+ model_update['status'] not in
+ ['error_deleting', 'error']):
+ model_update['status'] = snap_model['status']
if model_update:
if model_update['status'] == 'error':
LOG.error(msg)
raise exception.VolumeDriverException(message=msg)
- except Exception:
+ except exception.CinderException:
with excutils.save_and_reraise_exception():
cgsnapshot.status = 'error'
cgsnapshot.save()
+ # Update snapshot status to 'error' if driver returns
+ # None for snapshots_model_update.
+ if not snapshots_model_update:
+ for snapshot in snapshots:
+ snapshot.status = 'error'
+ snapshot.save()
for snapshot in snapshots:
volume_id = snapshot['volume_id']
self._notify_about_cgsnapshot_usage(
context, cgsnapshot, "delete.start")
+ snapshots_model_update = None
+ model_update = None
try:
utils.require_driver_initialized(self.driver)
# but it is not a requirement for all drivers.
cgsnapshot.context = caller_context
for snapshot in snapshots:
- snapshot['context'] = caller_context
-
- model_update, snapshots = \
- self.driver.delete_cgsnapshot(context, cgsnapshot)
-
- if snapshots:
- for snapshot in snapshots:
- update = {'status': snapshot['status']}
+ snapshot.context = caller_context
- # TODO(thangp): Switch over to use snapshot.update()
- # after cgsnapshot-objects bugs are fixed
- self.db.snapshot_update(context, snapshot['id'],
- update)
- if snapshot['status'] in ['error_deleting', 'error'] and \
- model_update['status'] not in \
- ['error_deleting', 'error']:
- model_update['status'] = snapshot['status']
+ model_update, snapshots_model_update = (
+ self.driver.delete_cgsnapshot(context, cgsnapshot,
+ snapshots))
+
+ if snapshots_model_update:
+ for snap_model in snapshots_model_update:
+ # NOTE(xyang): snapshots is a list of snapshot objects.
+ # snapshots_model_update should be a list of dicts.
+ snap = next((item for item in snapshots if
+ item.id == snap_model['id']), None)
+ if snap:
+ snap.status = snap_model['status']
+ snap.save()
+
+ if (snap_model['status'] in ['error_deleting', 'error'] and
+ model_update['status'] not in
+ ['error_deleting', 'error']):
+ model_update['status'] = snap_model['status']
if model_update:
if model_update['status'] in ['error_deleting', 'error']:
cgsnapshot.update(model_update)
cgsnapshot.save()
- except Exception:
+ except exception.CinderException:
with excutils.save_and_reraise_exception():
- cgsnapshot.status = 'error_deleting'
+ cgsnapshot.status = 'error'
cgsnapshot.save()
+ # Update snapshot status to 'error' if driver returns
+ # None for snapshots_model_update.
+ if not snapshots_model_update:
+ for snapshot in snapshots:
+ snapshot.status = 'error'
+ snapshot.save()
for snapshot in snapshots:
# Get reservations
self.db.volume_glance_metadata_delete_by_snapshot(context,
snapshot['id'])
- # TODO(thangp): Switch over to use snapshot.delete()
+ # TODO(thangp): Switch over to use snapshot.destroy()
# after cgsnapshot-objects bugs are fixed
self.db.snapshot_destroy(context, snapshot['id'])