use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.
the class BlockService method startContinuousCopies.
/**
* Start continuous copies. Continuous copies will be created when <i>NATIVE</i> type is specified and
* <i>copyID</i> fields are omitted.
*
* @prereq none
*
* @param id URN of a ViPR Source volume
* @param param List of copies to start or create.
*
* @brief Start or create continuous copies.
*
* @return TaskList
* @throws ControllerException
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/start")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList startContinuousCopies(@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");
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));
// Don't operate on ingested volumes.
VolumeIngestionUtil.checkOperationSupportedOnIngestedVolume(volume, ResourceOperationTypeEnum.CREATE_VOLUME_MIRROR, _dbClient);
Volume sourceVolume = queryVolumeResource(id);
validateSourceVolumeHasExported(sourceVolume);
// Validate the list of copies
ArgValidator.checkFieldNotEmpty(param.getCopies(), "copies");
// Verify that the copy IDs are either all specified or none are specified
// for a particular protection type. Combinations are not allowed
verifyCopyIDs(param);
// Process the list of copies
for (Copy copy : param.getCopies()) {
// Validate a copy type was passed
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
URI copyID = copy.getCopyID();
// If copyID is null all copies are started
if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
// If copyID is not set all copies are started
if (!URIUtil.isValid(copyID)) {
copyID = null;
}
taskResp = performProtectionAction(id, copy, ProtectionOp.START.getRestOp());
taskList.getTaskList().add(taskResp);
// If copyID is null, we have already started all copies
if (copyID == null) {
return taskList;
}
} 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.START.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
if (URIUtil.isValid(copyID) && URIUtil.isType(copyID, BlockMirror.class)) {
/*
* To establish group relationship between volume group and mirror group
*/
taskResp = establishVolumeMirrorGroupRelation(id, copy, ProtectionOp.START.getRestOp());
taskList.getTaskList().add(taskResp);
} else {
NativeContinuousCopyCreate mirror = new NativeContinuousCopyCreate(copy.getName(), copy.getCount());
taskList = startMirrors(id, mirror);
}
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
}
return taskList;
}
use of com.emc.storageos.model.TaskList 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.TaskList 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.TaskList in project coprhd-controller by CoprHD.
the class BlockService method deleteVolume.
/**
* Deactivate a volume, will result in permanent deletion of the requested volume(s) from the storage system it was created on and will
* move the volume to a "marked-for-delete" state after the deletion happens on the array side. The volume will be
* deleted from the database when all references to this volume of type BlockSnapshot and ExportGroup are deleted.
*
* If "?force=true" is added to the path, it will force the delete of internal
* volumes that have the SUPPORTS_FORCE flag.
*
* If "?type=VIPR_ONLY" is added to the path, it will delete volumes only from ViPR data base and leaves the volume on storage array as
* it is.
* Possible value for the attribute type : FULL, VIPR_ONLY
* FULL : Deletes the volumes permanently on array and ViPR data base.
* VIPR_ONLY : Deletes the volumes only from ViPR data base and leaves the volumes on array as it is.
*
* NOTE: This is an asynchronous operation.
*
* @prereq Dependent volume resources such as snapshots and export groups must be deleted
*
* @param id
* the URN of a ViPR volume to delete
* @param force {@link DefaultValue} false
* @param type {@link DefaultValue} FULL
*
* @brief Delete volume
* @return Volume information
*
* @throws InternalException
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep deleteVolume(@PathParam("id") URI id, @DefaultValue("false") @QueryParam("force") boolean force, @DefaultValue("FULL") @QueryParam("type") String type) throws InternalException {
// Reuse implementation for deleting multiple volumes.
BulkDeleteParam deleteParam = new BulkDeleteParam();
deleteParam.setIds(Lists.newArrayList(id));
TaskList taskList = deleteVolumes(deleteParam, force, type);
return taskList.getTaskList().get(0);
}
use of com.emc.storageos.model.TaskList 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;
}
Aggregations