Search in sources :

Example 1 with VcenterDataCenterRestRep

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);
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) HostRestRep(com.emc.storageos.model.host.HostRestRep) VcenterRestRep(com.emc.storageos.model.host.vcenter.VcenterRestRep) VcenterDataCenterRestRep(com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep)

Example 2 with VcenterDataCenterRestRep

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));
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) VcenterDataCenterRestRep(com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep) URI(java.net.URI) HostInfo(models.datatable.HostDataTable.HostInfo)

Example 3 with VcenterDataCenterRestRep

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);
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) HostRestRep(com.emc.storageos.model.host.HostRestRep) VcenterRestRep(com.emc.storageos.model.host.vcenter.VcenterRestRep) VcenterDataCenterRestRep(com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep)

Example 4 with VcenterDataCenterRestRep

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);
    }
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VcenterDataCenterRestRep(com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep)

Example 5 with 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;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) HashMap(java.util.HashMap) VcenterRestRep(com.emc.storageos.model.host.vcenter.VcenterRestRep) VcenterDataCenterRestRep(com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep) URI(java.net.URI) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

VcenterDataCenterRestRep (com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep)10 HostRestRep (com.emc.storageos.model.host.HostRestRep)4 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)4 VcenterRestRep (com.emc.storageos.model.host.vcenter.VcenterRestRep)3 URI (java.net.URI)3 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 VcenterClusterParam (com.emc.storageos.model.compute.VcenterClusterParam)2 HostInfo (models.datatable.HostDataTable.HostInfo)2 Asset (com.emc.sa.asset.annotation.Asset)1 VcenterDataCenterUpdate (com.emc.storageos.model.host.vcenter.VcenterDataCenterUpdate)1 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1 HashMap (java.util.HashMap)1