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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations