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;
}
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;
}
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;
}
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();
}
}
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();
}
}
Aggregations