use of com.emc.storageos.model.block.NativeContinuousCopyCreate 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;
}
Aggregations