Search in sources :

Example 1 with VmNicFilterParameterParameters

use of org.ovirt.engine.core.common.action.VmNicFilterParameterParameters in project ovirt-engine by oVirt.

the class BackendVmNicFilterParametersResource method add.

@Override
public Response add(NetworkFilterParameter parameter) {
    validateParameters(parameter, "value");
    VmNicFilterParameter vmNicFilterParameter = map(parameter);
    vmNicFilterParameter.setVmInterfaceId(nicId);
    return performCreate(ActionType.AddVmNicFilterParameter, new VmNicFilterParameterParameters(vmId, vmNicFilterParameter), new NicNetworkFilterParameterResolver(parameter.getName()));
}
Also used : VmNicFilterParameterParameters(org.ovirt.engine.core.common.action.VmNicFilterParameterParameters) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter)

Example 2 with VmNicFilterParameterParameters

use of org.ovirt.engine.core.common.action.VmNicFilterParameterParameters in project ovirt-engine by oVirt.

the class AddVmInterfaceCommand method saveNetworkFilterParameters.

protected void saveNetworkFilterParameters() {
    if (getParameters().getFilterParameters() != null) {
        for (VmNicFilterParameter parameter : getParameters().getFilterParameters()) {
            parameter.setVmInterfaceId(getInterface().getId());
            runInternalAction(ActionType.AddVmNicFilterParameter, new VmNicFilterParameterParameters(getParameters().getVmId(), parameter));
        }
    }
}
Also used : VmNicFilterParameterParameters(org.ovirt.engine.core.common.action.VmNicFilterParameterParameters) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter)

Example 3 with VmNicFilterParameterParameters

use of org.ovirt.engine.core.common.action.VmNicFilterParameterParameters in project ovirt-engine by oVirt.

the class UpdateVmInterfaceCommand method saveNetworkFilterParameters.

protected void saveNetworkFilterParameters() {
    List<VmNicFilterParameter> newParameters = getParameters().getFilterParameters();
    if (newParameters != null) {
        List<VmNicFilterParameter> savedParameters = runInternalQuery(QueryType.GetVmInterfaceFilterParametersByVmInterfaceId, new IdQueryParameters(getInterface().getId())).getReturnValue();
        for (VmNicFilterParameter parameter : newParameters) {
            boolean toUpdate = savedParameters.stream().anyMatch(saved -> Objects.equals(parameter.getId(), saved.getId()));
            if (toUpdate) {
                runInternalAction(ActionType.UpdateVmNicFilterParameter, new VmNicFilterParameterParameters(getParameters().getVmId(), parameter));
            } else {
                parameter.setVmInterfaceId(getInterface().getId());
                runInternalAction(ActionType.AddVmNicFilterParameter, new VmNicFilterParameterParameters(getParameters().getVmId(), parameter));
            }
        }
        for (VmNicFilterParameter parameter : savedParameters) {
            if (newParameters.stream().noneMatch(newParameter -> Objects.equals(parameter.getId(), newParameter.getId()))) {
                runInternalAction(ActionType.RemoveVmNicFilterParameter, new RemoveVmNicFilterParameterParameters(getParameters().getVmId(), parameter.getId()));
            }
        }
    }
}
Also used : VmNicFilterParameterParameters(org.ovirt.engine.core.common.action.VmNicFilterParameterParameters) RemoveVmNicFilterParameterParameters(org.ovirt.engine.core.common.action.RemoveVmNicFilterParameterParameters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) RemoveVmNicFilterParameterParameters(org.ovirt.engine.core.common.action.RemoveVmNicFilterParameterParameters) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter)

Aggregations

VmNicFilterParameterParameters (org.ovirt.engine.core.common.action.VmNicFilterParameterParameters)3 VmNicFilterParameter (org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter)3 RemoveVmNicFilterParameterParameters (org.ovirt.engine.core.common.action.RemoveVmNicFilterParameterParameters)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1