use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.
the class BaseHostProvider method getClustersMap.
protected Map<URI, String> getClustersMap(AssetOptionsContext context, List<HostRestRep> hosts) {
Set<URI> clusterIds = Sets.newHashSet();
for (HostRestRep host : hosts) {
URI clusterId = ResourceUtils.id(host.getCluster());
if (clusterId != null) {
clusterIds.add(clusterId);
}
}
Collection<ClusterRestRep> clusters = api(context).clusters().getByIds(clusterIds, null);
Map<URI, String> clusterMap = new HashMap<URI, String>();
for (ClusterRestRep cluster : clusters) {
clusterMap.put(cluster.getId(), cluster.getName());
}
return clusterMap;
}
use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.
the class BaseHostProvider method createFileHostOptions.
protected List<AssetOption> createFileHostOptions(AssetOptionsContext ctx, Collection<HostRestRep> hosts) {
List<AssetOption> options = Lists.newArrayList();
for (HostRestRep value : hosts) {
options.add(createFileHostOption(ctx, value));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.
the class VMWareProvider method filterClusterHosts.
/**
* Filter out hosts in the cluster when other hosts in that cluster have failed discovery or
* are incompatible.
*
* @param context
* asset context
* @param datacenter
* data center
* @param storageType
* storage type (exclusive or shared)
* @param esxHosts
* list of all esx hosts that are discovered and compatible
*/
private void filterClusterHosts(AssetOptionsContext context, URI datacenter, String storageType, List<HostRestRep> esxHosts) {
// Gather all ESX hosts that didn't match the filter
if (esxHosts != null && !esxHosts.isEmpty() && storageType.equalsIgnoreCase(BlockProvider.SHARED_STORAGE.toString())) {
List<HostRestRep> misfitEsxHosts = api(context).hosts().getByDataCenter(datacenter, HostTypeFilter.ESX.and(REGISTERED.not()).or(INCOMPATIBLE).or(COMPLETE.not()));
Set<URI> misfitEsxClusterIds = new HashSet<>();
if (misfitEsxHosts != null && !misfitEsxHosts.isEmpty()) {
for (HostRestRep misfitEsxHost : misfitEsxHosts) {
if (misfitEsxHost.getCluster() != null && !NullColumnValueGetter.isNullURI(misfitEsxHost.getCluster().getId())) {
misfitEsxClusterIds.add(misfitEsxHost.getCluster().getId());
}
}
Iterator<HostRestRep> esxHostIter = esxHosts.iterator();
while (esxHostIter.hasNext()) {
HostRestRep esxHost = esxHostIter.next();
if (esxHost.getCluster() != null && !NullColumnValueGetter.isNullURI(esxHost.getCluster().getId()) && misfitEsxClusterIds.contains(esxHost.getCluster().getId())) {
esxHostIter.remove();
}
}
}
}
}
use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.
the class ClusterProvider method getEsxClusterOptions.
@Asset("esxCluster")
public List<AssetOption> getEsxClusterOptions(AssetOptionsContext ctx) {
debug("getting esx clusters");
Collection<ClusterRestRep> clusters = getClusters(ctx);
List<AssetOption> options = Lists.newArrayList();
for (ClusterRestRep value : clusters) {
// If Cluster has an esx host - then add it to the list
List<HostRestRep> hostList = api(ctx).hosts().getByCluster(value.getId());
for (HostRestRep host : hostList) {
if (host.getType().equalsIgnoreCase(Host.HostType.Esx.name())) {
String dataCenterName = getDataCenterName(ctx, value);
options.add(createClusterOption(ctx, value, dataCenterName));
break;
}
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.
the class ClusterProvider method getVblockClusterOptions.
@Asset("vblockCluster")
public List<AssetOption> getVblockClusterOptions(AssetOptionsContext ctx) {
debug("getting vblock clusters");
Collection<ClusterRestRep> clusters = getClusters(ctx);
List<AssetOption> options = Lists.newArrayList();
for (ClusterRestRep value : clusters) {
List<HostRestRep> hostList = api(ctx).hosts().getByCluster(value.getId());
for (HostRestRep host : hostList) {
// If Cluster has an esx or No-OS host and if host has a computeElement - then add it to the list
if (host.getType() != null && (host.getType().equalsIgnoreCase(Host.HostType.Esx.name()) || host.getType().equalsIgnoreCase(Host.HostType.No_OS.name())) && host.getComputeElement() != null && !NullColumnValueGetter.isNullURI(host.getComputeElement().getId())) {
String dataCenterName = getDataCenterName(ctx, value);
options.add(createClusterOption(ctx, value, dataCenterName));
break;
}
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
Aggregations