use of com.emc.vipr.model.catalog.AssetOption 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.vipr.model.catalog.AssetOption 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.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class VcenterClusterProvider method getClusterOptions.
@Asset("vcenterCluster")
public List<AssetOption> getClusterOptions(AssetOptionsContext ctx) {
debug("getting clusters");
Collection<ClusterRestRep> clusters = getClusters(ctx);
List<AssetOption> options = Lists.newArrayList();
Map<URI, String> vcenterMap = getVcenters(ctx);
Map<URI, String> dataCenterNameMap = new HashMap<URI, String>();
Map<URI, String> dataCenterVcenterMap = new HashMap<URI, String>();
String vcenterName;
String datacenterName;
for (ClusterRestRep value : clusters) {
if (value.getVcenterDataCenter() != null) {
RelatedResourceRep datacenterVal = value.getVcenterDataCenter();
if (datacenterVal != null) {
if (dataCenterVcenterMap.get(datacenterVal.getId()) == null) {
VcenterDataCenterRestRep restResponse = api(ctx).vcenterDataCenters().get(datacenterVal.getId());
datacenterName = restResponse.getName();
dataCenterNameMap.put(datacenterVal.getId(), datacenterName);
RelatedResourceRep vcenterResp = restResponse.getVcenter();
if (vcenterMap.get(vcenterResp.getId()) == null) {
VcenterRestRep vcenterRep = api(ctx).vcenters().get(vcenterResp);
vcenterMap.put(vcenterResp.getId(), vcenterRep.getName());
vcenterName = vcenterRep.getName();
dataCenterVcenterMap.put(datacenterVal.getId(), vcenterName);
} else {
vcenterName = vcenterMap.get(vcenterResp.getId());
dataCenterVcenterMap.put(datacenterVal.getId(), vcenterName);
}
} else {
datacenterName = dataCenterNameMap.get(datacenterVal.getId());
vcenterName = dataCenterVcenterMap.get(datacenterVal.getId());
}
options.add(createClusterOption(ctx, value, true, vcenterName, datacenterName));
}
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class VcenterClusterProvider method getNewClusterOptions.
@Asset("newVcenterCluster")
public List<AssetOption> getNewClusterOptions(AssetOptionsContext ctx) {
debug("getting clusters");
Collection<ClusterRestRep> clusters = getClusters(ctx);
List<AssetOption> options = Lists.newArrayList();
for (ClusterRestRep value : clusters) {
if (value.getVcenterDataCenter() == null) {
options.add(createClusterOption(ctx, value, false, "", ""));
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.
the class VirtualArrayProvider method getVirtualArray.
@Asset("virtualArray")
@AssetDependencies({ "host" })
public List<AssetOption> getVirtualArray(AssetOptionsContext context, URI hostOrClusterId) {
ViPRCoreClient client = api(context);
List<URI> hostIds = HostProvider.getHostIds(client, hostOrClusterId);
Map<URI, VirtualArrayRestRep> virtualArrays = null;
Map<URI, VirtualArrayRestRep> allVirtualArrays = Maps.newHashMap();
for (URI hostId : hostIds) {
Map<URI, VirtualArrayRestRep> connectedVirtualArrays = ResourceUtils.mapById(client.varrays().findByConnectedHost(hostId));
if (virtualArrays == null) {
virtualArrays = connectedVirtualArrays;
} else {
virtualArrays.keySet().retainAll(connectedVirtualArrays.keySet());
}
allVirtualArrays.putAll(connectedVirtualArrays);
}
// Creates options for the virtual arrays, showing an indication whether the virtual array is only
// partially connected to the cluster
List<AssetOption> fullyConnectedOptions = new ArrayList<>();
List<AssetOption> partiallyConnectedOptions = new ArrayList<>();
List<VirtualArrayRestRep> varraysByTenant = client.varrays().getByTenant(context.getTenant());
for (VirtualArrayRestRep varray : allVirtualArrays.values()) {
if (!contains(varray.getId(), varraysByTenant)) {
continue;
}
boolean fullyConnected = virtualArrays.containsKey(varray.getId());
if (fullyConnected) {
fullyConnectedOptions.add(new AssetOption(varray.getId(), varray.getName()));
} else {
String label = getMessage("virtualArray.partiallyConnected", varray.getName());
partiallyConnectedOptions.add(new AssetOption(varray.getId(), label));
}
}
AssetOptionsUtils.sortOptionsByLabel(fullyConnectedOptions);
AssetOptionsUtils.sortOptionsByLabel(partiallyConnectedOptions);
// Place the fully connected options first
List<AssetOption> options = new ArrayList<>();
options.addAll(fullyConnectedOptions);
options.addAll(partiallyConnectedOptions);
return options;
}
Aggregations