Search in sources :

Example 6 with Copy

use of com.emc.storageos.model.block.Copy in project coprhd-controller by CoprHD.

the class BlockService method resumeContinuousCopies.

/**
 * Resume 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 resume
 *
 * @brief Resume continuous copies
 * @return TaskList
 *
 * @throws ControllerException
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/resume")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList resumeContinuousCopies(@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 resumed
        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 paused
        if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
            taskResp = performProtectionAction(id, copy, ProtectionOp.RESUME.getRestOp());
            taskList.getTaskList().add(taskResp);
        } else if (!vplexVolume && copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
            TaskList resumeTaskList = resumeMirrors(id, copyID);
            taskList.getTaskList().addAll(resumeTaskList.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.RESUME.getRestOp());
            taskList.getTaskList().add(taskResp);
        } else if (vplexVolume && copy.getType().equalsIgnoreCase(TechnologyType.NATIVE.toString())) {
            throw APIException.badRequests.actionNotApplicableForVplexVolumeMirrors(ProtectionOp.RESUME.getRestOp());
        } else {
            throw APIException.badRequests.invalidCopyType(copy.getType());
        }
        // If copyID is null, we have already resumed all copies
        if (copyID == null) {
            return taskList;
        }
    }
    return taskList;
}
Also used : Copy(com.emc.storageos.model.block.Copy) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 7 with Copy

use of com.emc.storageos.model.block.Copy in project coprhd-controller by CoprHD.

the class BlockService method failoverTest.

/**
 * Request to test failover of the protection link associated with the param.copyID.
 *
 * NOTE: This is an asynchronous operation.
 *
 * If volume is srdf protected, then invoking failover-test ends in no-op.
 * failoverTest is being replaced by failover
 *
 * @prereq none
 *
 * @param id
 *            the URN of a ViPR Source volume
 * @param param
 *            Copy to test failover on
 *
 * @brief Test volume protection link failover
 * @return TaskList
 *
 * @throws ControllerException
 *
 * @deprecated failoverTest is being replaced by failover.
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failover-test")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
@Deprecated
public TaskList failoverTest(@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.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.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.getRestOp());
        taskList.getTaskList().add(taskResp);
    } else {
        throw APIException.badRequests.invalidCopyType(copy.getType());
    }
    return taskList;
}
Also used : Copy(com.emc.storageos.model.block.Copy) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 8 with Copy

use of com.emc.storageos.model.block.Copy 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;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) MapVolume(com.emc.storageos.api.mapper.functions.MapVolume) Volume(com.emc.storageos.db.client.model.Volume) Copy(com.emc.storageos.model.block.Copy) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) NativeContinuousCopyCreate(com.emc.storageos.model.block.NativeContinuousCopyCreate) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 9 with Copy

use of com.emc.storageos.model.block.Copy 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;
}
Also used : Copy(com.emc.storageos.model.block.Copy) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 10 with Copy

use of com.emc.storageos.model.block.Copy 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;
}
Also used : Copy(com.emc.storageos.model.block.Copy) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

Copy (com.emc.storageos.model.block.Copy)32 TaskList (com.emc.storageos.model.TaskList)17 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)17 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)17 POST (javax.ws.rs.POST)17 Path (javax.ws.rs.Path)17 Produces (javax.ws.rs.Produces)17 CopiesParam (com.emc.storageos.model.block.CopiesParam)12 URI (java.net.URI)10 Consumes (javax.ws.rs.Consumes)10 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)8 Volume (com.emc.storageos.db.client.model.Volume)6 MapVolume (com.emc.storageos.api.mapper.functions.MapVolume)5 MapBlockConsistencyGroup (com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup)4 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)4 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 ArrayList (java.util.ArrayList)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 Constraint (com.emc.storageos.db.client.constraint.Constraint)1