Search in sources :

Example 1 with BlockSnapshotRestRep

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

the class BlockProvider method findSnapshotsByProject.

private List<BlockSnapshotRestRep> findSnapshotsByProject(ViPRCoreClient client, URI project) {
    log.info("Finding snapshots by project {}", project);
    List<SearchResultResourceRep> snapshotRefs = client.blockSnapshots().performSearchBy(SearchConstants.PROJECT_PARAM, project);
    List<URI> ids = new ArrayList<>();
    for (SearchResultResourceRep ref : snapshotRefs) {
        ids.add(ref.getId());
    }
    List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByIds(ids, null);
    log.info("Got snapshots: [{}]", snapshots.size());
    return snapshots;
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) SearchResultResourceRep(com.emc.storageos.model.search.SearchResultResourceRep) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 2 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 3 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)

Example 4 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(List<BlockSnapshotRestRep> snapshots) {
    List<AssetOption> options = Lists.newArrayList();
    for (BlockSnapshotRestRep snapshot : snapshots) {
        options.add(new AssetOption(snapshot.getId(), getMessage("block.snapshot.labelNoVolume", snapshot.getName(), snapshot.getWwn())));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep)

Example 5 with BlockSnapshotRestRep

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

the class BlockProvider method getCurrentExportPortGroups.

@Asset("exportCurrentPortGroup")
@AssetDependencies({ "host", "exportPathExport", "exportPathVirtualArray" })
public List<AssetOption> getCurrentExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI exportId, URI varrayId) {
    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")) {
        ExportGroupRestRep exportGroup = client.blockExports().get(exportId);
        List<StoragePortGroupRestRep> storagePortGroups = new ArrayList<StoragePortGroupRestRep>();
        List<ExportBlockParam> blockParams = exportGroup.getVolumes();
        Set<URI> storageSystemURISet = new HashSet<URI>();
        if (!CollectionUtils.isEmpty(blockParams)) {
            for (ExportBlockParam blockParam : blockParams) {
                // Get each volume in the export group to get the storage system ID
                if (blockParam != null) {
                    URI resourceId = blockParam.getId();
                    URI storageDeviceURI = null;
                    if (ResourceType.isType(ResourceType.VOLUME, resourceId)) {
                        VolumeRestRep volume = client.blockVolumes().get(resourceId);
                        storageDeviceURI = volume.getStorageController();
                    } else if (ResourceType.isType(ResourceType.BLOCK_SNAPSHOT, resourceId)) {
                        BlockSnapshotRestRep snapshot = client.blockSnapshots().get(resourceId);
                        storageDeviceURI = snapshot.getStorageController();
                    }
                    if (storageDeviceURI != null) {
                        storageSystemURISet.add(storageDeviceURI);
                    }
                } else {
                    log.error("Block param not found in export group: {}", exportId);
                }
            }
        }
        if (!CollectionUtils.isEmpty(storageSystemURISet)) {
            Set<URI> portGroupSet = new HashSet<URI>();
            for (URI storageSystemURI : storageSystemURISet) {
                // Now use the storage system ID as well to query the storage port groups
                StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, exportId, storageSystemURI, null, null, false);
                List<StoragePortGroupRestRep> portGroupList = portGroups.getStoragePortGroups();
                if (!CollectionUtils.isEmpty(portGroupList)) {
                    for (StoragePortGroupRestRep portGroup : portGroupList) {
                        if (portGroupSet.add(portGroup.getId())) {
                            storagePortGroups.add(portGroup);
                        }
                    }
                }
            }
        }
        return createPortGroupOptions(storagePortGroups);
    }
    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) ArrayList(java.util.ArrayList) URI(java.net.URI) ExportBlockParam(com.emc.storageos.model.block.export.ExportBlockParam) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) StoragePortGroupRestRep(com.emc.storageos.model.portgroup.StoragePortGroupRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)43 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)21 URI (java.net.URI)18 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)14 ArrayList (java.util.ArrayList)11 Asset (com.emc.sa.asset.annotation.Asset)9 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)9 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)9 AssetOption (com.emc.vipr.model.catalog.AssetOption)6 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)5 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)5 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)5 HashSet (java.util.HashSet)5 VolumeGroupCopySetParam (com.emc.storageos.model.application.VolumeGroupCopySetParam)4 ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)4 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)3 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)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