Search in sources :

Example 1 with BlockSnapshotSessionList

use of com.emc.storageos.model.block.BlockSnapshotSessionList 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 2 with BlockSnapshotSessionList

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

the class VolumeGroupService method getVolumeGroupSnapshotSessions.

/**
 * List snapshot sessions for a volume group
 *
 * @param volumeGroupId The URI of the volume group.
 * @brief List snapshot session for a volume group
 * @return BlockSnapshotSessionList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshot-sessions")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BlockSnapshotSessionList getVolumeGroupSnapshotSessions(@PathParam("id") final URI volumeGroupId) {
    ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, ID_FIELD);
    // query volume group
    final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
    // get the snapshot sessions for each CG in the volume group
    BlockSnapshotSessionList snapshotSessionList = new BlockSnapshotSessionList();
    // get all snapshot sessions for the volume group
    List<BlockSnapshotSession> volumeGroupSessions = getVolumeGroupSnapshotSessions(volumeGroup);
    for (BlockSnapshotSession session : volumeGroupSessions) {
        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) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 3 with BlockSnapshotSessionList

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

the class BlockProvider method getLinkedSnapshotsForApplicationSnapshotSessionVolumeNew.

@Asset("linkedSnapshotsForApplicationSnapshotSessionLinkService")
@AssetDependencies({ "application", "applicationSnapshotSessionCopySets" })
public List<AssetOption> getLinkedSnapshotsForApplicationSnapshotSessionVolumeNew(AssetOptionsContext ctx, URI application, String selectedCopySet) {
    ViPRCoreClient client = api(ctx);
    List<BlockSnapshotRestRep> snapshots = new ArrayList<BlockSnapshotRestRep>();
    Set<String> replicationGroups = getReplicationGroupsForApplicationSnapshotSession(client, application, selectedCopySet);
    Set<String> copySets = client.application().getVolumeGroupSnapsetSessionSets(application).getCopySets();
    List<BlockSnapshotSessionRestRep> snapshotSessions = Lists.newArrayList();
    for (String copySet : copySets) {
        VolumeGroupCopySetParam param = new VolumeGroupCopySetParam();
        param.setCopySetName(copySet);
        BlockSnapshotSessionList snapshotSessionList = client.application().getVolumeGroupSnapshotSessionsByCopySet(application, param);
        List<BlockSnapshotSessionRestRep> snapshotSessionsTmp = client.blockSnapshotSessions().getByRefs(snapshotSessionList.getSnapSessionRelatedResourceList());
        snapshotSessions.addAll(snapshotSessionsTmp);
        for (BlockSnapshotSessionRestRep session : snapshotSessionsTmp) {
            if (replicationGroups.contains(BlockStorageUtils.stripRPTargetFromReplicationGroup(session.getReplicationGroupInstance()))) {
                for (RelatedResourceRep target : session.getLinkedTarget()) {
                    BlockSnapshotRestRep blockSnapshot = client.blockSnapshots().get(target);
                    snapshots.add(blockSnapshot);
                }
            }
        }
    }
    return constructSnapshotWithSnapshotSessionOptions(snapshots, snapshotSessions);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) ArrayList(java.util.ArrayList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with BlockSnapshotSessionList

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

the class BlockProvider method getLinkedSnapshotsForApplicationSnapshotSessionVolume.

@Asset("linkedSnapshotsForApplicationSnapshotSession")
@AssetDependencies({ "application", "applicationSnapshotSessionCopySets" })
public List<AssetOption> getLinkedSnapshotsForApplicationSnapshotSessionVolume(AssetOptionsContext ctx, URI application, String copySet) {
    List<BlockSnapshotRestRep> snapshots = new ArrayList<BlockSnapshotRestRep>();
    VolumeGroupCopySetParam param = new VolumeGroupCopySetParam();
    param.setCopySetName(copySet);
    BlockSnapshotSessionList snapshotSessionList = api(ctx).application().getVolumeGroupSnapshotSessionsByCopySet(application, param);
    List<BlockSnapshotSessionRestRep> snapshotSessions = api(ctx).blockSnapshotSessions().getByRefs(snapshotSessionList.getSnapSessionRelatedResourceList());
    for (BlockSnapshotSessionRestRep session : snapshotSessions) {
        for (RelatedResourceRep target : session.getLinkedTarget()) {
            BlockSnapshotRestRep blockSnapshot = api(ctx).blockSnapshots().get(target);
            snapshots.add(blockSnapshot);
        }
    }
    return constructSnapshotWithSnapshotSessionOptions(snapshots, snapshotSessions);
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) ArrayList(java.util.ArrayList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 5 with BlockSnapshotSessionList

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

the class BlockProvider method getApplicationSnapshotSessionCopySetsForRestore.

private Set<String> getApplicationSnapshotSessionCopySetsForRestore(AssetOptionsContext ctx, URI application) {
    Set<String> restoreCopySets = new HashSet<String>();
    Set<String> copySetNames = api(ctx).application().getVolumeGroupSnapsetSessionSets(application).getCopySets();
    boolean isRP = false;
    NamedVolumesList volsInApp = api(ctx).application().getVolumeByApplication(application);
    if (volsInApp != null && volsInApp.getVolumes() != null && !volsInApp.getVolumes().isEmpty()) {
        VolumeRestRep firstVol = api(ctx).blockVolumes().get(volsInApp.getVolumes().get(0).getId());
        isRP = BlockStorageUtils.isRPVolume(firstVol);
    }
    if (isRP) {
        List<VolumeRestRep> applicationVolumes = api(ctx).blockVolumes().getByRefs(api(ctx).application().getVolumeByApplication(application).getVolumes());
        Set<String> sourceRepGrpNames = new HashSet<String>();
        for (VolumeRestRep volume : applicationVolumes) {
            if (volume.getReplicationGroupInstance() != null && BlockStorageUtils.isRPSourceVolume(volume)) {
                sourceRepGrpNames.add(volume.getReplicationGroupInstance());
            }
        }
        for (String copySetName : copySetNames) {
            VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
            input.setCopySetName(copySetName);
            BlockSnapshotSessionList sessions = api(ctx).application().getVolumeGroupSnapshotSessionsByCopySet(application, input);
            if (sessions != null && sessions.getSnapSessionRelatedResourceList() != null && !sessions.getSnapSessionRelatedResourceList().isEmpty()) {
                BlockSnapshotSessionRestRep sessionRep = api(ctx).blockSnapshotSessions().get(sessions.getSnapSessionRelatedResourceList().get(0));
                if (sessionRep != null && sessionRep.getReplicationGroupInstance() != null && sourceRepGrpNames.contains(sessionRep.getReplicationGroupInstance())) {
                    restoreCopySets.add(copySetName);
                }
            }
        }
    } else {
        restoreCopySets.addAll(copySetNames);
    }
    return restoreCopySets;
}
Also used : BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) HashSet(java.util.HashSet)

Aggregations

BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)9 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)4 VolumeGroupCopySetParam (com.emc.storageos.model.application.VolumeGroupCopySetParam)4 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)4 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)3 Asset (com.emc.sa.asset.annotation.Asset)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)2 VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)2 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)2 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 ArrayList (java.util.ArrayList)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 Volume (com.emc.storageos.db.client.model.Volume)1 VolumeGroupCopySetList (com.emc.storageos.model.application.VolumeGroupCopySetList)1 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)1 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)1