Search in sources :

Example 6 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class BackendFiltersResource method list.

@Override
public Filters list() {
    ClusterPolicy clusterPolicy = getClusterPolicy();
    Filters filters = new Filters();
    if (clusterPolicy.getFilters() != null) {
        for (Guid filterGuid : clusterPolicy.getFilters()) {
            Filter filter = new Filter();
            filter.setId(filterGuid.toString());
            filters.getFilters().add(addLinks(map(clusterPolicy, filter)));
        }
    }
    return filters;
}
Also used : Filters(org.ovirt.engine.api.model.Filters) Filter(org.ovirt.engine.api.model.Filter) Guid(org.ovirt.engine.core.compat.Guid) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 7 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class ClusterPolicyCRUDCommandTest method testCheckAddEditValidationsFailOnParameters.

@Test
public void testCheckAddEditValidationsFailOnParameters() {
    Guid clusterPolicyId = new Guid("e754440b-76a6-4099-8235-4565ab4b5521");
    ClusterPolicy clusterPolicy = new ClusterPolicy();
    clusterPolicy.setId(clusterPolicyId);
    HashMap<String, String> parameterMap = new HashMap<>();
    parameterMap.put("fail?", "sure, fail!");
    clusterPolicy.setParameterMap(parameterMap);
    ClusterPolicyCRUDCommand command = new ClusterPolicyCRUDCommand(new ClusterPolicyCRUDParameters(clusterPolicyId, clusterPolicy), null) {

        @Override
        protected void executeCommand() {
        }
    };
    command.schedulingManager = schedulingManager;
    assertFalse(command.checkAddEditValidations());
}
Also used : ClusterPolicyCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 8 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class InternalClusterPoliciesTest method testPolicyCreation.

@Test
public void testPolicyCreation() throws Exception {
    Guid uuid = Guid.newGuid();
    ClusterPolicy policy = InternalClusterPolicies.createBuilder(uuid.toString()).name("test-policy").isDefault().description("test-description").set(PolicyUnitParameter.CPU_OVERCOMMIT_DURATION_MINUTES, "5").set(PolicyUnitParameter.SPM_VM_GRACE, "1").setBalancer(EvenDistributionBalancePolicyUnit.class).addFilters(CpuLevelFilterPolicyUnit.class).addFilters(MemoryPolicyUnit.class).addFilters(PinToHostPolicyUnit.class).addFunction(1, HaReservationWeightPolicyUnit.class).addFunction(2, VmAffinityWeightPolicyUnit.class).getPolicy();
    assertNotNull(policy);
    assertEquals(uuid, policy.getId());
    assertEquals("test-policy", policy.getName());
    assertEquals("test-description", policy.getDescription());
    assertTrue(policy.isDefaultPolicy());
    assertTrue(policy.isLocked());
    assertNotNull(policy.getFilterPositionMap());
    assertEquals(-1L, (long) policy.getFilterPositionMap().get(getUnitId(CpuLevelFilterPolicyUnit.class)));
    assertEquals(0, (long) policy.getFilterPositionMap().get(getUnitId(MemoryPolicyUnit.class)));
    assertEquals(1L, (long) policy.getFilterPositionMap().get(getUnitId(PinToHostPolicyUnit.class)));
    assertNotNull(policy.getParameterMap());
    assertEquals(2, policy.getParameterMap().size());
    assertEquals("5", policy.getParameterMap().get(PolicyUnitParameter.CPU_OVERCOMMIT_DURATION_MINUTES.getDbName()));
    assertEquals("1", policy.getParameterMap().get(PolicyUnitParameter.SPM_VM_GRACE.getDbName()));
    assertNotNull(policy.getFunctions());
    assertNotNull(policy.getFilters());
    assertEquals(3, policy.getFilters().size());
    assertEquals(2, policy.getFunctions().size());
    Map<Guid, Integer> funcMap = new HashMap<>();
    for (Pair<Guid, Integer> pair : policy.getFunctions()) {
        funcMap.put(pair.getFirst(), pair.getSecond());
    }
    assertEquals(1, (long) funcMap.get(getUnitId(HaReservationWeightPolicyUnit.class)));
    assertEquals(2, (long) funcMap.get(getUnitId(VmAffinityWeightPolicyUnit.class)));
}
Also used : CpuLevelFilterPolicyUnit(org.ovirt.engine.core.bll.scheduling.policyunits.CpuLevelFilterPolicyUnit) PinToHostPolicyUnit(org.ovirt.engine.core.bll.scheduling.policyunits.PinToHostPolicyUnit) VmAffinityWeightPolicyUnit(org.ovirt.engine.core.bll.scheduling.policyunits.VmAffinityWeightPolicyUnit) HaReservationWeightPolicyUnit(org.ovirt.engine.core.bll.scheduling.policyunits.HaReservationWeightPolicyUnit) HashMap(java.util.HashMap) MemoryPolicyUnit(org.ovirt.engine.core.bll.scheduling.policyunits.MemoryPolicyUnit) Guid(org.ovirt.engine.core.compat.Guid) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) Test(org.junit.Test)

Example 9 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class ClusterPolicyDaoTest method testUpdate.

@Test
public void testUpdate() {
    dao.save(dummyPolicy);
    dummyPolicy.setName("Altered dummy policy");
    dao.update(dummyPolicy);
    ClusterPolicy result = dao.get(dummyPolicy.getId(), Collections.emptyMap());
    assertEquals(result, dummyPolicy);
}
Also used : ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) Test(org.junit.Test)

Example 10 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class ClusterPolicyDaoTest method testRemove.

@Test
public void testRemove() {
    dao.save(dummyPolicy);
    dao.remove(dummyPolicy.getId());
    ClusterPolicy result = dao.get(dummyPolicy.getId(), Collections.emptyMap());
    assertNull(result);
}
Also used : ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) Test(org.junit.Test)

Aggregations

ClusterPolicy (org.ovirt.engine.core.common.scheduling.ClusterPolicy)37 Guid (org.ovirt.engine.core.compat.Guid)20 HashMap (java.util.HashMap)10 LinkedHashMap (java.util.LinkedHashMap)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 ClusterPolicyCRUDParameters (org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters)7 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 PolicyUnit (org.ovirt.engine.core.common.scheduling.PolicyUnit)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Pair (org.ovirt.engine.core.common.utils.Pair)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)2 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 ValidationError (org.ovirt.engine.core.common.utils.customprop.ValidationError)2 Arrays (java.util.Arrays)1