Search in sources :

Example 1 with VcenterRestRep

use of com.emc.storageos.model.host.vcenter.VcenterRestRep in project coprhd-controller by CoprHD.

the class HostMapper method map.

public static VcenterRestRep map(Vcenter from) {
    if (from == null) {
        return null;
    }
    VcenterRestRep to = new VcenterRestRep();
    mapDiscoveredSystemObjectFields(from, to);
    to.setUsername(from.getUsername());
    to.setPortNumber(from.getPortNumber());
    to.setIpAddress(from.getIpAddress());
    to.setUseSsl(from.getUseSSL());
    to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, from.findVcenterTenant()));
    to.setOsVersion(from.getOsVersion());
    to.setCascadeTenancy(from.getCascadeTenancy());
    return to;
}
Also used : VcenterRestRep(com.emc.storageos.model.host.vcenter.VcenterRestRep)

Example 2 with VcenterRestRep

use of com.emc.storageos.model.host.vcenter.VcenterRestRep 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 3 with VcenterRestRep

use of com.emc.storageos.model.host.vcenter.VcenterRestRep 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 VcenterRestRep

use of com.emc.storageos.model.host.vcenter.VcenterRestRep 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)

Example 5 with VcenterRestRep

use of com.emc.storageos.model.host.vcenter.VcenterRestRep in project coprhd-controller by CoprHD.

the class VMWareProvider method listVcentersForCluster.

protected List<VcenterRestRep> listVcentersForCluster(AssetOptionsContext context, URI clusterId) {
    ClusterRestRep clusterRestRep = api(context).clusters().get(clusterId);
    RelatedResourceRep vcenterDatacenter = clusterRestRep.getVcenterDataCenter();
    if (vcenterDatacenter == null) {
        // return all vcenters
        return api(context).vcenters().getByTenant(context.getTenant(), REGISTERED.and(INCOMPATIBLE.not()));
    } else {
        // return the vcenter this vipr cluster is already associated with in vcenter
        RelatedResourceRep vcenterRelatedRestRep = api(context).vcenterDataCenters().get(vcenterDatacenter.getId()).getVcenter();
        VcenterRestRep vcenterRestRep = api(context).vcenters().get(vcenterRelatedRestRep.getId());
        return Arrays.asList(vcenterRestRep);
    }
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VcenterRestRep(com.emc.storageos.model.host.vcenter.VcenterRestRep)

Aggregations

VcenterRestRep (com.emc.storageos.model.host.vcenter.VcenterRestRep)6 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)4 VcenterDataCenterRestRep (com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep)3 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 HostRestRep (com.emc.storageos.model.host.HostRestRep)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 Asset (com.emc.sa.asset.annotation.Asset)1 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1