Search in sources :

Example 36 with VolumeRestRep

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

the class BlockProvider method getVolumeFilter.

@Asset("sourceVolumeFilter")
@AssetDependencies({ "project", "blockVirtualPool" })
public List<AssetOption> getVolumeFilter(AssetOptionsContext ctx, URI projectId, URI virtualPoolId) {
    List<String> volumeNames = Lists.newArrayList();
    for (VolumeRestRep volume : listSourceVolumes(api(ctx), projectId, new VirtualPoolFilter(virtualPoolId))) {
        volumeNames.add(volume.getName());
    }
    Collections.sort(volumeNames, new StringComparator(false));
    return VirtualDataCenterProvider.getVolumeFilterOptions(volumeNames);
}
Also used : VplexVolumeVirtualPoolFilter(com.emc.vipr.client.core.filters.VplexVolumeVirtualPoolFilter) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) StringComparator(com.emc.sa.util.StringComparator) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 37 with VolumeRestRep

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

the class BlockProvider method getBlockVolumes.

@Asset("unassignedVplexBlockVolume")
@AssetDependencies({ "project", "host", "virtualArray" })
public List<AssetOption> getBlockVolumes(AssetOptionsContext ctx, final URI projectId, URI hostOrClusterId, URI virtualArrayId) {
    // get a list of all 'source' volumes that :
    // - are in this project and not exported to the given host/cluster
    // - are a 'source' volume
    // - are vplex volumes
    ViPRCoreClient client = api(ctx);
    Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(client, projectId, hostOrClusterId, virtualArrayId);
    UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
    SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
    VplexVolumeFilter vplexVolumeFilter = new VplexVolumeFilter();
    CachedResources<BlockVirtualPoolRestRep> blockVpools = new CachedResources<>(client.blockVpools());
    VplexVolumeVirtualPoolFilter virtualPoolFilter = new VplexVolumeVirtualPoolFilter(blockVpools);
    BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
    FilterChain<VolumeRestRep> filter = sourceTargetVolumesFilter.and(unexportedFilter).and(bootVolumeFilter.not()).and(vplexVolumeFilter.or(virtualPoolFilter));
    // perform the query and apply the filter
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, filter);
    // get a list of all volumes from our list that are in the target VArray, or use the target VArray for protection
    List<BlockObjectRestRep> acceptedVolumes = getVPlexVolumesInTargetVArray(client, virtualArrayId, volumes);
    return createVolumeOptions(client, acceptedVolumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) URI(java.net.URI) VplexVolumeFilter(com.emc.vipr.client.core.filters.VplexVolumeFilter) BlockVolumeBootVolumeFilter(com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) CachedResources(com.emc.vipr.client.core.util.CachedResources) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) VplexVolumeVirtualPoolFilter(com.emc.vipr.client.core.filters.VplexVolumeVirtualPoolFilter) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 38 with VolumeRestRep

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

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

the class BlockProvider method getApplicationFullCopyNamesForRestore.

/**
 * returns the list of application full copies that can be restored from. For RP, we exclude target copies because the target is read
 * only
 *
 * @param ctx
 * @param applicationId
 * @return
 */
@Asset("restoreFullCopyName")
@AssetDependencies("application")
public List<AssetOption> getApplicationFullCopyNamesForRestore(AssetOptionsContext ctx, URI applicationId) {
    List<VolumeRestRep> fullCopies = getFullCopiesForApplication(ctx, applicationId);
    Set<String> fullCopyNames = new HashSet<String>();
    for (VolumeRestRep vol : fullCopies) {
        if (vol != null && vol.getProtection() != null && vol.getProtection().getFullCopyRep() != null && vol.getProtection().getFullCopyRep().getFullCopySetName() != null && !fullCopyNames.contains(vol.getProtection().getFullCopyRep().getFullCopySetName())) {
            if (!isFullCopyOfRPTarget(ctx, vol)) {
                fullCopyNames.add(vol.getProtection().getFullCopyRep().getFullCopySetName());
            }
        }
    }
    return createStringOptions(fullCopyNames);
}
Also used : 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)

Example 40 with VolumeRestRep

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

the class BlockProvider method getVolumesWithContinuousCopies.

@Asset("volumeWithContinuousCopies")
@AssetDependencies("project")
public List<AssetOption> getVolumesWithContinuousCopies(AssetOptionsContext ctx, URI project) {
    final ViPRCoreClient client = api(ctx);
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project, new SourceTargetVolumesFilter() {

        @Override
        public boolean accept(VolumeRestRep volume) {
            if (volume.getProtection() == null) {
                return false;
            }
            MirrorRestRep mirrors = volume.getProtection().getMirrorRep();
            if (mirrors == null || mirrors.getMirrors() == null || mirrors.getMirrors().isEmpty()) {
                return false;
            }
            return true;
        }
    });
    return createVolumeOptions(client, volumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) MirrorRestRep(com.emc.storageos.model.block.VolumeRestRep.MirrorRestRep) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)136 URI (java.net.URI)74 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)49 Asset (com.emc.sa.asset.annotation.Asset)35 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)35 ArrayList (java.util.ArrayList)25 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)23 AssetOption (com.emc.vipr.model.catalog.AssetOption)20 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)13 HashSet (java.util.HashSet)13 UnManagedVolumeRestRep (com.emc.storageos.model.block.UnManagedVolumeRestRep)12 Test (org.junit.Test)12 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)11 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)10 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)9 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)8 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)7 VolumeCreate (com.emc.storageos.model.block.VolumeCreate)7 List (java.util.List)7 SnapshotList (com.emc.storageos.model.SnapshotList)6