Search in sources :

Example 11 with ClusterPolicy

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

the class ClusterPolicyDaoTest method testGetNegative.

@Test
public void testGetNegative() {
    ClusterPolicy result = dao.get(Guid.newGuid(), Collections.emptyMap());
    assertNull(result);
}
Also used : ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) Test(org.junit.Test)

Example 12 with ClusterPolicy

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

the class SchedulingManager method canSchedule.

public List<VDS> canSchedule(Cluster cluster, VM vm, List<Guid> vdsBlackList, List<Guid> vdsWhiteList, List<String> messages) {
    List<VDS> vdsList = vdsDao.getAllForClusterWithStatus(cluster.getId(), VDSStatus.Up);
    vdsList = removeBlacklistedHosts(vdsList, vdsBlackList);
    vdsList = keepOnlyWhitelistedHosts(vdsList, vdsWhiteList);
    refreshCachedPendingValues(vdsList);
    ClusterPolicy policy = policyMap.get(cluster.getClusterPolicyId());
    Map<String, String> parameters = createClusterPolicyParameters(cluster);
    vdsList = runFilters(policy.getFilters(), cluster, vdsList, vm, parameters, policy.getFilterPositionMap(), messages, noWaitingVmDelayer, false, null);
    return vdsList;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 13 with ClusterPolicy

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

the class BackendWeightsResource method list.

@Override
public Weights list() {
    ClusterPolicy clusterPolicy = getClusterPolicy();
    Weights weights = new Weights();
    if (clusterPolicy.getFunctions() != null) {
        for (Pair<Guid, Integer> weightPair : clusterPolicy.getFunctions()) {
            Weight weight = new Weight();
            weight.setId(weightPair.getFirst().toString());
            weight.setFactor(weightPair.getSecond());
            weights.getWeights().add(addLinks(map(clusterPolicy, weight)));
        }
    }
    return weights;
}
Also used : Weights(org.ovirt.engine.api.model.Weights) Guid(org.ovirt.engine.core.compat.Guid) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) Weight(org.ovirt.engine.api.model.Weight)

Example 14 with ClusterPolicy

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

the class SchedulingPolicyMapper method map.

@Mapping(from = Balance.class, to = ClusterPolicy.class)
public static ClusterPolicy map(Balance model, ClusterPolicy template) {
    ClusterPolicy entity = template != null ? template : new ClusterPolicy();
    if (model.isSetSchedulingPolicyUnit() && model.getSchedulingPolicyUnit().isSetId()) {
        Guid guid = GuidUtils.asGuid(model.getSchedulingPolicyUnit().getId());
        entity.setBalance(guid);
    }
    return entity;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 15 with ClusterPolicy

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

the class ClusterPolicyDaoTest method testSave.

@Test
public void testSave() {
    dao.save(dummyPolicy);
    ClusterPolicy result = dao.get(dummyPolicy.getId(), Collections.emptyMap());
    assertEquals(result, dummyPolicy);
    dao.remove(dummyPolicy.getId());
}
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