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()));
}
}
}
}
Aggregations