Search in sources :

Example 6 with BlockSnapshotSessionRestRep

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

the class BlockVolumes method unlinkTargetSnapshot.

public static void unlinkTargetSnapshot(String sessionId, String volumeId, Boolean deleteOption) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    SnapshotSessionUnlinkTargetsParam sessionTargets = new SnapshotSessionUnlinkTargetsParam();
    List<SnapshotSessionUnlinkTargetParam> targetLists = Lists.newArrayList();
    List<RelatedResourceRep> targets = client.blockSnapshotSessions().get(uri(sessionId)).getLinkedTarget();
    List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByRefs(targets);
    for (BlockSnapshotRestRep snap : snapshots) {
        SnapshotSessionUnlinkTargetParam targetList = new SnapshotSessionUnlinkTargetParam();
        targetList.setId(snap.getId());
        targetList.setDeleteTarget(deleteOption);
        targetLists.add(targetList);
    }
    if (!targetLists.isEmpty()) {
        sessionTargets.setLinkedTargets(targetLists);
        Task<BlockSnapshotSessionRestRep> tasks = client.blockSnapshotSessions().unlinkTargets(uri(sessionId), sessionTargets);
        flash.put("info", MessagesUtils.get("resources.snapshot.session.unlink.success", sessionId));
    } else {
        flash.error(MessagesUtils.get(NOTARGET, sessionId));
    }
    volume(volumeId, null);
}
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) SnapshotSessionUnlinkTargetParam(com.emc.storageos.model.block.SnapshotSessionUnlinkTargetParam) SnapshotSessionUnlinkTargetsParam(com.emc.storageos.model.block.SnapshotSessionUnlinkTargetsParam)

Example 7 with BlockSnapshotSessionRestRep

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

the class BlockVolumes method volumeSnapshotSessions.

public static void volumeSnapshotSessions(String volumeId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    VolumeRestRep volume = client.blockVolumes().get(uri(volumeId));
    List<BlockSnapshotSessionRestRep> snapshotSessions = Lists.newArrayList();
    if (volume.getConsistencyGroup() != null) {
        URI consistencygroup = volume.getConsistencyGroup().getId();
        List<NamedRelatedResourceRep> cgSessions = client.blockConsistencyGroups().getSnapshotSessions(consistencygroup);
        snapshotSessions = client.blockSnapshotSessions().getByRefs(cgSessions);
    } else {
        List<NamedRelatedResourceRep> refs = client.blockSnapshotSessions().listByVolume(uri(volumeId));
        snapshotSessions = client.blockSnapshotSessions().getByRefs(refs);
    }
    render(snapshotSessions, volumeId);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 8 with BlockSnapshotSessionRestRep

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

the class BlockProvider method constructSnapshotWithSnapshotSessionOptions.

protected List<AssetOption> constructSnapshotWithSnapshotSessionOptions(List<BlockSnapshotRestRep> snapshots, List<BlockSnapshotSessionRestRep> snapshotSessions) {
    List<AssetOption> options = Lists.newArrayList();
    // Create a map of linked target URIs to snapshot session names for convenience when creating
    // the option labels.
    Map<URI, String> linkedSnapshotToSnapshotSessionMap = new HashMap<URI, String>();
    for (BlockSnapshotSessionRestRep snapshotSession : snapshotSessions) {
        for (RelatedResourceRep linkedTarget : snapshotSession.getLinkedTarget()) {
            linkedSnapshotToSnapshotSessionMap.put(linkedTarget.getId(), snapshotSession.getName());
        }
    }
    for (BlockSnapshotRestRep snapshot : snapshots) {
        // Ignore RP Bookmarks for snapshot session options
        boolean isRPSnapshot = (snapshot.getTechnologyType() != null && snapshot.getTechnologyType().equalsIgnoreCase(RECOVERPOINT_BOOKMARK_SNAPSHOT_TYPE_VALUE));
        boolean validSnapshotOption = snapshot.getTechnologyType() == null || !isRPSnapshot;
        if (validSnapshotOption) {
            options.add(new AssetOption(snapshot.getId(), getBlockSnapshotLinkedLabel(snapshot, linkedSnapshotToSnapshotSessionMap)));
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) HashMap(java.util.HashMap) URI(java.net.URI)

Example 9 with BlockSnapshotSessionRestRep

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

the class BlockProvider method getLinkedSnapshotsForSnapshotSessionVolume.

@Asset("linkedSnapshotsForVolume")
@AssetDependencies({ "snapshotSessionBlockVolume", "blockVolumeOrConsistencyType" })
public List<AssetOption> getLinkedSnapshotsForSnapshotSessionVolume(AssetOptionsContext ctx, URI volumeOrCGId, String volumeOrConsistencyType) {
    if (!checkTypeConsistency(volumeOrCGId, volumeOrConsistencyType)) {
        warn("Inconsistent types, %s and %s, return empty results", volumeOrCGId, volumeOrConsistencyType);
        return new ArrayList<AssetOption>();
    }
    List<BlockSnapshotRestRep> snapshots = new ArrayList<BlockSnapshotRestRep>();
    List<BlockSnapshotSessionRestRep> snapshotSessions = new ArrayList<BlockSnapshotSessionRestRep>();
    final ViPRCoreClient client = api(ctx);
    if (isVolumeType(volumeOrConsistencyType)) {
        snapshots = client.blockSnapshots().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
        snapshotSessions = client.blockSnapshotSessions().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
    } else {
        snapshots = client.blockSnapshots().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
        snapshotSessions = client.blockSnapshotSessions().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
    }
    return constructSnapshotWithSnapshotSessionOptions(snapshots, snapshotSessions);
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) ArrayList(java.util.ArrayList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 10 with BlockSnapshotSessionRestRep

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

the class BlockProvider method getVolumeSnapshotSessionOptionsForProject.

/**
 * get single volume snapshot sessions for a project
 * @param ctx
 * @param project
 * @return
 */
private List<AssetOption> getVolumeSnapshotSessionOptionsForProject(AssetOptionsContext ctx, URI project) {
    final ViPRCoreClient client = api(ctx);
    List<BlockSnapshotSessionRestRep> snapshotSessions = client.blockSnapshotSessions().findByProject(project);
    List<BlockSnapshotSessionRestRep> singleVolumeSnapshotSessions = new ArrayList<BlockSnapshotSessionRestRep>();
    for (BlockSnapshotSessionRestRep snapshotSession : snapshotSessions) {
        if (snapshotSession.getReplicationGroupInstance() == null) {
            singleVolumeSnapshotSessions.add(snapshotSession);
        }
    }
    return constructSnapshotSessionOptions(client, project, singleVolumeSnapshotSessions);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) ArrayList(java.util.ArrayList)

Aggregations

BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)20 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)9 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)8 URI (java.net.URI)8 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)5 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5 ArrayList (java.util.ArrayList)5 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)4 VolumeGroupCopySetParam (com.emc.storageos.model.application.VolumeGroupCopySetParam)4 BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 Asset (com.emc.sa.asset.annotation.Asset)3 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)3 DeactivateBlockSnapshotSession (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshotSession)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 GetBlockSnapshotSession (com.emc.sa.service.vipr.application.tasks.GetBlockSnapshotSession)1 GetBlockSnapshotSessionList (com.emc.sa.service.vipr.application.tasks.GetBlockSnapshotSessionList)1 DeactivateBlockSnapshot (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)1