Search in sources :

Example 1 with BlockVolumeBootVolumeFilter

use of com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter 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 2 with BlockVolumeBootVolumeFilter

use of com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter in project coprhd-controller by CoprHD.

the class BlockProvider method getBlockVolumes.

@Asset("unassignedBlockVolume")
@AssetDependencies({ "host", "project", "blockStorageType" })
public List<AssetOption> getBlockVolumes(AssetOptionsContext ctx, URI hostOrClusterId, final URI projectId, String blockStorageType) {
    ViPRCoreClient client = api(ctx);
    Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(client, projectId, hostOrClusterId, null);
    UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
    SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
    BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, unexportedFilter.and(sourceTargetVolumesFilter).and(bootVolumeFilter.not()));
    // get varray IDs for host/cluster
    List<VirtualArrayRestRep> varrays = new ArrayList<>();
    if (EXCLUSIVE_STORAGE_OPTION.key.equals(blockStorageType) && URIUtil.isType(hostOrClusterId, Host.class)) {
        varrays = client.varrays().findByConnectedHost(hostOrClusterId);
    } else if (SHARED_STORAGE_OPTION.key.equals(blockStorageType) && URIUtil.isType(hostOrClusterId, Cluster.class)) {
        varrays = client.varrays().findByConnectedCluster(hostOrClusterId);
    }
    List<URI> varrayIds = new ArrayList<>();
    for (VirtualArrayRestRep varray : varrays) {
        varrayIds.add(varray.getId());
    }
    // remove volumes not in hosts/cluster's varray
    Iterator<VolumeRestRep> itr = volumes.iterator();
    while (itr.hasNext()) {
        if (!varrayIds.contains(itr.next().getVirtualArray().getId())) {
            itr.remove();
        }
    }
    return createVolumeOptions(client, volumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) URI(java.net.URI) BlockVolumeBootVolumeFilter(com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 3 with BlockVolumeBootVolumeFilter

use of com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter in project coprhd-controller by CoprHD.

the class VMWareProvider method getUnassignedDatastores.

@Asset("unassignedBlockDatastore")
@AssetDependencies({ "esxHost", "project" })
public List<AssetOption> getUnassignedDatastores(AssetOptionsContext ctx, URI hostOrClusterId, final URI projectId) {
    ViPRCoreClient client = api(ctx);
    Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(api(ctx), projectId, hostOrClusterId, null);
    UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
    SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
    BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, unexportedFilter.and(sourceTargetVolumesFilter).and(bootVolumeFilter.not()));
    return createBlockVolumeDatastoreOptions(volumes, hostOrClusterId);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) UnexportedBlockResourceFilter(com.emc.sa.asset.providers.BlockProvider.UnexportedBlockResourceFilter) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) BlockVolumeBootVolumeFilter(com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with BlockVolumeBootVolumeFilter

use of com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter in project coprhd-controller by CoprHD.

the class BlockProvider method getExportedVolumes.

@Asset("exportedBlockVolume")
@AssetDependencies("project")
public List<AssetOption> getExportedVolumes(AssetOptionsContext ctx, URI project) {
    debug("getting source block volumes (project=%s)", project);
    final ViPRCoreClient client = api(ctx);
    // Filter volumes that are not RP Metadata
    List<URI> volumeIds = getExportedVolumeIds(ctx, project);
    FilterChain<VolumeRestRep> filter = new FilterChain<VolumeRestRep>(RecoverPointPersonalityFilter.METADATA.not());
    filter.and(new BlockVolumeVMFSDatastoreFilter().not());
    filter.and(new BlockVolumeBootVolumeFilter().not());
    filter.and(new BlockVolumeMountPointFilter().not());
    List<VolumeRestRep> volumes = client.blockVolumes().getByIds(volumeIds, filter);
    return createVolumeWithVarrayOptions(client, volumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FilterChain(com.emc.vipr.client.core.filters.FilterChain) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) BlockVolumeBootVolumeFilter(com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

Asset (com.emc.sa.asset.annotation.Asset)4 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)4 BlockVolumeBootVolumeFilter (com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter)4 URI (java.net.URI)4 SourceTargetVolumesFilter (com.emc.vipr.client.core.filters.SourceTargetVolumesFilter)3 UnexportedBlockResourceFilter (com.emc.sa.asset.providers.BlockProvider.UnexportedBlockResourceFilter)1 Host (com.emc.storageos.db.client.model.Host)1 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)1 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)1 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)1 FilterChain (com.emc.vipr.client.core.filters.FilterChain)1 VplexVolumeFilter (com.emc.vipr.client.core.filters.VplexVolumeFilter)1 VplexVolumeVirtualPoolFilter (com.emc.vipr.client.core.filters.VplexVolumeVirtualPoolFilter)1 CachedResources (com.emc.vipr.client.core.util.CachedResources)1 ArrayList (java.util.ArrayList)1