Search in sources :

Example 1 with RemoveVmNicFilterParameterParameters

use of org.ovirt.engine.core.common.action.RemoveVmNicFilterParameterParameters 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

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