Search in sources :

Example 1 with VolumeGroupSnapshotSessionRelinkTargetsParam

use of com.emc.storageos.model.application.VolumeGroupSnapshotSessionRelinkTargetsParam 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);
}
Also used : SnapshotSessionNewTargetsParam(com.emc.storageos.model.block.SnapshotSessionNewTargetsParam) WaitForTasks(com.emc.sa.service.vipr.tasks.WaitForTasks) Tasks(com.emc.vipr.client.Tasks) VolumeGroupSnapshotSessionRelinkTargetsParam(com.emc.storageos.model.application.VolumeGroupSnapshotSessionRelinkTargetsParam) TaskList(com.emc.storageos.model.TaskList) VolumeGroupSnapshotSessionLinkTargetsParam(com.emc.storageos.model.application.VolumeGroupSnapshotSessionLinkTargetsParam)

Example 2 with VolumeGroupSnapshotSessionRelinkTargetsParam

use of com.emc.storageos.model.application.VolumeGroupSnapshotSessionRelinkTargetsParam 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;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) VolumeGroupSnapshotSessionUnlinkTargetsParam(com.emc.storageos.model.application.VolumeGroupSnapshotSessionUnlinkTargetsParam) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) SnapshotSessionLinkTargetsParam(com.emc.storageos.model.block.SnapshotSessionLinkTargetsParam) VolumeGroupSnapshotSessionLinkTargetsParam(com.emc.storageos.model.application.VolumeGroupSnapshotSessionLinkTargetsParam) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) VolumeGroupSnapshotSessionRelinkTargetsParam(com.emc.storageos.model.application.VolumeGroupSnapshotSessionRelinkTargetsParam) SnapshotSessionRelinkTargetsParam(com.emc.storageos.model.block.SnapshotSessionRelinkTargetsParam) VolumeGroupSnapshotSessionRelinkTargetsParam(com.emc.storageos.model.application.VolumeGroupSnapshotSessionRelinkTargetsParam) ResourceOperationTypeEnum(com.emc.storageos.model.ResourceOperationTypeEnum) SnapshotSessionUnlinkTargetsParam(com.emc.storageos.model.block.SnapshotSessionUnlinkTargetsParam) VolumeGroupSnapshotSessionUnlinkTargetsParam(com.emc.storageos.model.application.VolumeGroupSnapshotSessionUnlinkTargetsParam)

Aggregations

TaskList (com.emc.storageos.model.TaskList)2 VolumeGroupSnapshotSessionLinkTargetsParam (com.emc.storageos.model.application.VolumeGroupSnapshotSessionLinkTargetsParam)2 VolumeGroupSnapshotSessionRelinkTargetsParam (com.emc.storageos.model.application.VolumeGroupSnapshotSessionRelinkTargetsParam)2 WaitForTasks (com.emc.sa.service.vipr.tasks.WaitForTasks)1 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)1 VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)1 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)1 ResourceOperationTypeEnum (com.emc.storageos.model.ResourceOperationTypeEnum)1 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)1 VolumeGroupSnapshotSessionUnlinkTargetsParam (com.emc.storageos.model.application.VolumeGroupSnapshotSessionUnlinkTargetsParam)1 SnapshotSessionLinkTargetsParam (com.emc.storageos.model.block.SnapshotSessionLinkTargetsParam)1 SnapshotSessionNewTargetsParam (com.emc.storageos.model.block.SnapshotSessionNewTargetsParam)1 SnapshotSessionRelinkTargetsParam (com.emc.storageos.model.block.SnapshotSessionRelinkTargetsParam)1 SnapshotSessionUnlinkTargetsParam (com.emc.storageos.model.block.SnapshotSessionUnlinkTargetsParam)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 Tasks (com.emc.vipr.client.Tasks)1 URI (java.net.URI)1