Search in sources :

Example 16 with VPlexController

use of com.emc.storageos.vplexcontroller.VPlexController in project coprhd-controller by CoprHD.

the class MigrationService method pauseMigration.

/**
 * Pause a migration that is in progress.
 *
 * @prereq The migration is in progress
 *
 * @param id the URN of a ViPR migration.
 *
 * @brief Pause a migration.
 * @return A TaskResourceRep
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/pause")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep pauseMigration(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, Migration.class, "id");
    Migration migration = queryResource(id);
    if (!BulkList.MigrationFilter.isUserAuthorizedForMigration(migration, getUserFromContext(), _permissionsHelper)) {
        StorageOSUser user = getUserFromContext();
        throw APIException.forbidden.insufficientPermissionsForUser(user.getName());
    }
    String status = migration.getMigrationStatus();
    String migrationName = migration.getLabel();
    if (status == null || status.isEmpty() || migrationName == null || migrationName.isEmpty()) {
        throw APIException.badRequests.migrationHasntStarted(id.toString());
    }
    if (status.equalsIgnoreCase(VPlexMigrationInfo.MigrationStatus.COMPLETE.getStatusValue()) || status.equalsIgnoreCase(VPlexMigrationInfo.MigrationStatus.ERROR.getStatusValue()) || status.equalsIgnoreCase(VPlexMigrationInfo.MigrationStatus.COMMITTED.getStatusValue()) || status.equalsIgnoreCase(VPlexMigrationInfo.MigrationStatus.CANCELLED.getStatusValue())) {
        throw APIException.badRequests.migrationCantBePaused(migrationName, status);
    }
    URI volId = migration.getVolume();
    Volume vplexVol = _dbClient.queryObject(Volume.class, volId);
    // Create a unique task id.
    String taskId = UUID.randomUUID().toString();
    // Create a task for the volume and set the
    // initial task state to pending.
    Operation op = _dbClient.createTaskOpStatus(Volume.class, volId, taskId, ResourceOperationTypeEnum.PAUSE_MIGRATION);
    TaskResourceRep task = toTask(vplexVol, taskId, op);
    if (status.equalsIgnoreCase(VPlexMigrationInfo.MigrationStatus.PAUSED.getStatusValue())) {
        // it has been paused.
        s_logger.info("Migration {} has been paused", id);
        op.ready();
        vplexVol.getOpStatus().createTaskStatus(taskId, op);
        _dbClient.persistObject(vplexVol);
        return task;
    }
    try {
        VPlexController controller = _vplexBlockServiceApi.getController();
        controller.pauseMigration(vplexVol.getStorageController(), id, taskId);
    } catch (InternalException e) {
        s_logger.error("Error", e);
        String errMsg = String.format("Error: %s", e.getMessage());
        task.setState(Operation.Status.error.name());
        task.setMessage(errMsg);
        op.error(e);
        vplexVol.getOpStatus().updateTaskStatus(taskId, op);
        _dbClient.persistObject(vplexVol);
    }
    return task;
}
Also used : VPlexController(com.emc.storageos.vplexcontroller.VPlexController) Volume(com.emc.storageos.db.client.model.Volume) Migration(com.emc.storageos.db.client.model.Migration) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 17 with VPlexController

use of com.emc.storageos.vplexcontroller.VPlexController in project coprhd-controller by CoprHD.

the class VPlexBlockFullCopyApiImpl method establishVolumeAndFullCopyGroupRelation.

/**
 * {@inheritDoc}
 */
@Override
public TaskList establishVolumeAndFullCopyGroupRelation(Volume sourceVolume, Volume fullCopyVolume) {
    // Create the task list.
    TaskList taskList = new TaskList();
    // Create a unique task id.
    String taskId = UUID.randomUUID().toString();
    // Get the id of the source volume.
    URI sourceVolumeURI = sourceVolume.getId();
    // Get the id of the full copy volume.
    URI fullCopyURI = fullCopyVolume.getId();
    // Get the storage system for the source volume.
    StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceVolume.getStorageController());
    URI sourceSystemURI = sourceSystem.getId();
    // Create the task on the full copy volume.
    Operation op = _dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, ResourceOperationTypeEnum.ESTABLISH_VOLUME_FULL_COPY);
    fullCopyVolume.getOpStatus().put(taskId, op);
    TaskResourceRep fullCopyVolumeTask = TaskMapper.toTask(fullCopyVolume, taskId, op);
    taskList.getTaskList().add(fullCopyVolumeTask);
    // Invoke the controller.
    try {
        VPlexController controller = getController(VPlexController.class, DiscoveredDataObject.Type.vplex.toString());
        controller.establishVolumeAndFullCopyGroupRelation(sourceSystemURI, sourceVolumeURI, fullCopyURI, taskId);
    } catch (InternalException ie) {
        s_logger.error("Controller error", ie);
        // corresponding tasks.
        if (op != null) {
            op.error(ie);
            fullCopyVolume.getOpStatus().updateTaskStatus(taskId, op);
            _dbClient.persistObject(fullCopyVolume);
            fullCopyVolumeTask.setState(op.getStatus());
            fullCopyVolumeTask.setMessage(op.getMessage());
        }
    }
    return taskList;
}
Also used : VPlexController(com.emc.storageos.vplexcontroller.VPlexController) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 18 with VPlexController

use of com.emc.storageos.vplexcontroller.VPlexController in project coprhd-controller by CoprHD.

the class VPlexBlockFullCopyApiImpl method resynchronizeCopy.

/**
 * {@inheritDoc}
 */
@Override
public TaskList resynchronizeCopy(Volume sourceVolume, Volume fullCopyVolume) {
    // Create the task list.
    TaskList taskList = new TaskList();
    // Create a unique task id.
    String taskId = UUID.randomUUID().toString();
    // If the source is in a CG, then we will resynchronize the corresponding
    // full copies for all the volumes in the CG. Since we did not allow
    // full copies for volumes or snaps in CGs prior to Jedi, there should
    // be a full copy for all volumes in the CG.
    Map<URI, Volume> fullCopyMap = getFullCopySetMap(sourceVolume, fullCopyVolume);
    Set<URI> fullCopyURIs = fullCopyMap.keySet();
    // Get the storage system for the source volume.
    StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceVolume.getStorageController());
    URI sourceSystemURI = sourceSystem.getId();
    // Create the resynchronize task on the full copy volumes.
    for (URI fullCopyURI : fullCopyURIs) {
        Operation op = _dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, ResourceOperationTypeEnum.RESYNCHRONIZE_VOLUME_FULL_COPY);
        fullCopyMap.get(fullCopyURI).getOpStatus().put(taskId, op);
        TaskResourceRep fullCopyVolumeTask = TaskMapper.toTask(fullCopyMap.get(fullCopyURI), taskId, op);
        taskList.getTaskList().add(fullCopyVolumeTask);
    }
    addConsistencyGroupTasks(Arrays.asList(sourceVolume), taskList, taskId, ResourceOperationTypeEnum.RESYNCHRONIZE_CONSISTENCY_GROUP_FULL_COPY);
    // Invoke the controller.
    try {
        VPlexController controller = getController(VPlexController.class, DiscoveredDataObject.Type.vplex.toString());
        controller.resyncFullCopy(sourceSystemURI, new ArrayList<>(fullCopyURIs), taskId);
    } catch (InternalException ie) {
        s_logger.error("Controller error: Failed to resync volume full copy {}", fullCopyVolume.getId(), ie);
        handleFailedRequest(taskId, taskList, new ArrayList<>(fullCopyMap.values()), ie, false);
    }
    return taskList;
}
Also used : VPlexController(com.emc.storageos.vplexcontroller.VPlexController) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 19 with VPlexController

use of com.emc.storageos.vplexcontroller.VPlexController in project coprhd-controller by CoprHD.

the class VPlexBlockSnapshotSessionApiImpl method relinkTargetVolumesToSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void relinkTargetVolumesToSnapshotSession(BlockObject snapSessionSourceObj, BlockSnapshotSession tgtSnapSession, List<URI> snapshotURIs, String taskId) {
    // data has been changed.
    if (URIUtil.isType(snapSessionSourceObj.getId(), Volume.class)) {
        // Invoke VLPEX controller.
        Volume vplexVolume = (Volume) snapSessionSourceObj;
        URI vplexURI = vplexVolume.getStorageController();
        VPlexController controller = getController(VPlexController.class, DiscoveredDataObject.Type.vplex.toString());
        controller.relinkTargetsToSnapshotSession(vplexURI, tgtSnapSession.getId(), snapshotURIs, taskId);
    } else {
        // so should never be called.
        throw APIException.methodNotAllowed.notSupportedForVplexVolumes();
    }
}
Also used : VPlexController(com.emc.storageos.vplexcontroller.VPlexController) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 20 with VPlexController

use of com.emc.storageos.vplexcontroller.VPlexController in project coprhd-controller by CoprHD.

the class VPlexBlockSnapshotSessionApiImpl method restoreSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void restoreSnapshotSession(BlockSnapshotSession snapSession, BlockObject snapSessionSourceObj, String taskId) {
    // recognizes that the data has been changed.
    if (URIUtil.isType(snapSessionSourceObj.getId(), Volume.class)) {
        // Invoke VLPEX controller.
        Volume vplexVolume = (Volume) snapSessionSourceObj;
        URI vplexURI = vplexVolume.getStorageController();
        VPlexController controller = getController(VPlexController.class, DiscoveredDataObject.Type.vplex.toString());
        controller.restoreSnapshotSession(vplexURI, snapSession.getId(), taskId);
    } else {
        // so should never be called.
        throw APIException.methodNotAllowed.notSupportedForVplexVolumes();
    }
}
Also used : VPlexController(com.emc.storageos.vplexcontroller.VPlexController) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

VPlexController (com.emc.storageos.vplexcontroller.VPlexController)20 Volume (com.emc.storageos.db.client.model.Volume)17 URI (java.net.URI)17 Operation (com.emc.storageos.db.client.model.Operation)16 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)13 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)11 ArrayList (java.util.ArrayList)10 NamedURI (com.emc.storageos.db.client.model.NamedURI)9 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)7 FCTN_VPLEX_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI)7 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)6 TaskList (com.emc.storageos.model.TaskList)6 VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)5 Migration (com.emc.storageos.db.client.model.Migration)5 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)5 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)5 POST (javax.ws.rs.POST)5 Produces (javax.ws.rs.Produces)5 Project (com.emc.storageos.db.client.model.Project)4