Search in sources :

Example 1 with V3VmPlacementPolicy

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

the class V3VmPlacementPolicyInAdapter method adapt.

@Override
public VmPlacementPolicy adapt(V3VmPlacementPolicy from) {
    VmPlacementPolicy to = new VmPlacementPolicy();
    if (from.isSetAffinity()) {
        to.setAffinity(VmAffinity.fromValue(from.getAffinity()));
    }
    if (from.isSetHosts()) {
        to.setHosts(new Hosts());
        to.getHosts().getHosts().addAll(adaptIn(from.getHosts().getHosts()));
    }
    // V3 allowed specifying only one host, using "host" instead of "hosts":
    if (from.isSetHost() && !from.isSetHosts()) {
        Hosts hosts = new Hosts();
        Host host = adaptIn(from.getHost());
        hosts.getHosts().add(host);
        to.setHosts(hosts);
    }
    return to;
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) Host(org.ovirt.engine.api.model.Host) VmPlacementPolicy(org.ovirt.engine.api.model.VmPlacementPolicy) V3VmPlacementPolicy(org.ovirt.engine.api.v3.types.V3VmPlacementPolicy)

Example 2 with V3VmPlacementPolicy

use of org.ovirt.engine.api.v3.types.V3VmPlacementPolicy 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)

Aggregations

Host (org.ovirt.engine.api.model.Host)2 V3VmPlacementPolicy (org.ovirt.engine.api.v3.types.V3VmPlacementPolicy)2 Hosts (org.ovirt.engine.api.model.Hosts)1 VmPlacementPolicy (org.ovirt.engine.api.model.VmPlacementPolicy)1 V3Host (org.ovirt.engine.api.v3.types.V3Host)1 V3Hosts (org.ovirt.engine.api.v3.types.V3Hosts)1