use of com.emc.storageos.model.application.VolumeGroupSnapshotSessionLinkTargetsParam in project coprhd-controller by CoprHD.
the class LinkSnapshotSessionForApplication method doExecute.
@Override
protected Tasks<TaskResourceRep> doExecute() throws Exception {
TaskList taskList = null;
if (linkedTargets != null && !linkedTargets.isEmpty()) {
VolumeGroupSnapshotSessionRelinkTargetsParam relinkParam = new VolumeGroupSnapshotSessionRelinkTargetsParam();
relinkParam.setLinkedTargetIds(linkedTargets);
relinkParam.setPartial(true);
relinkParam.setSnapshotSessions(snapSessions);
taskList = getClient().application().relinkApplicationSnapshotSession(applicationId, relinkParam);
} else {
VolumeGroupSnapshotSessionLinkTargetsParam input = new VolumeGroupSnapshotSessionLinkTargetsParam();
input.setSnapshotSessions(snapSessions);
input.setPartial(true);
SnapshotSessionNewTargetsParam newLinkedTargets = new SnapshotSessionNewTargetsParam();
newLinkedTargets.setCopyMode(copyMode);
newLinkedTargets.setCount(count);
newLinkedTargets.setTargetName(targetName);
input.setNewLinkedTargets(newLinkedTargets);
taskList = getClient().application().linkApplicationSnapshotSession(applicationId, input);
}
return new Tasks<TaskResourceRep>(getClient().auth().getClient(), taskList.getTaskList(), TaskResourceRep.class);
}
use of com.emc.storageos.model.application.VolumeGroupSnapshotSessionLinkTargetsParam in project coprhd-controller by CoprHD.
the class VolumeGroupService method performVolumeGroupSnapshotSessionOperation.
/*
* Wrapper of BlockConsistencyGroupService methods for snapshot session operations
*
* @param volumeGroupId
*
* @param param
*
* @return a TaskList
*/
private TaskList performVolumeGroupSnapshotSessionOperation(final URI volumeGroupId, final VolumeGroupSnapshotSessionOperationParam param, OperationTypeEnum opType) {
List<BlockSnapshotSession> snapSessions = getSnapshotSessionsGroupedBySnapSessionset(volumeGroupId, param);
// Check for pending tasks
VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, volumeGroupId);
if (opType == OperationTypeEnum.RESTORE_VOLUME_GROUP_SNAPSHOT_SESSION) {
checkForApplicationPendingTasks(volumeGroup, _dbClient, true);
} else {
checkForApplicationPendingTasks(volumeGroup, _dbClient, false);
}
auditOp(opType, true, AuditLogManager.AUDITOP_BEGIN, volumeGroupId.toString(), param.getSnapshotSessions());
TaskList taskList = new TaskList();
Table<URI, String, BlockSnapshotSession> storageRgToSnapshot = ControllerUtils.getSnapshotSessionForStorageReplicationGroup(snapSessions, _dbClient);
for (Cell<URI, String, BlockSnapshotSession> cell : storageRgToSnapshot.cellSet()) {
BlockSnapshotSession session = cell.getValue();
log.info("{} for replication group {}", opType.getDescription(), cell.getColumnKey());
ResourceOperationTypeEnum oprEnum = null;
try {
// should not be null
URI cgUri = session.getConsistencyGroup();
URI sessionUri = session.getId();
log.info("CG: {}, Session: {}", cgUri, session.getLabel());
switch(opType) {
case RESTORE_VOLUME_GROUP_SNAPSHOT_SESSION:
oprEnum = ResourceOperationTypeEnum.RESTORE_SNAPSHOT_SESSION;
taskList.addTask(_blockConsistencyGroupService.restoreConsistencyGroupSnapshotSession(cgUri, sessionUri));
break;
case DELETE_VOLUME_GROUP_SNAPSHOT_SESSION:
oprEnum = ResourceOperationTypeEnum.DELETE_CONSISTENCY_GROUP_SNAPSHOT_SESSION;
taskList.getTaskList().addAll(_blockConsistencyGroupService.deactivateConsistencyGroupSnapshotSession(cgUri, sessionUri).getTaskList());
break;
case LINK_VOLUME_GROUP_SNAPSHOT_SESSION_TARGET:
oprEnum = ResourceOperationTypeEnum.LINK_SNAPSHOT_SESSION_TARGETS;
SnapshotSessionLinkTargetsParam linkParam = new SnapshotSessionLinkTargetsParam(((VolumeGroupSnapshotSessionLinkTargetsParam) param).getNewLinkedTargets());
taskList.getTaskList().addAll(_blockConsistencyGroupService.linkTargetVolumes(cgUri, sessionUri, linkParam).getTaskList());
break;
case RELINK_VOLUME_GROUP_SNAPSHOT_SESSION_TARGET:
oprEnum = ResourceOperationTypeEnum.RELINK_CONSISTENCY_GROUP_SNAPSHOT_SESSION_TARGETS;
SnapshotSessionRelinkTargetsParam relinkParam = new SnapshotSessionRelinkTargetsParam(getRelinkTargetIdsForSession((VolumeGroupSnapshotSessionRelinkTargetsParam) param, session, snapSessions.size()));
taskList.getTaskList().addAll(_blockConsistencyGroupService.relinkTargetVolumes(cgUri, sessionUri, relinkParam).getTaskList());
break;
case UNLINK_VOLUME_GROUP_SNAPSHOT_SESSION_TARGET:
oprEnum = ResourceOperationTypeEnum.UNLINK_SNAPSHOT_SESSION_TARGETS;
SnapshotSessionUnlinkTargetsParam unlinkParam = new SnapshotSessionUnlinkTargetsParam(getUnlinkTargetIdsForSession((VolumeGroupSnapshotSessionUnlinkTargetsParam) param, session));
taskList.addTask(_blockConsistencyGroupService.unlinkTargetVolumesForSession(cgUri, sessionUri, unlinkParam));
break;
default:
log.error("Unsupported operation {}", opType.getDescription());
break;
}
} catch (InternalException | APIException e) {
String errMsg = String.format("Exception occurred while performing %s on Replication group %s", opType.getDescription(), cell.getColumnKey());
log.error(errMsg, e);
TaskResourceRep task = BlockServiceUtils.createFailedTaskOnSnapshotSession(_dbClient, session, oprEnum, e);
taskList.addTask(task);
} catch (Exception ex) {
String errMsg = String.format("Unexpected Exception occurred while performing %s on Replication group %s", opType.getDescription(), cell.getColumnKey());
log.error(errMsg, ex);
}
}
auditOp(opType, true, AuditLogManager.AUDITOP_END, volumeGroupId.toString(), param.getSnapshotSessions());
return taskList;
}
Aggregations