Search in sources :

Example 1 with VolumeGroupSnapshotSessionUnlinkTargetsParam

use of com.emc.storageos.model.application.VolumeGroupSnapshotSessionUnlinkTargetsParam in project coprhd-controller by CoprHD.

the class UnlinkSnapshotSessionForApplication method doExecute.

@Override
protected Tasks<TaskResourceRep> doExecute() throws Exception {
    VolumeGroupSnapshotSessionUnlinkTargetsParam input = new VolumeGroupSnapshotSessionUnlinkTargetsParam();
    input.setSnapshotSessions(snapshotSessions);
    input.setPartial(true);
    List<SnapshotSessionUnlinkTargetParam> linkedTargets = Lists.newArrayList();
    if (existingLinkedSnapshotIds != null) {
        for (String linkedSnapshot : existingLinkedSnapshotIds) {
            SnapshotSessionUnlinkTargetParam param = new SnapshotSessionUnlinkTargetParam();
            param.setId(uri(linkedSnapshot));
            if (deleteTarget != null) {
                param.setDeleteTarget(deleteTarget);
            }
            linkedTargets.add(param);
        }
    }
    input.setLinkedTargets(linkedTargets);
    TaskList taskList = getClient().application().unlinkApplicationSnapshotSession(applicationId, input);
    return new Tasks<TaskResourceRep>(getClient().auth().getClient(), taskList.getTaskList(), TaskResourceRep.class);
}
Also used : WaitForTasks(com.emc.sa.service.vipr.tasks.WaitForTasks) Tasks(com.emc.vipr.client.Tasks) SnapshotSessionUnlinkTargetParam(com.emc.storageos.model.block.SnapshotSessionUnlinkTargetParam) TaskList(com.emc.storageos.model.TaskList) VolumeGroupSnapshotSessionUnlinkTargetsParam(com.emc.storageos.model.application.VolumeGroupSnapshotSessionUnlinkTargetsParam)

Example 2 with VolumeGroupSnapshotSessionUnlinkTargetsParam

use of com.emc.storageos.model.application.VolumeGroupSnapshotSessionUnlinkTargetsParam 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 VolumeGroupSnapshotSessionUnlinkTargetsParam (com.emc.storageos.model.application.VolumeGroupSnapshotSessionUnlinkTargetsParam)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 VolumeGroupSnapshotSessionLinkTargetsParam (com.emc.storageos.model.application.VolumeGroupSnapshotSessionLinkTargetsParam)1 VolumeGroupSnapshotSessionRelinkTargetsParam (com.emc.storageos.model.application.VolumeGroupSnapshotSessionRelinkTargetsParam)1 SnapshotSessionLinkTargetsParam (com.emc.storageos.model.block.SnapshotSessionLinkTargetsParam)1 SnapshotSessionRelinkTargetsParam (com.emc.storageos.model.block.SnapshotSessionRelinkTargetsParam)1 SnapshotSessionUnlinkTargetParam (com.emc.storageos.model.block.SnapshotSessionUnlinkTargetParam)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