Search in sources :

Example 1 with BlockObjectRestRep

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

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

the class VMWareProvider method createDatastoreOptions.

protected static List<AssetOption> createDatastoreOptions(List<? extends BlockObjectRestRep> mountedVolumes, URI hostId) {
    // There can be multiple volumes to a DS, so de-dupe in a hash map
    Map<String, List<String>> datastores = Maps.newHashMap();
    for (BlockObjectRestRep volume : mountedVolumes) {
        String key = KnownMachineTags.getBlockVolumeVMFSDatastore(hostId, volume);
        List<String> values = Lists.newArrayList();
        if (datastores.containsKey(key)) {
            values = datastores.get(key);
        }
        values.add(volume.getWwn());
        datastores.put(key, values);
    }
    List<AssetOption> options = Lists.newArrayList();
    for (Map.Entry<String, List<String>> datastore : datastores.entrySet()) {
        options.add(new AssetOption(datastore.getKey(), getMessage("datastore.label", datastore.getKey(), String.join(",", datastore.getValue()))));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) ArrayList(java.util.ArrayList) List(java.util.List) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) Map(java.util.Map)

Example 3 with BlockObjectRestRep

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

the class VMWareProvider method createBlockVolumeDatastoreOptions.

protected static List<AssetOption> createBlockVolumeDatastoreOptions(List<? extends BlockObjectRestRep> mountedVolumes, URI hostId) {
    List<AssetOption> options = Lists.newArrayList();
    for (BlockObjectRestRep volume : mountedVolumes) {
        Set<String> datastoreNames = VMwareDatastoreTagger.getDatastoreNames(volume);
        String datastoresLabel = datastoreNames.isEmpty() ? "N/A" : StringUtils.join(datastoreNames, ",");
        options.add(newAssetOption(volume.getId(), "volume.hlu.datastore", volume.getName(), datastoresLabel, volume.getWwn()));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 4 with BlockObjectRestRep

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

the class BlockProvider method createVolumeOptions.

protected static List<AssetOption> createVolumeOptions(ViPRCoreClient client, URI project, URI hostId, Collection<? extends BlockObjectRestRep> blockObjects) {
    Map<URI, VolumeRestRep> volumeNames = getProjectVolumeNames(client, project);
    List<AssetOption> options = Lists.newArrayList();
    for (BlockObjectRestRep blockObject : blockObjects) {
        options.add(createVolumeOption(client, hostId, blockObject, volumeNames));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 5 with BlockObjectRestRep

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

the class BlockProvider method createVolumeWithVarrayOptions.

protected static List<AssetOption> createVolumeWithVarrayOptions(ViPRCoreClient client, Collection<? extends BlockObjectRestRep> blockObjects) {
    List<URI> varrayIds = getVirtualArrayIds(blockObjects);
    Map<URI, VirtualArrayRestRep> varrayNames = getVirutalArrayNames(client, varrayIds);
    List<AssetOption> options = Lists.newArrayList();
    for (BlockObjectRestRep blockObject : blockObjects) {
        options.add(createVolumeWithVarrayOption(blockObject, varrayNames));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) URI(java.net.URI) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Aggregations

BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)60 URI (java.net.URI)30 Host (com.emc.storageos.db.client.model.Host)8 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)8 ArrayList (java.util.ArrayList)8 DiskDrive (com.iwave.ext.windows.model.wmi.DiskDrive)7 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)5 Datastore (com.vmware.vim25.mo.Datastore)5 Map (java.util.Map)5 ExecutionException (com.emc.sa.engine.ExecutionException)4 DeactivateHost (com.emc.sa.service.vipr.compute.tasks.DeactivateHost)4 DiscoverHost (com.emc.sa.service.vipr.compute.tasks.DiscoverHost)4 GetHost (com.emc.sa.service.vipr.tasks.GetHost)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 HashMap (java.util.HashMap)4 HostRestRep (com.emc.storageos.model.host.HostRestRep)3 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)3 TimeoutException (com.emc.vipr.client.exceptions.TimeoutException)3 ViPRException (com.emc.vipr.client.exceptions.ViPRException)3 Disk (com.iwave.ext.windows.model.Disk)3