Search in sources :

Example 6 with AffinityGroup

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

the class AffinityGroupMapperTest method testVmAffinityNegRestOutput.

@Test
public void testVmAffinityNegRestOutput() 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(true);
    entity.setVmAffinityRule(EntityAffinityRule.NEGATIVE);
    AffinityGroup model = new AffinityGroup();
    AffinityGroupMapper.map(entity, model);
    assertNotNull(model.getVmsRule());
    assertEquals(true, model.getVmsRule().isEnabled());
    assertEquals(false, model.getVmsRule().isPositive());
    assertEquals(true, model.getVmsRule().isEnforcing());
    assertEquals(false, model.isPositive());
    assertEquals(true, model.isEnforcing());
}
Also used : AffinityGroup(org.ovirt.engine.api.model.AffinityGroup) Test(org.junit.Test)

Example 7 with AffinityGroup

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

the class AffinityGroupMapperTest method testHostsRuleStructureNeg.

@Test
public void testHostsRuleStructureNeg() throws Exception {
    AffinityGroup model = new AffinityGroup();
    AffinityRule rule = new AffinityRule();
    rule.setEnabled(true);
    rule.setEnforcing(false);
    rule.setPositive(true);
    model.setHostsRule(rule);
    org.ovirt.engine.core.common.scheduling.AffinityGroup entity = new org.ovirt.engine.core.common.scheduling.AffinityGroup();
    AffinityGroupMapper.map(model, entity);
    assertEquals(EntityAffinityRule.POSITIVE, entity.getVdsAffinityRule());
    assertEquals(false, entity.isVdsEnforcing());
}
Also used : AffinityRule(org.ovirt.engine.api.model.AffinityRule) EntityAffinityRule(org.ovirt.engine.core.common.scheduling.EntityAffinityRule) AffinityGroup(org.ovirt.engine.api.model.AffinityGroup) Test(org.junit.Test)

Example 8 with AffinityGroup

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

the class AffinityGroupMapperTest method testHostAffinityRestOutput.

@Test
public void testHostAffinityRestOutput() 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(false);
    entity.setVdsAffinityRule(EntityAffinityRule.POSITIVE);
    AffinityGroup model = new AffinityGroup();
    AffinityGroupMapper.map(entity, model);
    assertNotNull(model.getHostsRule());
    assertEquals(true, model.getHostsRule().isEnabled());
    assertEquals(true, model.getHostsRule().isPositive());
    assertEquals(false, model.getHostsRule().isEnforcing());
}
Also used : AffinityGroup(org.ovirt.engine.api.model.AffinityGroup) Test(org.junit.Test)

Example 9 with AffinityGroup

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

the class AffinityGroupMapperTest method testVmsRuleNeg.

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

Example 10 with AffinityGroup

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

the class AffinityGroupMapperTest method testVmsRuleStructureWins.

@Test
public void testVmsRuleStructureWins() throws Exception {
    AffinityGroup model = new AffinityGroup();
    model.setEnforcing(false);
    model.setPositive(false);
    AffinityRule rule = new AffinityRule();
    rule.setEnforcing(true);
    rule.setPositive(true);
    rule.setEnabled(true);
    model.setVmsRule(rule);
    org.ovirt.engine.core.common.scheduling.AffinityGroup entity = new org.ovirt.engine.core.common.scheduling.AffinityGroup();
    AffinityGroupMapper.map(model, entity);
    assertEquals(EntityAffinityRule.POSITIVE, entity.getVmAffinityRule());
    assertEquals(true, entity.isVmEnforcing());
    assertEquals(true, entity.isVmAffinityEnabled());
}
Also used : AffinityRule(org.ovirt.engine.api.model.AffinityRule) EntityAffinityRule(org.ovirt.engine.core.common.scheduling.EntityAffinityRule) 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