Search in sources :

Example 1 with V3Hosts

use of org.ovirt.engine.api.v3.types.V3Hosts in project ovirt-engine by oVirt.

the class V3DnsOutAdapter method adapt.

@Override
public V3DNS adapt(Dns from) {
    V3DNS to = new V3DNS();
    if (from.isSetSearchDomains()) {
        to.setSearchDomains(new V3Hosts());
        to.getSearchDomains().getHosts().addAll(adaptOut(from.getSearchDomains().getHosts()));
    }
    if (from.isSetServers()) {
        to.setServers(new V3Hosts());
        to.getServers().getHosts().addAll(adaptOut(from.getServers().getHosts()));
    }
    return to;
}
Also used : V3Hosts(org.ovirt.engine.api.v3.types.V3Hosts) V3DNS(org.ovirt.engine.api.v3.types.V3DNS)

Example 2 with V3Hosts

use of org.ovirt.engine.api.v3.types.V3Hosts in project ovirt-engine by oVirt.

the class V3HostsInAdapter method adapt.

@Override
public Hosts adapt(V3Hosts from) {
    Hosts to = new Hosts();
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetActive()) {
        to.setActive(from.getActive());
    }
    if (from.isSetSize()) {
        to.setSize(from.getSize());
    }
    if (from.isSetTotal()) {
        to.setTotal(from.getTotal());
    }
    to.getHosts().addAll(adaptIn(from.getHosts()));
    return to;
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) V3Hosts(org.ovirt.engine.api.v3.types.V3Hosts)

Example 3 with V3Hosts

use of org.ovirt.engine.api.v3.types.V3Hosts in project ovirt-engine by oVirt.

the class V3ApiSummaryOutAdapter method adapt.

@Override
public V3ApiSummary adapt(ApiSummary from) {
    V3ApiSummary to = new V3ApiSummary();
    if (from.isSetHosts()) {
        ApiSummaryItem fromHosts = from.getHosts();
        V3Hosts toHosts = new V3Hosts();
        if (fromHosts.isSetTotal()) {
            toHosts.setTotal(fromHosts.getTotal().longValue());
        }
        if (fromHosts.isSetActive()) {
            toHosts.setActive(fromHosts.getActive().longValue());
        }
        to.setHosts(toHosts);
    }
    if (from.isSetStorageDomains()) {
        ApiSummaryItem fromSds = from.getStorageDomains();
        V3StorageDomains toSds = new V3StorageDomains();
        if (fromSds.isSetTotal()) {
            toSds.setTotal(fromSds.getTotal().longValue());
        }
        if (fromSds.isSetActive()) {
            toSds.setActive(fromSds.getActive().longValue());
        }
        to.setStorageDomains(toSds);
    }
    if (from.isSetUsers()) {
        ApiSummaryItem fromUsers = from.getUsers();
        V3Users toUsers = new V3Users();
        if (fromUsers.isSetTotal()) {
            toUsers.setTotal(fromUsers.getTotal().longValue());
        }
        if (fromUsers.isSetActive()) {
            toUsers.setActive(fromUsers.getActive().longValue());
        }
        to.setUsers(toUsers);
    }
    if (from.isSetVms()) {
        ApiSummaryItem fromVms = from.getVms();
        V3VMs toVms = new V3VMs();
        if (fromVms.isSetTotal()) {
            toVms.setTotal(fromVms.getTotal().longValue());
        }
        if (fromVms.isSetActive()) {
            toVms.setActive(fromVms.getActive().longValue());
        }
        to.setVMs(toVms);
    }
    return to;
}
Also used : ApiSummaryItem(org.ovirt.engine.api.model.ApiSummaryItem) V3ApiSummary(org.ovirt.engine.api.v3.types.V3ApiSummary) V3Hosts(org.ovirt.engine.api.v3.types.V3Hosts) V3Users(org.ovirt.engine.api.v3.types.V3Users) V3VMs(org.ovirt.engine.api.v3.types.V3VMs) V3StorageDomains(org.ovirt.engine.api.v3.types.V3StorageDomains)

Example 4 with V3Hosts

use of org.ovirt.engine.api.v3.types.V3Hosts in project ovirt-engine by oVirt.

the class V3VmPlacementPolicyOutAdapter method adapt.

@Override
public V3VmPlacementPolicy adapt(VmPlacementPolicy from) {
    V3VmPlacementPolicy to = new V3VmPlacementPolicy();
    if (from.isSetAffinity()) {
        to.setAffinity(from.getAffinity().value());
    }
    if (from.isSetHosts()) {
        to.setHosts(new V3Hosts());
        to.getHosts().getHosts().addAll(adaptOut(from.getHosts().getHosts()));
        // V3 allowed specifying only one host, using the "host" element instead of "hosts":
        List<Host> hosts = from.getHosts().getHosts();
        if (hosts.size() == 1) {
            V3Host host = adaptOut(hosts.get(0));
            to.setHost(host);
        }
    }
    return to;
}
Also used : V3Host(org.ovirt.engine.api.v3.types.V3Host) V3Hosts(org.ovirt.engine.api.v3.types.V3Hosts) V3VmPlacementPolicy(org.ovirt.engine.api.v3.types.V3VmPlacementPolicy) V3Host(org.ovirt.engine.api.v3.types.V3Host) Host(org.ovirt.engine.api.model.Host)

Example 5 with V3Hosts

use of org.ovirt.engine.api.v3.types.V3Hosts in project ovirt-engine by oVirt.

the class V3HostsServer method list.

@GET
public V3Hosts list(@Context HttpHeaders headers, @Context UriInfo ui) {
    V3Hosts hosts = adaptList(getDelegate()::list);
    // In V3 the collection of hosts used to have the statistics inline, but only when the 'statistics' detail
    // was explicitly provided:
    Set<String> details = DetailHelper.getDetails(headers, ui);
    if (details.contains("statistics")) {
        hosts.getHosts().forEach(V3HostHelper::addStatistics);
    }
    return hosts;
}
Also used : V3Hosts(org.ovirt.engine.api.v3.types.V3Hosts) V3HostHelper(org.ovirt.engine.api.v3.helpers.V3HostHelper) GET(javax.ws.rs.GET)

Aggregations

V3Hosts (org.ovirt.engine.api.v3.types.V3Hosts)6 GET (javax.ws.rs.GET)1 ApiSummaryItem (org.ovirt.engine.api.model.ApiSummaryItem)1 Host (org.ovirt.engine.api.model.Host)1 Hosts (org.ovirt.engine.api.model.Hosts)1 V3HostHelper (org.ovirt.engine.api.v3.helpers.V3HostHelper)1 V3ApiSummary (org.ovirt.engine.api.v3.types.V3ApiSummary)1 V3DNS (org.ovirt.engine.api.v3.types.V3DNS)1 V3Host (org.ovirt.engine.api.v3.types.V3Host)1 V3StorageDomains (org.ovirt.engine.api.v3.types.V3StorageDomains)1 V3Users (org.ovirt.engine.api.v3.types.V3Users)1 V3VMs (org.ovirt.engine.api.v3.types.V3VMs)1 V3VmPlacementPolicy (org.ovirt.engine.api.v3.types.V3VmPlacementPolicy)1