use of models.datatable.HostDataTable.HostInfo in project coprhd-controller by CoprHD.
the class Hosts method listJson.
public static void listJson() {
String tenantId = Models.currentAdminTenant();
List<HostRestRep> hosts = HostUtils.getHosts(tenantId);
Map<URI, String> clusterMap = ResourceUtils.mapNames(getViprClient().clusters().listByTenant(uri(tenantId)));
Set<URI> dataCenterIds = HostUtils.getDataCenterIds(hosts);
Map<URI, VcenterDataCenterRestRep> vcenterDataCenters = HostUtils.getVcenterDataCenters(dataCenterIds);
List<HostInfo> hostInfos = Lists.newArrayList();
for (HostRestRep host : hosts) {
hostInfos.add(new HostInfo(host, clusterMap, vcenterDataCenters));
}
renderJSON(DataTablesSupport.createJSON(hostInfos, params));
}
use of models.datatable.HostDataTable.HostInfo in project coprhd-controller by CoprHD.
the class Hosts method itemsJson.
public static void itemsJson(@As(",") String[] ids) {
Map<URI, String> clusterMap = ResourceUtils.mapNames(getViprClient().clusters().listByTenant(uri(Models.currentAdminTenant())));
List<HostInfo> results = Lists.newArrayList();
if ((ids != null) && (ids.length > 0)) {
for (String id : ids) {
if (StringUtils.isBlank(id)) {
continue;
}
HostRestRep host = HostUtils.getHost(uri(id));
if (host != null) {
Set<URI> dataCenterIds = HostUtils.getDataCenterIds(Lists.newArrayList(host));
Map<URI, VcenterDataCenterRestRep> vcenterDataCenters = HostUtils.getVcenterDataCenters(dataCenterIds);
results.add(new HostInfo(host, clusterMap, vcenterDataCenters));
}
}
}
renderJSON(results);
}
Aggregations