use of org.ovirt.engine.api.model.Hosts in project ovirt-engine by oVirt.
the class BackendVmResourceTest method testUpdateVmPolicySingleHostId.
@Test
public void testUpdateVmPolicySingleHostId() throws Exception {
setUpUdpateVm();
setUriInfo(setUpActionExpectations(ActionType.UpdateVm, VmManagementParametersBase.class, new String[] {}, new Object[] {}, true, true));
Vm model = getModel(0);
model.setPlacementPolicy(new VmPlacementPolicy());
model.getPlacementPolicy().setHosts(new Hosts());
model.getPlacementPolicy().getHosts().getHosts().add(new Host());
model.getPlacementPolicy().getHosts().getHosts().get(0).setId(GUIDS[1].toString());
verifyModel(resource.update(model), 0);
}
use of org.ovirt.engine.api.model.Hosts in project ovirt-engine by oVirt.
the class VmMapperTest method createPlacementPolicy.
private VmPlacementPolicy createPlacementPolicy(Guid... guids) {
VmPlacementPolicy placementPolicy = new VmPlacementPolicy();
Hosts hostsList = new Hosts();
for (Guid guid : guids) {
Host newHost = new Host();
newHost.setId(guid.toString());
hostsList.getHosts().add(newHost);
}
placementPolicy.setHosts(hostsList);
return placementPolicy;
}
use of org.ovirt.engine.api.model.Hosts 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;
}
use of org.ovirt.engine.api.model.Hosts in project ovirt-engine by oVirt.
the class AffinityGroupMapper method map.
@Mapping(from = org.ovirt.engine.core.common.scheduling.AffinityGroup.class, to = AffinityGroup.class)
public static AffinityGroup map(org.ovirt.engine.core.common.scheduling.AffinityGroup entity, AffinityGroup template) {
AffinityGroup model = template != null ? template : new AffinityGroup();
model.setId(entity.getId().toString());
model.setName(entity.getName());
model.setDescription(entity.getDescription());
// These two fields are maintained to keep the backwards compatibility
// with version 4 of the API and will be removed in future.
model.setPositive(entity.isVmAffinityEnabled() ? entity.getVmPolarityBooleanObject() : null);
model.setEnforcing(entity.isVmEnforcing());
AffinityRule hostsRule = model.getHostsRule();
if (hostsRule == null) {
hostsRule = new AffinityRule();
model.setHostsRule(hostsRule);
}
hostsRule.setEnabled(entity.isVdsAffinityEnabled());
hostsRule.setEnforcing(entity.isVdsEnforcing());
hostsRule.setPositive(entity.isVdsPositive());
AffinityRule vmsRule = model.getVmsRule();
if (vmsRule == null) {
vmsRule = new AffinityRule();
model.setVmsRule(vmsRule);
}
vmsRule.setEnabled(entity.isVmAffinityEnabled());
vmsRule.setEnforcing(entity.isVmEnforcing());
vmsRule.setPositive(entity.isVmPositive());
Cluster cluster = new Cluster();
cluster.setId(entity.getClusterId().toString());
model.setCluster(cluster);
Hosts hosts = model.getHosts();
if (hosts == null) {
hosts = new Hosts();
model.setHosts(hosts);
}
entity.getVdsIds().stream().map(id -> {
Host host = new Host();
host.setId(id.toString());
return host;
}).forEach(model.getHosts().getHosts()::add);
Vms vms = model.getVms();
if (vms == null) {
vms = new Vms();
model.setVms(vms);
}
entity.getVmIds().stream().map(id -> {
Vm vm = new Vm();
vm.setId(id.toString());
return vm;
}).forEach(model.getVms().getVms()::add);
return model;
}
use of org.ovirt.engine.api.model.Hosts in project ovirt-engine by oVirt.
the class AffinityGroupMapperTest method testHostIdsReplacement.
@Test
public void testHostIdsReplacement() throws Exception {
AffinityGroup model = new AffinityGroup();
Host host = new Host();
final Guid hostGuid = Guid.newGuid();
host.setId(hostGuid.toString());
model.setHosts(new Hosts());
model.getHosts().getHosts().add(host);
org.ovirt.engine.core.common.scheduling.AffinityGroup entity = new org.ovirt.engine.core.common.scheduling.AffinityGroup();
entity.getVdsIds().add(Guid.newGuid());
AffinityGroupMapper.map(model, entity);
assertEquals(1, entity.getVdsIds().size());
assertEquals(hostGuid, entity.getVdsIds().get(0));
}
Aggregations