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