use of com.emc.storageos.model.block.Copy in project coprhd-controller by CoprHD.
the class BlockService method verifyCopyIDs.
/**
* Verify that all the copy IDs passed for a protection type are either
* set to valid URIs, or none are set. A combination of the two is not allowed.
* When none are set the operation is performed on all copies for the specified source volume.
*
* @param param
* List of copies to verify
*/
private void verifyCopyIDs(CopiesParam param) {
boolean rpEmpty = false;
boolean rpSet = false;
boolean nativeEmpty = false;
boolean nativeSet = false;
boolean srdfEmpty = false;
boolean srdfSet = false;
// Process the list of copies to ensure either all are set or all are empty
for (Copy copy : param.getCopies()) {
URI copyID = copy.getCopyID();
if (URIUtil.isValid(copyID)) {
if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
rpEmpty = true;
} else if (copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
nativeEmpty = true;
} else if (copy.getType().equalsIgnoreCase(TechnologyType.SRDF.toString())) {
srdfEmpty = true;
}
} else {
if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
rpSet = true;
} else if (copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
nativeSet = true;
} else if (copy.getType().equalsIgnoreCase(TechnologyType.SRDF.toString())) {
srdfSet = true;
}
}
}
if (rpEmpty && rpSet) {
throw APIException.badRequests.invalidCopyIDCombination(TechnologyType.RP.toString());
} else if (nativeEmpty && nativeSet) {
throw APIException.badRequests.invalidCopyIDCombination(TechnologyType.NATIVE.toString());
} else if (srdfEmpty && srdfSet) {
throw APIException.badRequests.invalidCopyIDCombination(TechnologyType.SRDF.toString());
}
}
use of com.emc.storageos.model.block.Copy in project coprhd-controller by CoprHD.
the class BlockService method pauseContinuousCopies.
/**
* Pause 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 pause
*
* @brief Pause continuous copies
* @return TaskList
*
* @throws ControllerException
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/pause")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList pauseContinuousCopies(@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");
// 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()) {
// If copyID is not set all copies are paused
URI copyID = copy.getCopyID();
if (!URIUtil.isValid(copyID)) {
copyID = null;
}
// Validate a copy type was passed
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
taskResp = performProtectionAction(id, copy, ProtectionOp.PAUSE.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (!vplexVolume && copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
TaskList pauseTaskList = pauseMirrors(id, copy.getSync(), copyID);
taskList.getTaskList().addAll(pauseTaskList.getTaskList());
} 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.PAUSE.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (vplexVolume && copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
throw APIException.badRequests.actionNotApplicableForVplexVolumeMirrors(ProtectionOp.PAUSE.getRestOp());
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
// If copyID is null, we have already paused 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 failoverCancel.
/**
* Request to cancel fail over on already failed over volumes.
*
* @prereq none
*
* @param id
* the URN of a ViPR Source volume
* @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, 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.failOverCancelCopiesParamCanOnlyBeOne();
}
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.FAILOVER_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_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 BlockService method changeCopyMode.
/**
* Changes Copy Mode
*
* @param id
* the URI of a ViPR Source volume
*
* @param param
* List of copies to sync
*
* @brief Change the SRDF copy mode
*
* @desc Change the SRDF copy mode. Copy modes are synchronous, asynchronous, or adaptive
*
* @return TaskList
*
* @throws ControllerException
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/copymode")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList changeCopyMode(@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");
// 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");
String copyMode = copy.getCopyMode();
// Validate a copy mode was passed
ArgValidator.checkFieldNotEmpty(copyMode, "copyMode");
Volume volume = queryVolumeResource(id);
ArgValidator.checkEntity(volume, id, true);
if (volume.hasConsistencyGroup()) {
if (TechnologyType.SRDF.name().equalsIgnoreCase(copy.getType())) {
id = VPlexSrdfUtil.getSrdfIdFromVolumeId(_dbClient, id);
copy.setCopyID(VPlexSrdfUtil.getSrdfIdFromVolumeId(_dbClient, copy.getCopyID()));
if (RemoteDirectorGroup.SupportedCopyModes.ASYNCHRONOUS.name().equalsIgnoreCase(copyMode) || RemoteDirectorGroup.SupportedCopyModes.SYNCHRONOUS.name().equalsIgnoreCase(copyMode) || RemoteDirectorGroup.SupportedCopyModes.ADAPTIVECOPY.name().equalsIgnoreCase(copyMode)) {
taskResp = performSRDFProtectionAction(id, copy, ProtectionOp.CHANGE_COPY_MODE.getRestOp());
taskList.getTaskList().add(taskResp);
} else {
throw APIException.badRequests.invalidSRDFCopyMode(copy.getType());
}
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
} else {
/**
* As of now ViPR supports change copy mode operations only for volumes with CG.
*/
throw APIException.badRequests.invalidSRDFCopyMode(volume.getNativeId());
}
}
return taskList;
}
use of com.emc.storageos.model.block.Copy in project coprhd-controller by CoprHD.
the class BlockService method changeAccessMode.
/**
* Request to change the access mode on the provided copy.
*
* NOTE: This is an asynchronous operation.
*
* Currently only supported for RecoverPoint protected volumes. If volume is SRDF protected,
* then we do nothing and return the task.
*
* @prereq none
*
* @param id
* the URN of a ViPR Source volume
* @param param
* Copy to change access mode on
*
* @brief Change the access mode for a copy.
* @return TaskList
*
* @throws ControllerException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/accessmode")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList changeAccessMode(@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) {
// Change access mode operations can only be performed on a single copy
throw APIException.badRequests.changeAccessCopiesParamCanOnlyBeOne();
}
Copy copy = copies.get(0);
if (vplexVolume && copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
throw APIException.badRequests.actionNotApplicableForVplexVolumeMirrors(ProtectionOp.CHANGE_ACCESS_MODE.getRestOp());
}
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
ArgValidator.checkFieldNotEmpty(copy.getAccessMode(), "accessMode");
if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
taskResp = performProtectionAction(id, copy, ProtectionOp.CHANGE_ACCESS_MODE.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (copy.getType().equalsIgnoreCase(TechnologyType.SRDF.toString())) {
_log.warn("Changing access mode is currently not supported for SRDF. Returning empty task list (no-op).");
return taskList;
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
return taskList;
}
Aggregations