use of com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep in project coprhd-controller by CoprHD.
the class HostClusters method itemDetails.
public static void itemDetails(String id) {
ClusterRestRep cluster = ClusterUtils.getCluster(uri(id));
if (cluster == null) {
error(MessagesUtils.get(UNKNOWN, id));
}
ProjectRestRep project = ProjectUtils.getProject(ResourceUtils.id(cluster.getProject()));
List<HostRestRep> hosts = ClusterUtils.getHosts(uri(id));
VcenterDataCenterRestRep dataCenter = VCenterUtils.getDataCenter(ResourceUtils.id(cluster.getVcenterDataCenter()));
VcenterRestRep vcenter = VCenterUtils.getVCenter(dataCenter);
render(cluster, project, hosts, dataCenter, vcenter);
}
use of com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep 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 com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep in project coprhd-controller by CoprHD.
the class Hosts method itemDetails.
public static void itemDetails(String id) {
HostRestRep host = HostUtils.getHost(uri(id));
ClusterRestRep cluster = ClusterUtils.getCluster(ResourceUtils.id(host.getCluster()));
VcenterDataCenterRestRep dataCenter = VCenterUtils.getDataCenter(ResourceUtils.id(host.getvCenterDataCenter()));
VcenterRestRep vcenter = VCenterUtils.getVCenter(dataCenter);
render(host, cluster, dataCenter, vcenter);
}
use of com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep in project coprhd-controller by CoprHD.
the class VMWareProvider method listDatacentersByVCenterAndCluster.
protected List<VcenterDataCenterRestRep> listDatacentersByVCenterAndCluster(AssetOptionsContext context, URI vcenterId, URI clusterId) {
ClusterRestRep clusterRestRep = api(context).clusters().get(clusterId);
RelatedResourceRep vcenterDatacenter = clusterRestRep.getVcenterDataCenter();
if (vcenterDatacenter == null) {
// return all datacenters for this datacenter
return api(context).vcenterDataCenters().getByVcenter(vcenterId, context.getTenant());
} else {
// return the datacenter this vipr cluster is already associated with in vcenter
VcenterDataCenterRestRep vcenterDataCenterRestRep = api(context).vcenterDataCenters().get(vcenterDatacenter.getId());
return Arrays.asList(vcenterDataCenterRestRep);
}
}
use of com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep 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;
}
Aggregations