use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class BlockService method failoverTestCancel.
/**
* Request to cancel a prior test failover of the protection link associated with the param.copyID.
*
* NOTE: This is an asynchronous operation.
*
* If volume is srdf protected, then its a no-op
* <p>
* This method is deprecated. Use /block/volumes/{id}/protection/continuous-copies/failover-cancel instead.
*
* @prereq none
*
* @param id
* the URN of a ViPR Source volume
* @param param
* Copy to cancel the failover to
*
* @brief Cancel volume protection link failover test
* @return TaskList
*
* @throws ControllerException
*
* @deprecated failoverTestCancel is being replaced by failover-cancel.
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failover-test-cancel")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
@Deprecated
public TaskList failoverTestCancel(@PathParam("id") URI id, CopiesParam param) throws ControllerException {
TaskResourceRep taskResp = null;
TaskList taskList = new TaskList();
// Validate the source volume URI
ArgValidator.checkFieldUriType(id, Volume.class, "id");
boolean vplexVolume = checkIfVolumeIsForVplex(id);
// Validate the list of copies
ArgValidator.checkFieldNotEmpty(param.getCopies(), "copies");
List<Copy> copies = param.getCopies();
if (copies.size() != 1) {
throw APIException.badRequests.failoverCopiesParamCanOnlyBeOne();
}
Copy copy = copies.get(0);
if (vplexVolume && copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
throw APIException.badRequests.actionNotApplicableForVplexVolumeMirrors(ProtectionOp.FAILOVER_TEST_CANCEL.getRestOp());
}
ArgValidator.checkFieldUriType(copy.getCopyID(), Volume.class, "id");
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
taskResp = performProtectionAction(id, copy, ProtectionOp.FAILOVER_TEST_CANCEL.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (copy.getType().equalsIgnoreCase(TechnologyType.SRDF.toString())) {
id = VPlexSrdfUtil.getSrdfIdFromVolumeId(_dbClient, id);
copy.setCopyID(VPlexSrdfUtil.getSrdfIdFromVolumeId(_dbClient, copy.getCopyID()));
taskResp = performSRDFProtectionAction(id, copy, ProtectionOp.FAILOVER_TEST_CANCEL.getRestOp());
taskList.getTaskList().add(taskResp);
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
return taskList;
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class BlockService method swap.
/**
* Request to reverse the replication direction, i.e. R1 and R2 are interchanged..
*
* @prereq none
*
* @param id
* the URN of a ViPR Source volume
* @param param
* Copy to swap
*
* @brief Reverse roles of source and target
* @return TaskList
*
* @throws ControllerException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/swap")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList swap(@PathParam("id") URI id, CopiesParam param) throws ControllerException {
TaskResourceRep taskResp = null;
TaskList taskList = new TaskList();
// Validate the source volume URI
ArgValidator.checkFieldUriType(id, Volume.class, "id");
// Validate the list of copies
ArgValidator.checkFieldNotEmpty(param.getCopies(), "copies");
List<Copy> copies = param.getCopies();
if (copies.size() > 1) {
throw APIException.badRequests.swapCopiesParamCanOnlyBeOne();
}
Copy copy = copies.get(0);
ArgValidator.checkFieldUriType(copy.getCopyID(), Volume.class, "id");
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
taskResp = performProtectionAction(id, copy, ProtectionOp.SWAP.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (copy.getType().equalsIgnoreCase(TechnologyType.SRDF.toString())) {
id = VPlexSrdfUtil.getSrdfIdFromVolumeId(_dbClient, id);
copy.setCopyID(VPlexSrdfUtil.getSrdfIdFromVolumeId(_dbClient, copy.getCopyID()));
taskResp = performSRDFProtectionAction(id, copy, ProtectionOp.SWAP.getRestOp());
taskList.getTaskList().add(taskResp);
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
return taskList;
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class BlockService method deactivateMirror.
/**
* Deactivate continuous copies for given source volume
*
* NOTE: This is an asynchronous operation.
*
* @prereq none
*
* @param id
* the URN of a ViPR Source volume
* @param param
* List of copies to deactivate
* @param type {@link DefaultValue} FULL
* Possible type of deletion
* <ul>
* <li>FULL</li>
* <li>VIPR_ONLY</li>
* </ul>
* if type is FULL, ViPR deletes the continuous copy from storage array and removes from ViPR data base.
* if type is VIPR_ONLY, ViPR removes the continuous copy only from ViPR data base and leaves the continuous copy on storage
* array as it is.
*
* @brief Delete continuous copies
* @return TaskList
*
* @throws ControllerException
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList deactivateMirror(@PathParam("id") URI id, CopiesParam param, @DefaultValue("FULL") @QueryParam("type") String deleteType) throws ControllerException {
TaskList taskList = new TaskList();
// Validate the source volume URI
ArgValidator.checkFieldUriType(id, Volume.class, "id");
Volume volume = _dbClient.queryObject(Volume.class, id);
// Make sure that we don't have some pending
// operation against the volume
checkForPendingTasks(Arrays.asList(volume.getTenant().getURI()), Arrays.asList(volume));
// Validate the list of copies
ArgValidator.checkFieldNotEmpty(param.getCopies(), "copies");
boolean vplexVolume = checkIfVolumeIsForVplex(id);
// Process the list of copies
for (Copy copy : param.getCopies()) {
// Validate the copy ID
URI copyID = copy.getCopyID();
ArgValidator.checkUri(copyID);
// Validate a copy type was passed
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
if (TechnologyType.NATIVE.toString().equalsIgnoreCase(copy.getType())) {
String task = UUID.randomUUID().toString();
StorageSystem device;
String mirrorLabel;
URI mirrorURI;
BlockServiceApi blockServiceApi;
if (vplexVolume) {
VplexMirror mirror = queryVplexMirror(copyID);
ArgValidator.checkEntity(mirror, mirror.getId(), isIdEmbeddedInURL(copyID));
if (!mirror.getSource().getURI().equals(id)) {
throw APIException.badRequests.mirrorDoesNotBelongToVolume(copyID, id);
}
mirrorLabel = mirror.getLabel();
mirrorURI = mirror.getId();
device = _dbClient.queryObject(StorageSystem.class, mirror.getStorageController());
blockServiceApi = getBlockServiceImpl(DiscoveredDataObject.Type.vplex.name());
} else {
BlockMirror mirror = queryMirror(copyID);
ArgValidator.checkEntity(mirror, mirror.getId(), isIdEmbeddedInURL(copyID));
if (!mirror.getSource().getURI().equals(id)) {
throw APIException.badRequests.mirrorDoesNotBelongToVolume(copyID, id);
}
mirrorLabel = mirror.getLabel();
mirrorURI = mirror.getId();
device = _dbClient.queryObject(StorageSystem.class, mirror.getStorageController());
blockServiceApi = getBlockServiceImpl("mirror");
}
// Deactivate the mirror
TaskList deactivateTaskList = blockServiceApi.deactivateMirror(device, mirrorURI, task, deleteType);
// Create the audit log message
String opStage = VolumeDeleteTypeEnum.VIPR_ONLY.name().equals(deleteType) ? null : AuditLogManager.AUDITOP_BEGIN;
boolean opStatus = true;
for (TaskResourceRep resultTask : deactivateTaskList.getTaskList()) {
if (Operation.Status.error.name().equals(resultTask.getState())) {
opStatus = false;
break;
}
}
auditOp(OperationTypeEnum.DEACTIVATE_VOLUME_MIRROR, opStatus, opStage, copyID.toString(), mirrorLabel);
// Add tasks for this copy
taskList.getTaskList().addAll(deactivateTaskList.getTaskList());
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
}
return taskList;
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class BlockSnapshotService method deactivateSnapshot.
/**
* Deactivate volume snapshot, will result in permanent deletion of the requested snapshot from the storage system it was created on
* and will move the snapshot to a "marked-for-delete" state after the deletion happens on the array side.
* It will be deleted by the garbage collector on a subsequent iteration
* If this snapshot was created from a volume that is part of a consistency group,
* then all the related snapshots will be deactivated, as well.
*
* If "?type=VIPR_ONLY" is added to the path, it will delete snapshot only from ViPR data base and leaves the snapshot on storage array
* as it is.
* Possible value for attribute type : FULL, VIPR_ONLY
* FULL : Deletes the snapshot permanently on array and ViPR data base.
* VIPR_ONLY : Deletes the snapshot only from ViPR data base and leaves the snapshot on array as it is.
*
* @prereq none
* @param id the URN of a ViPR snapshot
* @param type the type of deletion {@link DefaultValue} FULL
* @brief Delete snapshot
* @return Snapshot information
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskList deactivateSnapshot(@PathParam("id") URI id, @DefaultValue("FULL") @QueryParam("type") String type) {
_log.info("Executing {} snapshot delete for snapshot {}", type, id);
String opStage = null;
boolean successStatus = true;
String taskId = UUID.randomUUID().toString();
TaskList response = new TaskList();
// Get the snapshot.
BlockSnapshot snap = (BlockSnapshot) queryResource(id);
// We can ignore dependencies on BlockSnapshotSession. In this case
// the BlockSnapshot instance is a linked target for a BlockSnapshotSession
// and we will unlink the snapshot from the session and delete it.
List<Class<? extends DataObject>> excludeTypes = new ArrayList<Class<? extends DataObject>>();
excludeTypes.add(BlockSnapshotSession.class);
if (VolumeDeleteTypeEnum.VIPR_ONLY.name().equals(type)) {
excludeTypes.add(ExportGroup.class);
excludeTypes.add(ExportMask.class);
}
ArgValidator.checkReference(BlockSnapshot.class, id, checkForDelete(snap, excludeTypes));
if (!VolumeDeleteTypeEnum.VIPR_ONLY.name().equals(type)) {
// The audit log message operation stage.
opStage = AuditLogManager.AUDITOP_BEGIN;
// If the BlockSnapshot instance represents a linked target, then
// we need to unlink the target form the snapshot session and then
// delete the target.
URIQueryResultList snapSessionURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getLinkedTargetSnapshotSessionConstraint(id), snapSessionURIs);
Iterator<URI> snapSessionURIsIter = snapSessionURIs.iterator();
if (snapSessionURIsIter.hasNext()) {
_log.info("Snapshot is linked target for a snapshot session");
SnapshotSessionUnlinkTargetsParam param = new SnapshotSessionUnlinkTargetsParam();
List<SnapshotSessionUnlinkTargetParam> targetInfoList = new ArrayList<SnapshotSessionUnlinkTargetParam>();
SnapshotSessionUnlinkTargetParam targetInfo = new SnapshotSessionUnlinkTargetParam(id, Boolean.TRUE);
targetInfoList.add(targetInfo);
param.setLinkedTargets(targetInfoList);
response.getTaskList().add(getSnapshotSessionManager().unlinkTargetVolumesFromSnapshotSession(snapSessionURIsIter.next(), param, OperationTypeEnum.DELETE_VOLUME_SNAPSHOT));
return response;
}
// Not an error if the snapshot we try to delete is already deleted
if (snap.getInactive()) {
_log.info("Snapshot is already inactive");
Operation op = new Operation();
op.ready("The snapshot has already been deleted");
op.setResourceType(ResourceOperationTypeEnum.DELETE_VOLUME_SNAPSHOT);
_dbClient.createTaskOpStatus(BlockSnapshot.class, snap.getId(), taskId, op);
response.getTaskList().add(toTask(snap, taskId, op));
return response;
}
}
// Get the storage system.
StorageSystem device = _dbClient.queryObject(StorageSystem.class, snap.getStorageController());
// Determine all snapshots to delete.
List<BlockSnapshot> snapshots = new ArrayList<BlockSnapshot>();
final URI cgId = snap.getConsistencyGroup();
if (!NullColumnValueGetter.isNullURI(cgId) && !NullColumnValueGetter.isNullValue(snap.getReplicationGroupInstance())) {
// Collect all the BlockSnapshots if part of a CG.
snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snap, _dbClient);
} else {
// Snap is not part of a CG so only delete the snap
snapshots.add(snap);
}
// Get the snapshot parent volume.
Volume parentVolume = _permissionsHelper.getObjectById(snap.getParent(), Volume.class);
// Check that there are no pending tasks for these snapshots.
checkForPendingTasks(Arrays.asList(parentVolume.getTenant().getURI()), snapshots);
// Create tasks on the volume.
for (BlockSnapshot snapshot : snapshots) {
Operation snapOp = _dbClient.createTaskOpStatus(BlockSnapshot.class, snapshot.getId(), taskId, ResourceOperationTypeEnum.DELETE_VOLUME_SNAPSHOT);
response.getTaskList().add(toTask(snapshot, taskId, snapOp));
}
// should be returned.
try {
BlockServiceApi blockServiceApiImpl = BlockService.getBlockServiceImpl(parentVolume, _dbClient);
blockServiceApiImpl.deleteSnapshot(snap, snapshots, taskId, type);
} catch (APIException | InternalException e) {
successStatus = false;
String errorMsg = String.format("Exception attempting to delete snapshot %s: %s", snap.getId(), e.getMessage());
_log.error(errorMsg);
for (TaskResourceRep taskResourceRep : response.getTaskList()) {
taskResourceRep.setState(Operation.Status.error.name());
taskResourceRep.setMessage(errorMsg);
_dbClient.error(BlockSnapshot.class, taskResourceRep.getResource().getId(), taskId, e);
}
} catch (Exception e) {
successStatus = false;
String errorMsg = String.format("Exception attempting to delete snapshot %s: %s", snap.getId(), e.getMessage());
_log.error(errorMsg);
ServiceCoded sc = APIException.internalServerErrors.genericApisvcError(errorMsg, e);
for (TaskResourceRep taskResourceRep : response.getTaskList()) {
taskResourceRep.setState(Operation.Status.error.name());
taskResourceRep.setMessage(sc.getMessage());
_dbClient.error(BlockSnapshot.class, taskResourceRep.getResource().getId(), taskId, sc);
}
}
auditOp(OperationTypeEnum.DELETE_VOLUME_SNAPSHOT, successStatus, opStage, id.toString(), snap.getLabel(), snap.getParent().getName(), device.getId().toString());
return response;
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ExportGroupService method pathsAdjustment.
/**
* Export paths adjustment
*
* @param id The export group id
* @param param The parameters including addedPaths, removedPaths, storage system URI, exportPathParameters,
* and waitBeforeRemovePaths
* @brief Initiate port allocations for export
* @return The pending task
* @throws ControllerException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/paths-adjustment")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep pathsAdjustment(@PathParam("id") URI id, ExportPathsAdjustmentParam param) throws ControllerException {
// Basic validation of ExportGroup and the request
ExportGroup exportGroup = queryObject(ExportGroup.class, id, true);
if (exportGroup.checkInternalFlags(DataObject.Flag.DELETION_IN_PROGRESS)) {
throw BadRequestException.badRequests.deletionInProgress(exportGroup.getClass().getSimpleName(), exportGroup.getLabel());
}
validateExportGroupNoPendingEvents(exportGroup);
validateSuspendSetForNonDiscoverableHosts(exportGroup, param.getWaitBeforeRemovePaths(), param.getRemovedPaths().isEmpty());
ArgValidator.checkUri(param.getStorageSystem());
StorageSystem system = queryObject(StorageSystem.class, param.getStorageSystem(), true);
// Log the input parameters
param.logParameters(_log);
// Get the virtual array, default to Export Group varray. Validate it matches.
URI varray = param.getVirtualArray();
if (varray != null) {
boolean validVarray = varray.equals(exportGroup.getVirtualArray());
if (exportGroup.getAltVirtualArrays() != null && varray.toString().equals(exportGroup.getAltVirtualArrays().get(system.getId().toString()))) {
validVarray = true;
}
if (!validVarray) {
throw APIException.badRequests.varrayNotInExportGroup(varray.toString());
}
} else {
varray = exportGroup.getVirtualArray();
}
validatePathAdjustment(exportGroup, system, param, varray);
Boolean wait = new Boolean(param.getWaitBeforeRemovePaths());
String task = UUID.randomUUID().toString();
Operation op = initTaskStatus(exportGroup, task, Operation.Status.pending, ResourceOperationTypeEnum.EXPORT_PATHS_ADJUSTMENT);
// persist the export group to the database
_dbClient.updateObject(exportGroup);
auditOp(OperationTypeEnum.EXPORT_PATH_ADJUSTMENT, true, AuditLogManager.AUDITOP_BEGIN, exportGroup.getLabel(), exportGroup.getId().toString(), exportGroup.getVirtualArray().toString(), exportGroup.getProject().toString());
TaskResourceRep taskRes = toTask(exportGroup, task, op);
BlockExportController exportController = getExportController();
_log.info("Submitting export path adjustment request.");
Map<URI, List<URI>> addedPaths = convertInitiatorPathParamToMap(param.getAdjustedPaths());
Map<URI, List<URI>> removedPaths = convertInitiatorPathParamToMap(param.getRemovedPaths());
ExportPathParams pathParam = new ExportPathParams(param.getExportPathParameters(), exportGroup);
exportController.exportGroupPortRebalance(param.getStorageSystem(), id, varray, addedPaths, removedPaths, pathParam, wait, task);
return taskRes;
}
Aggregations