use of com.emc.storageos.model.block.Copy in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupService method failoverCancel.
/**
* Request to cancel fail over on already failed over consistency group.
*
* @prereq none
*
* @param id the URI of the BlockConsistencyGroup.
* @param param Copy to fail back
*
* @brief Cancel a failover and return to source
* @return TaskList
*
* @throws ControllerException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failover-cancel")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList failoverCancel(@PathParam("id") URI id, CopiesParam param) throws ControllerException {
TaskResourceRep taskResp = null;
TaskList taskList = new TaskList();
// Validate the source volume URI
ArgValidator.checkFieldUriType(id, BlockConsistencyGroup.class, "id");
// Validate the list of copies
ArgValidator.checkFieldNotEmpty(param.getCopies(), "copies");
// Query Consistency Group
final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(id);
// system types.
if (!consistencyGroup.created()) {
throw APIException.badRequests.consistencyGroupNotCreated();
}
List<Copy> copies = param.getCopies();
if (copies.size() > 1) {
throw APIException.badRequests.failOverCancelCopiesParamCanOnlyBeOne();
}
Copy copy = copies.get(0);
ArgValidator.checkFieldUriType(copy.getCopyID(), VirtualArray.class, "copyId");
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
if (TechnologyType.RP.name().equalsIgnoreCase(copy.getType())) {
taskResp = performProtectionAction(id, copy, ProtectionOp.FAILOVER_CANCEL.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (TechnologyType.SRDF.name().equalsIgnoreCase(copy.getType())) {
taskResp = performSRDFProtectionAction(id, copy, ProtectionOp.FAILOVER_CANCEL.getRestOp());
taskList.getTaskList().add(taskResp);
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
return taskList;
}
use of com.emc.storageos.model.block.Copy in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupService method swap.
/**
* Request to reverse the replication direction, i.e. R1 and R2 are interchanged.
*
* @prereq none
*
* @param id the URI of a BlockConsistencyGroup
* @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, BlockConsistencyGroup.class, "id");
// Validate the list of copies
ArgValidator.checkFieldNotEmpty(param.getCopies(), "copies");
// Query Consistency Group
final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(id);
// system types.
if (!consistencyGroup.created()) {
throw APIException.badRequests.consistencyGroupNotCreated();
}
List<Copy> copies = param.getCopies();
if (copies.size() > 1) {
throw APIException.badRequests.swapCopiesParamCanOnlyBeOne();
}
Copy copy = copies.get(0);
ArgValidator.checkFieldUriType(copy.getCopyID(), VirtualArray.class, "copyId");
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
if (TechnologyType.RP.name().equalsIgnoreCase(copy.getType())) {
taskResp = performProtectionAction(id, copy, ProtectionOp.SWAP.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (TechnologyType.SRDF.name().equalsIgnoreCase(copy.getType())) {
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.block.Copy in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupService method failoverProtection.
/**
* Request to failover the protection link associated with the copy. The target
* copy is specified by identifying the virtual array in param.copyId.
*
* NOTE: This is an asynchronous operation.
*
* If volume is srdf protected, then invoking failover internally triggers
* SRDF SWAP on volume pairs.
*
* @prereq none
*
* @param id the URI of a BlockConsistencyGroup
* @param param Copy to failover to
*
* @brief Failover the protection link
* @return TaskList
*
* @throws ControllerException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failover")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList failoverProtection(@PathParam("id") URI id, CopiesParam param) throws ControllerException {
TaskResourceRep taskResp = null;
TaskList taskList = new TaskList();
// Validate the consistency group URI
ArgValidator.checkFieldUriType(id, BlockConsistencyGroup.class, "id");
// Validate the list of copies
ArgValidator.checkFieldNotEmpty(param.getCopies(), "copies");
// Query Consistency Group
final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(id);
// system types.
if (!consistencyGroup.created()) {
throw APIException.badRequests.consistencyGroupNotCreated();
}
List<Copy> copies = param.getCopies();
if (copies.size() > 1) {
throw APIException.badRequests.failoverCopiesParamCanOnlyBeOne();
}
Copy copy = copies.get(0);
ArgValidator.checkFieldUriType(copy.getCopyID(), VirtualArray.class, "copyId");
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
if (TechnologyType.RP.name().equalsIgnoreCase(copy.getType())) {
taskResp = performProtectionAction(id, copy, ProtectionOp.FAILOVER.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (TechnologyType.SRDF.name().equalsIgnoreCase(copy.getType())) {
taskResp = performSRDFProtectionAction(id, copy, ProtectionOp.FAILOVER.getRestOp());
taskList.getTaskList().add(taskResp);
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
return taskList;
}
use of com.emc.storageos.model.block.Copy in project coprhd-controller by CoprHD.
the class BlockService method stopContinuousCopies.
/**
* Stop continuous copies.
*
* @prereq none
*
* @param id
* the URN of a ViPR Source volume
* @param param
* List of copies to stop
*
* @brief Stop continuous copies.
* @return TaskList
*
* @throws ControllerException
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/stop")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList stopContinuousCopies(@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));
boolean vplexVolume = checkIfVolumeIsForVplex(id);
// 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);
// Validate for SRDF Stop operation
validateSRDFStopOperation(id, param);
// Process the list of copies
for (Copy copy : param.getCopies()) {
// If copyID is not set all copies are stopped
URI copyID = copy.getCopyID();
if (!URIUtil.isValid(copyID)) {
copyID = null;
}
// Validate a copy type was passed
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
// If copyID is null all copies are stopped
if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
taskResp = performProtectionAction(id, copy, ProtectionOp.STOP.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (!vplexVolume && copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
taskList = stopMirrors(id, copyID);
} else if (vplexVolume && copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
taskList = stopVplexMirrors(id, copyID);
} 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.STOP.getRestOp());
taskList.getTaskList().add(taskResp);
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
// If copyID is null, we have already stopped all copies
if (copyID == null) {
return taskList;
}
}
return taskList;
}
use of com.emc.storageos.model.block.Copy in project coprhd-controller by CoprHD.
the class BlockService method failoverProtection.
/**
* Request to failover the protection link associated with the param.copyID.
*
* NOTE: This is an asynchronous operation.
*
* If volume is srdf protected, then invoking failover internally triggers
* SRDF SWAP on volume pairs.
*
* @prereq none
*
* @param id
* the URN of a ViPR Source volume
* @param param
* Copy to failover to
*
* @brief Failover the volume protection link
* @return TaskList
*
* @throws ControllerException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failover")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList failoverProtection(@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.getRestOp());
}
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
taskResp = performProtectionAction(id, copy, ProtectionOp.FAILOVER.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.getRestOp());
taskList.getTaskList().add(taskResp);
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
return taskList;
}
Aggregations