Search in sources :

Example 6 with NetworkQoS

use of org.ovirt.engine.core.common.businessentities.network.NetworkQoS in project ovirt-engine by oVirt.

the class EditNetworkQoSModel method executeSave.

@Override
public void executeSave() {
    QosParametersBase<NetworkQoS> parameters = new QosParametersBase<>();
    parameters.setQos(networkQoS);
    Frontend.getInstance().runAction(ActionType.UpdateNetworkQoS, parameters, result -> {
        ActionReturnValue retVal = result.getReturnValue();
        boolean succeeded = false;
        if (retVal != null && retVal.getSucceeded()) {
            succeeded = true;
        }
        postSaveAction(succeeded);
    });
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) QosParametersBase(org.ovirt.engine.core.common.action.QosParametersBase) NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS)

Example 7 with NetworkQoS

use of org.ovirt.engine.core.common.businessentities.network.NetworkQoS in project ovirt-engine by oVirt.

the class RemoveNetworkQoSModel method onRemove.

public void onRemove() {
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    for (Object networkQoS : sourceListModel.getSelectedItems()) {
        QosParametersBase<NetworkQoS> parameter = new QosParametersBase<>();
        NetworkQoS tempQos = (NetworkQoS) networkQoS;
        parameter.setQos(tempQos);
        parameters.add(parameter);
    }
    Frontend.getInstance().runMultipleAction(ActionType.RemoveNetworkQoS, parameters);
    cancel();
}
Also used : QosParametersBase(org.ovirt.engine.core.common.action.QosParametersBase) NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 8 with NetworkQoS

use of org.ovirt.engine.core.common.businessentities.network.NetworkQoS in project ovirt-engine by oVirt.

the class RemoveNetworkQoSModel method setMessage.

private void setMessage() {
    ArrayList<QueryParametersBase> parameters = new ArrayList<>();
    ArrayList<QueryType> queryTypes = new ArrayList<>();
    for (Object networkQoS : sourceListModel.getSelectedItems()) {
        QueryParametersBase parameter = new IdQueryParameters(((NetworkQoS) networkQoS).getId());
        parameters.add(parameter);
        queryTypes.add(QueryType.GetVnicProfilesByNetworkQosId);
    }
    Frontend.getInstance().runMultipleQueries(queryTypes, parameters, result -> {
        ArrayList<VnicProfileView> vnicProfiles = new ArrayList<>();
        setHelpTag(HelpTag.remove_network_qos);
        // $NON-NLS-1$
        setHashName("remove_network_qos");
        for (QueryReturnValue returnValue : result.getReturnValues()) {
            vnicProfiles.addAll((ArrayList<VnicProfileView>) returnValue.getReturnValue());
        }
        if (vnicProfiles.isEmpty()) {
            ArrayList<String> list = new ArrayList<>();
            for (Object item : sourceListModel.getSelectedItems()) {
                NetworkQoS i = (NetworkQoS) item;
                list.add(i.getName());
            }
            setItems(list);
        } else {
            setMessage(ConstantsManager.getInstance().getMessages().removeNetworkQoSMessage(vnicProfiles.size()));
            ArrayList<String> list = new ArrayList<>();
            for (VnicProfileView item : vnicProfiles) {
                list.add(item.getName());
            }
            setItems(list);
        }
    });
}
Also used : ArrayList(java.util.ArrayList) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 9 with NetworkQoS

use of org.ovirt.engine.core.common.businessentities.network.NetworkQoS in project ovirt-engine by oVirt.

the class QosRangeValidatorTest method validNetworkQosMessages.

@Test
public void validNetworkQosMessages() {
    NetworkQoS qos = new NetworkQoS();
    qos.setInboundAverage(OUT_OF_RANGE);
    qos.setInboundPeak(OUT_OF_RANGE);
    qos.setInboundBurst(OUT_OF_RANGE);
    qos.setOutboundAverage(OUT_OF_RANGE);
    qos.setOutboundPeak(OUT_OF_RANGE);
    qos.setOutboundBurst(OUT_OF_RANGE);
    List<String> validationMessages = ValidationUtils.validateInputs(Arrays.asList(new Class<?>[] { Default.class }), qos);
    assertValidateMsgCount(validationMessages, "$range 0-100", 6);
    assertValidateMsgCount(validationMessages, EngineMessage.ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES.name(), 6);
}
Also used : NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS) Default(javax.validation.groups.Default) Test(org.junit.Test)

Example 10 with NetworkQoS

use of org.ovirt.engine.core.common.businessentities.network.NetworkQoS in project ovirt-engine by oVirt.

the class NetworkQosDaoTest method testRemoveNetworkQos.

/**
 * test remove
 */
@Test
public void testRemoveNetworkQos() {
    dao.remove(qosCId);
    NetworkQoS afterRemove = dao.get(qosCId);
    assertNull(afterRemove);
}
Also used : NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS) Test(org.junit.Test)

Aggregations

NetworkQoS (org.ovirt.engine.core.common.businessentities.network.NetworkQoS)21 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)3 QosParametersBase (org.ovirt.engine.core.common.action.QosParametersBase)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 List (java.util.List)1 Default (javax.validation.groups.Default)1 Before (org.junit.Before)1 DataCenter (org.ovirt.engine.api.model.DataCenter)1 Qos (org.ovirt.engine.api.model.Qos)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 Network (org.ovirt.engine.core.common.businessentities.network.Network)1 NetworkFilter (org.ovirt.engine.core.common.businessentities.network.NetworkFilter)1 VnicProfile (org.ovirt.engine.core.common.businessentities.network.VnicProfile)1 VnicProfileView (org.ovirt.engine.core.common.businessentities.network.VnicProfileView)1 QosQueryParameterBase (org.ovirt.engine.core.common.queries.QosQueryParameterBase)1 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)1