Search in sources :

Example 16 with AffinityGroup

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

the class AffinityGroupMapperTest method testVmsRuleStructureDisabled.

@Test
public void testVmsRuleStructureDisabled() throws Exception {
    AffinityGroup model = new AffinityGroup();
    AffinityRule rule = new AffinityRule();
    rule.setEnforcing(true);
    rule.setPositive(false);
    rule.setEnabled(false);
    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.DISABLED, entity.getVmAffinityRule());
    assertEquals(true, entity.isVmEnforcing());
    assertEquals(false, 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)

Example 17 with AffinityGroup

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

the class AffinityGroupMapperTest method testHostIds.

@Test
public void testHostIds() 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();
    AffinityGroupMapper.map(model, entity);
    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 18 with AffinityGroup

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

the class AffinityGroupMapperTest method testVmAffinityDisabledRestOutput.

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

Example 19 with AffinityGroup

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

the class AffinityGroupMapperTest method testHostsRuleStructure.

@Test
public void testHostsRuleStructure() throws Exception {
    AffinityGroup model = new AffinityGroup();
    AffinityRule rule = new AffinityRule();
    rule.setEnabled(true);
    rule.setEnforcing(true);
    rule.setPositive(false);
    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.NEGATIVE, entity.getVdsAffinityRule());
    assertEquals(true, 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 20 with AffinityGroup

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

the class BackendAffinityGroupsResource method add.

@Override
public Response add(AffinityGroup affinityGroup) {
    org.ovirt.engine.core.common.scheduling.AffinityGroup backendEntity = getMapper(AffinityGroup.class, org.ovirt.engine.core.common.scheduling.AffinityGroup.class).map(affinityGroup, null);
    backendEntity.setClusterId(asGuid(clusterId));
    return performCreate(ActionType.AddAffinityGroup, new AffinityGroupCRUDParameters(null, backendEntity), new QueryIdResolver<Guid>(QueryType.GetAffinityGroupById, IdQueryParameters.class), true);
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AffinityGroupCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.AffinityGroupCRUDParameters) Guid(org.ovirt.engine.core.compat.Guid) AffinityGroup(org.ovirt.engine.api.model.AffinityGroup)

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