Search in sources :

Example 6 with BlockSnapshotRestRep

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

the class TestBlockStorageUtils method prepare.

static List<URI> prepare(ViPRCoreClient client) throws URISyntaxException {
    List<URI> returnList = new ArrayList<>();
    ProjectRestRep project = client.projects().get(new URI("urn:storageos:Project:3e1ef32b-3091-4a83-9fac-4a2a3bc30413:global"));
    for (BlockSnapshotRestRep r : client.blockSnapshots().findByProject(project)) {
        returnList.add(r.getId());
    }
    for (VolumeRestRep r : client.blockVolumes().findByProject(project)) {
        returnList.add(r.getId());
    }
    return returnList;
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) ArrayList(java.util.ArrayList) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI)

Example 7 with BlockSnapshotRestRep

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

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

the class BlockProvider method getBlockVolumesWithSnapshot.

@Asset("blockVolumeWithSnapshot")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getBlockVolumesWithSnapshot(AssetOptionsContext context, URI project, String volumeOrConsistencyType) {
    final ViPRCoreClient client = api(context);
    if (isVolumeType(volumeOrConsistencyType)) {
        Set<URI> volIdSet = new HashSet<>();
        List<BlockSnapshotRestRep> snapshots = findSnapshotsByProject(client, project);
        for (BlockSnapshotRestRep snapshot : snapshots) {
            volIdSet.add(snapshot.getParent().getId());
        }
        // Have to get volumes just as it needs vol's mount point which snapshot doesn't have.
        List<VolumeRestRep> volumes = getVolumesByIds(client, volIdSet);
        List<VolumeRestRep> filteredVols = new ArrayList<>();
        for (VolumeRestRep vol : volumes) {
            if (StringUtils.isEmpty(vol.getReplicationGroupInstance())) {
                filteredVols.add(vol);
            }
        }
        return createVolumeOptions(client, filteredVols);
    } else {
        List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).run();
        return createBaseResourceOptions(consistencyGroups);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) ArrayList(java.util.ArrayList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 9 with BlockSnapshotRestRep

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

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

the class BlockProvider method constructSnapshotOptions.

protected List<AssetOption> constructSnapshotOptions(ViPRCoreClient client, URI project, List<BlockSnapshotRestRep> snapshots) {
    List<AssetOption> options = Lists.newArrayList();
    Map<URI, VolumeRestRep> volumeNames = getProjectVolumeNames(client, project);
    for (BlockSnapshotRestRep snapshot : snapshots) {
        options.add(new AssetOption(snapshot.getId(), getBlockObjectLabel(client, snapshot, volumeNames)));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI)

Aggregations

BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)41 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)20 URI (java.net.URI)17 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)13 ArrayList (java.util.ArrayList)10 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)9 Asset (com.emc.sa.asset.annotation.Asset)8 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)8 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)5 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)5 AssetOption (com.emc.vipr.model.catalog.AssetOption)5 VolumeGroupCopySetParam (com.emc.storageos.model.application.VolumeGroupCopySetParam)4 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)4 HashSet (java.util.HashSet)4 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)3 ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)3 DeactivateBlockSnapshot (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot)2 ResourceType (com.emc.sa.util.ResourceType)2 SnapshotList (com.emc.storageos.model.SnapshotList)2 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)2