Search in sources :

Example 6 with BlockSnapshotSession

use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.

the class BlockSnapshotSessionService method queryResource.

/**
 * {@inheritDoc}
 */
@Override
protected BlockSnapshotSession queryResource(URI id) {
    ArgValidator.checkUri(id);
    BlockSnapshotSession blockSnapshotSession = _permissionsHelper.getObjectById(id, BlockSnapshotSession.class);
    ArgValidator.checkEntityNotNull(blockSnapshotSession, id, isIdEmbeddedInURL(id));
    return blockSnapshotSession;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) MapBlockSnapshotSession(com.emc.storageos.api.mapper.functions.MapBlockSnapshotSession)

Example 7 with BlockSnapshotSession

use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.

the class VolumeGroupService method checkForApplicationPendingTasks.

/**
 * Check if the application and its CGs/volumes/snapshots/snapshotSessions have any pending tasks
 *
 * @param volumeGroup The volume group
 * @param dbClient
 * @param preventAnyPendingTask If throw error when there is any pending task
 */
private void checkForApplicationPendingTasks(VolumeGroup volumeGroup, DbClient dbClient, boolean preventAnyPendingTask) {
    checkForPendingTask(volumeGroup.getId(), dbClient, preventAnyPendingTask);
    Set<URI> cgs = new HashSet<URI>();
    List<Volume> allVolumes = ControllerUtils.getVolumeGroupVolumes(dbClient, volumeGroup);
    for (Volume vol : allVolumes) {
        checkForPendingTask(vol.getId(), dbClient, preventAnyPendingTask);
        URI cg = vol.getConsistencyGroup();
        if (!NullColumnValueGetter.isNullURI(cg)) {
            cgs.add(vol.getConsistencyGroup());
        }
    }
    for (URI cg : cgs) {
        checkForPendingTask(cg, dbClient, preventAnyPendingTask);
    }
    // it has a corresponding task in CG. so the above checking on CG should cover the case for clone.
    for (Volume volume : allVolumes) {
        Volume theVol = volume;
        if (volume.isVPlexVolume(dbClient)) {
            theVol = VPlexUtil.getVPLEXBackendVolume(volume, true, dbClient);
            if (theVol == null || theVol.getInactive()) {
                log.warn("Cannot find backend volume for VPLEX volume {}", volume.getLabel());
                continue;
            }
        }
        URIQueryResultList snapshotURIs = new URIQueryResultList();
        dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(theVol.getId()), snapshotURIs);
        Iterator<URI> it = snapshotURIs.iterator();
        while (it.hasNext()) {
            URI snapURI = it.next();
            checkForPendingTask(snapURI, dbClient, preventAnyPendingTask);
        }
    }
    // Get snapshotSessions
    List<BlockSnapshotSession> sessions = getVolumeGroupSnapshotSessions(volumeGroup);
    for (BlockSnapshotSession session : sessions) {
        checkForPendingTask(session.getId(), dbClient, preventAnyPendingTask);
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) Volume(com.emc.storageos.db.client.model.Volume) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 8 with BlockSnapshotSession

use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.

the class VolumeGroupService method getVolumeGroupSnapshotSessionsByCopySet.

/**
 * List snapshot sessions in a session set for a volume group.
 *
 * @param volumeGroupId The URI of the volume group
 * @param param the VolumeGroupCopySetParam containing set name
 * @return BlockSnapshotSessionList
 * @brief List snapshot sessions in session set for a volume group
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshot-sessions/copy-sets")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BlockSnapshotSessionList getVolumeGroupSnapshotSessionsByCopySet(@PathParam("id") final URI volumeGroupId, final VolumeGroupCopySetParam param) {
    ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, ID_FIELD);
    // query volume group
    final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
    // validate snap session set name
    String sessionsetName = param.getCopySetName();
    ArgValidator.checkFieldNotNull(sessionsetName, COPY_SET_NAME_FIELD);
    // get the snapshot sessions for the given set name in the volume group
    BlockSnapshotSessionList snapshotSessionList = new BlockSnapshotSessionList();
    // validate that the provided set name actually belongs to this Application
    VolumeGroupCopySetList copySetList = getVolumeGroupSnapsetSessionSets(volumeGroup);
    if (copySetList.getCopySets().contains(sessionsetName)) {
        // get the snapshot sessions for the volume group
        List<BlockSnapshotSession> volumeGroupSessions = getVolumeGroupSnapshotSessions(volumeGroup);
        for (BlockSnapshotSession session : volumeGroupSessions) {
            if (sessionsetName.equals(session.getSessionSetName())) {
                snapshotSessionList.getSnapSessionRelatedResourceList().add(toNamedRelatedResource(session));
            }
        }
    }
    return snapshotSessionList;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) VolumeGroupCopySetList(com.emc.storageos.model.application.VolumeGroupCopySetList) 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 9 with BlockSnapshotSession

use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.

the class VolumeGroupService method getVolumeGroupSnapshotSession.

/**
 * Get the specified volume group snapshot session.
 *
 * @param volumeGroupId The URI of the volume group.
 * @param snapshotIsnapshotSessionIdd The URI of the snapshot session.
 * @brief Get the specified volume group snapshot session.
 * @return BlockSnapshotSessionRestRep.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshot-sessions/{sid}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BlockSnapshotSessionRestRep getVolumeGroupSnapshotSession(@PathParam("id") final URI volumeGroupId, @PathParam("sid") final URI snapshotSessionId) {
    ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, ID_FIELD);
    // query Volume Group
    final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
    // validate replica operation for volume group
    validateCopyOperationForVolumeGroup(volumeGroup, ReplicaTypeEnum.SNAPSHOT);
    // get snapshot session
    BlockSnapshotSession snapSession = BlockSnapshotSessionUtils.querySnapshotSession(snapshotSessionId, uriInfo, _dbClient, true);
    // validate that the provided snapshot session is part of the volume group
    validateSnapSessionBelongsToApplication(snapSession, volumeGroup);
    return map(_dbClient, snapSession);
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 10 with BlockSnapshotSession

use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.

the class VolumeGroupService method validateSnapSessionBelongsToApplication.

/**
 * Validates that the snap session belongs to the given application.
 *
 * @param session the snapshot session
 * @param volumeGroup the volume group
 */
private void validateSnapSessionBelongsToApplication(BlockSnapshotSession session, VolumeGroup volumeGroup) {
    List<BlockSnapshotSession> volumeGroupSessions = getVolumeGroupSnapshotSessions(volumeGroup);
    Set<URI> sessionURIs = new HashSet<URI>();
    for (BlockSnapshotSession snapSession : volumeGroupSessions) {
        sessionURIs.add(snapSession.getId());
    }
    if (!sessionURIs.contains(session.getId())) {
        throw APIException.badRequests.replicaOperationNotAllowedSourceNotInVolumeGroup(ReplicaTypeEnum.SNAPSHOT_SESSION.toString(), session.getLabel());
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) HashSet(java.util.HashSet)

Aggregations

BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)112 URI (java.net.URI)64 Volume (com.emc.storageos.db.client.model.Volume)43 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)41 NamedURI (com.emc.storageos.db.client.model.NamedURI)38 ArrayList (java.util.ArrayList)33 BlockObject (com.emc.storageos.db.client.model.BlockObject)29 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)27 StringSet (com.emc.storageos.db.client.model.StringSet)25 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)17 HashMap (java.util.HashMap)17 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)16 CIMObjectPath (javax.cim.CIMObjectPath)13 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)11 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)11 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)11 DataObject (com.emc.storageos.db.client.model.DataObject)10 Project (com.emc.storageos.db.client.model.Project)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)10