Search in sources :

Example 21 with Copy

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

the class ResumeContinuousCopy method doExecute.

@Override
protected Tasks<VolumeRestRep> doExecute() throws Exception {
    Copy copy = new Copy();
    copy.setCopyID(continuousCopyId);
    copy.setType(type);
    CopiesParam param = new CopiesParam();
    param.getCopies().add(copy);
    return getClient().blockVolumes().resumeContinuousCopies(volumeId, param);
}
Also used : Copy(com.emc.storageos.model.block.Copy) CopiesParam(com.emc.storageos.model.block.CopiesParam)

Example 22 with Copy

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

the class SwapCGContinuousCopies method doExecute.

@Override
protected Tasks<BlockConsistencyGroupRestRep> doExecute() throws Exception {
    Copy copy = new Copy();
    copy.setType(type);
    copy.setCopyID(failoverTarget);
    CopiesParam param = new CopiesParam();
    param.getCopies().add(copy);
    return getClient().blockConsistencyGroups().swap(consistencyGroupId, param);
}
Also used : Copy(com.emc.storageos.model.block.Copy) CopiesParam(com.emc.storageos.model.block.CopiesParam)

Example 23 with Copy

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

the class UpdateBlockConsistencyGroupAccessMode method doExecute.

@Override
protected Tasks<BlockConsistencyGroupRestRep> doExecute() throws Exception {
    Copy copy = new Copy();
    copy.setType(type);
    copy.setCopyID(failoverTarget);
    copy.setAccessMode(accessMode);
    CopiesParam param = new CopiesParam();
    param.getCopies().add(copy);
    return getClient().blockConsistencyGroups().updateCopyAccessMode(consistencyGroupId, param);
}
Also used : Copy(com.emc.storageos.model.block.Copy) CopiesParam(com.emc.storageos.model.block.CopiesParam)

Example 24 with Copy

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

the class BlockService method validateSRDFStopOperation.

/**
 * Cant Perform SRDF STOP operation Sync/Async with CG if it has active snap or clone.
 *
 * @param id
 * @param param
 */
private void validateSRDFStopOperation(URI id, CopiesParam param) {
    List<URI> srdfVolumeURIList = new ArrayList<URI>();
    Volume srdfSourceVolume = _dbClient.queryObject(Volume.class, id);
    if (srdfSourceVolume.checkForSRDF() && srdfSourceVolume.hasConsistencyGroup()) {
        srdfVolumeURIList.add(id);
        for (Copy copy : param.getCopies()) {
            URI copyID = copy.getCopyID();
            if (URIUtil.isType(copyID, Volume.class) && URIUtil.isValid(copyID)) {
                srdfVolumeURIList.add(copyID);
                break;
            }
        }
        for (URI srdfVolURI : srdfVolumeURIList) {
            Volume volume = _dbClient.queryObject(Volume.class, srdfVolURI);
            URIQueryResultList list = new URIQueryResultList();
            Constraint constraint = ContainmentConstraint.Factory.getVolumeSnapshotConstraint(srdfVolURI);
            _dbClient.queryByConstraint(constraint, list);
            Iterator<URI> it = list.iterator();
            while (it.hasNext()) {
                URI snapshotID = it.next();
                BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
                if (snapshot != null && !snapshot.getInactive()) {
                    throw APIException.badRequests.cannotStopSRDFBlockSnapShotExists(volume.getLabel());
                }
            }
            // Also check for snapshot sessions.
            List<BlockSnapshotSession> snapSessions = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getParentSnapshotSessionConstraint(srdfVolURI));
            if (!snapSessions.isEmpty()) {
                throw APIException.badRequests.cannotStopSRDFBlockSnapShotExists(volume.getLabel());
            }
            // full copies deleting the volume may not be allowed.
            if (!getFullCopyManager().volumeCanBeDeleted(volume)) {
                throw APIException.badRequests.cantStopSRDFFullCopyNotDetached(volume.getLabel());
            }
        }
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) MapVolume(com.emc.storageos.api.mapper.functions.MapVolume) Volume(com.emc.storageos.db.client.model.Volume) Copy(com.emc.storageos.model.block.Copy) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 25 with Copy

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

the class BlockService method syncContinuousCopies.

/**
 * Sync continuous copies.
 *
 * @prereq none
 *
 * @param id
 *            the URI of a ViPR Source volume
 * @param param
 *            List of copies to sync
 *
 * @brief Sync continuous copies.
 * @return TaskList
 *
 * @throws ControllerException
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/sync")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList syncContinuousCopies(@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");
        // If copyID is null all copies are paused
        if (copy.getType().equalsIgnoreCase(TechnologyType.RP.toString())) {
            // If copyID is not set all copies are sync'd
            URI copyID = copy.getCopyID();
            if (!URIUtil.isValid(copyID)) {
                copyID = null;
            }
            taskResp = performProtectionAction(id, copy, ProtectionOp.SYNC.getRestOp());
            taskList.getTaskList().add(taskResp);
            // If copyID is null, we have already synced 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.SYNC.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) 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)

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