Search in sources :

Example 1 with ClusterPolicyCRUDParameters

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

the class BackendBalanceResource method remove.

@Override
public Response remove() {
    ClusterPolicy entity = parent.getClusterPolicy();
    updateEntityForRemove(entity, guid);
    return performAction(ActionType.EditClusterPolicy, new ClusterPolicyCRUDParameters(entity.getId(), entity));
}
Also used : ClusterPolicyCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 2 with ClusterPolicyCRUDParameters

use of org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters 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 3 with ClusterPolicyCRUDParameters

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

the class BackendSchedulingPolicyResource method remove.

@Override
public Response remove() {
    get();
    Response performAction = null;
    try {
        performAction = performAction(ActionType.RemoveClusterPolicy, new ClusterPolicyCRUDParameters(asGuid(id), new QueryIdResolver<Guid>(QueryType.GetClusterPolicyById, IdQueryParameters.class).lookupEntity(asGuid(id))));
    } catch (BackendFailureException e) {
        log.error("Failed performing action", e);
    }
    return performAction;
}
Also used : Response(javax.ws.rs.core.Response) ClusterPolicyCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters)

Example 4 with ClusterPolicyCRUDParameters

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

the class ClusterPolicyListModel method onRemove.

public void onRemove() {
    for (Object item : getSelectedItems()) {
        ClusterPolicy clusterPolicy = (ClusterPolicy) item;
        Frontend.getInstance().runAction(ActionType.RemoveClusterPolicy, new ClusterPolicyCRUDParameters(clusterPolicy.getId(), clusterPolicy));
    }
    setWindow(null);
    // Execute search to keep list updated.
    getSearchCommand().execute();
}
Also used : ClusterPolicyCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 5 with ClusterPolicyCRUDParameters

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

the class NewClusterPolicyModel method save.

private void save() {
    if (getProgress() != null) {
        return;
    }
    if (!validate()) {
        return;
    }
    startProgress();
    ClusterPolicy policy = new ClusterPolicy();
    policy.setId(clusterPolicy.getId());
    policy.setName(getName().getEntity());
    policy.setDescription(getDescription().getEntity());
    ArrayList<Guid> keys = new ArrayList<>();
    for (PolicyUnit clusterPolicy : getUsedFilters()) {
        keys.add(clusterPolicy.getId());
    }
    policy.setFilters(keys);
    policy.setFilterPositionMap(getFilterPositionMap());
    ArrayList<Pair<Guid, Integer>> pairs = new ArrayList<>();
    for (Pair<PolicyUnit, Integer> pair : getUsedFunctions()) {
        pairs.add(new Pair<>(pair.getFirst().getId(), pair.getSecond()));
    }
    policy.setFunctions(pairs);
    policy.setBalance(getLoadBalanceList().getSelectedItem().getId());
    policy.setParameterMap(KeyValueModel.convertProperties(getCustomPropertySheet().serialize()));
    Frontend.getInstance().runAction(commandType == CommandType.Edit ? ActionType.EditClusterPolicy : ActionType.AddClusterPolicy, new ClusterPolicyCRUDParameters(policy.getId(), policy), result -> {
        NewClusterPolicyModel.this.stopProgress();
        if (result.getReturnValue().getSucceeded()) {
            NewClusterPolicyModel.this.cancel();
        }
    });
}
Also used : ClusterPolicyCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) Pair(org.ovirt.engine.core.common.utils.Pair)

Aggregations

ClusterPolicyCRUDParameters (org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters)8 ClusterPolicy (org.ovirt.engine.core.common.scheduling.ClusterPolicy)7 Guid (org.ovirt.engine.core.compat.Guid)3 Test (org.junit.Test)2 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Response (javax.ws.rs.core.Response)1 PolicyUnit (org.ovirt.engine.core.common.scheduling.PolicyUnit)1 Pair (org.ovirt.engine.core.common.utils.Pair)1