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;
}
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;
}
Aggregations