Search in sources :

Example 31 with BlockSnapshotRestRep

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

the class BlockProvider method getProjectBlockResources.

protected List<BlockObjectRestRep> getProjectBlockResources(ViPRCoreClient client, URI hostOrClusterId, URI project, boolean onlyMounted) {
    List<BlockObjectRestRep> blockObjects = Lists.newArrayList();
    // the list of host ids that the volume could be mounted to
    List<URI> hostIds = getHostIds(client, hostOrClusterId, onlyMounted);
    // get a list of all volumes and snapshots in the project
    List<VolumeRestRep> projectVolumes = client.blockVolumes().findByProject(project);
    List<BlockSnapshotRestRep> projectSnapshots = client.blockSnapshots().findByProject(project);
    // cycle through every volume in the project and add the volume and its snapshots
    for (VolumeRestRep volume : projectVolumes) {
        boolean isMounted = isMounted(hostIds, volume);
        if ((onlyMounted && isMounted) || (!onlyMounted && !isMounted)) {
            addVolume(blockObjects, volume, projectSnapshots);
        }
    }
    // remaining snapshots can be added now. We don't know their parent volume but we need them in the list anyway
    blockObjects.addAll(projectSnapshots);
    return blockObjects;
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Example 32 with BlockSnapshotRestRep

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

the class BlockProvider method getExportSnapshotForHostPortGroups.

@Asset("exportSnapshotForHostPortGroups")
@AssetDependencies({ "unassignedBlockSnapshot", "host", "project" })
public List<AssetOption> getExportSnapshotForHostPortGroups(AssetOptionsContext ctx, String selectedSnapshots, URI hostOrClusterId, URI projectId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        List<URI> snapshotIds = Lists.newArrayList();
        info("Snapshots selected by user: %s", selectedSnapshots);
        List<String> parsedSnapshotIds = TextUtils.parseCSV(selectedSnapshots);
        for (String id : parsedSnapshotIds) {
            snapshotIds.add(uri(id));
        }
        List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByIds(snapshotIds);
        Set<URI> virtualArrays = new HashSet<URI>();
        Set<URI> storageSystems = new HashSet<URI>();
        for (BlockSnapshotRestRep snapshot : snapshots) {
            virtualArrays.add(snapshot.getVirtualArray().getId());
            storageSystems.add(snapshot.getStorageController());
        }
        if (virtualArrays.size() == 1 && storageSystems.size() == 1) {
            Iterator<URI> it = virtualArrays.iterator();
            URI varrayId = it.next();
            ExportGroupRestRep export = findExportGroup(hostOrClusterId, projectId, varrayId, client);
            Iterator<URI> ssIt = storageSystems.iterator();
            StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, export != null ? export.getId() : null, ssIt.next(), null, null, true);
            return createPortGroupOptions(portGroups.getStoragePortGroups());
        }
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) URI(java.net.URI) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 33 with BlockSnapshotRestRep

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

the class BlockStorageUtils method startSnapshot.

public static void startSnapshot(URI snapshotId) {
    Task<BlockSnapshotRestRep> task = execute(new StartBlockSnapshot(snapshotId));
    addAffectedResource(task);
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) StartBlockSnapshot(com.emc.sa.service.vipr.block.tasks.StartBlockSnapshot)

Example 34 with BlockSnapshotRestRep

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

the class BlockStorageUtils method createSnapshotFullCopy.

public static Tasks<BlockSnapshotRestRep> createSnapshotFullCopy(URI snapshotId, String name, Integer count) {
    int countValue = (count != null) ? count : 1;
    Tasks<BlockSnapshotRestRep> copyTasks = ViPRExecutionUtils.execute(new CreateSnapshotFullCopy(snapshotId, name, countValue));
    addAffectedResources(copyTasks);
    return copyTasks;
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) CreateSnapshotFullCopy(com.emc.sa.service.vipr.block.tasks.CreateSnapshotFullCopy)

Example 35 with BlockSnapshotRestRep

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

the class BlockStorageUtils method deactivateSnapshot.

private static void deactivateSnapshot(URI snapshotId, VolumeDeleteTypeEnum type) {
    Tasks<BlockSnapshotRestRep> tasks = execute(new DeactivateBlockSnapshot(snapshotId, type));
    addAffectedResources(tasks);
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) DeactivateBlockSnapshot(com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot)

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