Search in sources :

Example 11 with AffinityGroup

use of org.ovirt.engine.api.model.AffinityGroup in project ovirt-engine by oVirt.

the class AffinityGroupMapperTest method testVmIds.

@Test
public void testVmIds() throws Exception {
    AffinityGroup model = new AffinityGroup();
    Vm vm = new Vm();
    final Guid vmGuid = Guid.newGuid();
    vm.setId(vmGuid.toString());
    model.setVms(new Vms());
    model.getVms().getVms().add(vm);
    org.ovirt.engine.core.common.scheduling.AffinityGroup entity = new org.ovirt.engine.core.common.scheduling.AffinityGroup();
    AffinityGroupMapper.map(model, entity);
    assertEquals(vmGuid, entity.getVmIds().get(0));
}
Also used : Vm(org.ovirt.engine.api.model.Vm) Guid(org.ovirt.engine.core.compat.Guid) Vms(org.ovirt.engine.api.model.Vms) AffinityGroup(org.ovirt.engine.api.model.AffinityGroup) Test(org.junit.Test)

Example 12 with AffinityGroup

use of org.ovirt.engine.api.model.AffinityGroup in project ovirt-engine by oVirt.

the class AffinityGroupMapperTest method testVmsRule.

@Test
public void testVmsRule() throws Exception {
    AffinityGroup model = new AffinityGroup();
    model.setEnforcing(true);
    model.setPositive(false);
    org.ovirt.engine.core.common.scheduling.AffinityGroup entity = new org.ovirt.engine.core.common.scheduling.AffinityGroup();
    AffinityGroupMapper.map(model, entity);
    assertEquals(EntityAffinityRule.NEGATIVE, entity.getVmAffinityRule());
    assertEquals(true, entity.isVmEnforcing());
    assertEquals(true, entity.isVmAffinityEnabled());
}
Also used : AffinityGroup(org.ovirt.engine.api.model.AffinityGroup) Test(org.junit.Test)

Example 13 with AffinityGroup

use of org.ovirt.engine.api.model.AffinityGroup 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));
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) Host(org.ovirt.engine.api.model.Host) Guid(org.ovirt.engine.core.compat.Guid) AffinityGroup(org.ovirt.engine.api.model.AffinityGroup) Test(org.junit.Test)

Example 14 with AffinityGroup

use of org.ovirt.engine.api.model.AffinityGroup in project ovirt-engine by oVirt.

the class AffinityGroupMapperTest method testVmAffinityRestOutput.

@Test
public void testVmAffinityRestOutput() throws Exception {
    org.ovirt.engine.core.common.scheduling.AffinityGroup entity = new org.ovirt.engine.core.common.scheduling.AffinityGroup();
    entity.setId(Guid.Empty);
    entity.setClusterId(Guid.Empty);
    entity.setVmEnforcing(false);
    entity.setVmAffinityRule(EntityAffinityRule.POSITIVE);
    AffinityGroup model = new AffinityGroup();
    AffinityGroupMapper.map(entity, model);
    assertNotNull(model.getVmsRule());
    assertEquals(true, model.getVmsRule().isEnabled());
    assertEquals(true, model.getVmsRule().isPositive());
    assertEquals(false, model.getVmsRule().isEnforcing());
    assertEquals(true, model.isPositive());
    assertEquals(false, model.isEnforcing());
}
Also used : AffinityGroup(org.ovirt.engine.api.model.AffinityGroup) Test(org.junit.Test)

Example 15 with AffinityGroup

use of org.ovirt.engine.api.model.AffinityGroup in project ovirt-engine by oVirt.

the class AffinityGroupMapperTest method testHostAffinityNegRestOutput.

@Test
public void testHostAffinityNegRestOutput() throws Exception {
    org.ovirt.engine.core.common.scheduling.AffinityGroup entity = new org.ovirt.engine.core.common.scheduling.AffinityGroup();
    entity.setId(Guid.Empty);
    entity.setClusterId(Guid.Empty);
    entity.setVdsEnforcing(true);
    entity.setVdsAffinityRule(EntityAffinityRule.NEGATIVE);
    AffinityGroup model = new AffinityGroup();
    AffinityGroupMapper.map(entity, model);
    assertNotNull(model.getHostsRule());
    assertEquals(true, model.getHostsRule().isEnabled());
    assertEquals(false, model.getHostsRule().isPositive());
    assertEquals(true, model.getHostsRule().isEnforcing());
}
Also used : AffinityGroup(org.ovirt.engine.api.model.AffinityGroup) Test(org.junit.Test)

Aggregations

AffinityGroup (org.ovirt.engine.api.model.AffinityGroup)22 Test (org.junit.Test)19 AffinityRule (org.ovirt.engine.api.model.AffinityRule)7 EntityAffinityRule (org.ovirt.engine.core.common.scheduling.EntityAffinityRule)7 Guid (org.ovirt.engine.core.compat.Guid)6 Host (org.ovirt.engine.api.model.Host)3 Hosts (org.ovirt.engine.api.model.Hosts)3 Vm (org.ovirt.engine.api.model.Vm)3 Vms (org.ovirt.engine.api.model.Vms)3 Cluster (org.ovirt.engine.api.model.Cluster)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Response (javax.ws.rs.core.Response)1 GuidUtils (org.ovirt.engine.api.restapi.utils.GuidUtils)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 AffinityGroupCRUDParameters (org.ovirt.engine.core.common.scheduling.parameters.AffinityGroupCRUDParameters)1