alshabib
Committed by Gerrit Code Review

Adding support to remove a subscriber.

And fixing an issue where build on a flowrule could not be
called repeatedly.

Change-Id: I85773ac7a3fb4f2970b63599d1eafbfc8b3c5879
......@@ -364,6 +364,7 @@ public class DefaultFlowRule implements FlowRule {
@Override
public FlowRule build() {
FlowId localFlowId;
checkArgument((flowId != null) ^ (appId != null), "Either an application" +
" id or a cookie must be supplied");
checkNotNull(selector, "Traffic selector cannot be null");
......@@ -377,11 +378,13 @@ public class DefaultFlowRule implements FlowRule {
// Computing a flow ID based on appId takes precedence over setting
// the flow ID directly
if (appId != null) {
flowId = computeFlowId(appId);
localFlowId = computeFlowId(appId);
} else {
localFlowId = flowId;
}
return new DefaultFlowRule(deviceId, selector, treatment, priority,
flowId, permanent, timeout, tableId);
localFlowId, permanent, timeout, tableId);
}
private FlowId computeFlowId(ApplicationId appId) {
......
......@@ -38,7 +38,6 @@ import org.onosproject.net.driver.AbstractHandlerBehaviour;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.FlowEntry;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.FlowRuleOperations;
import org.onosproject.net.flow.FlowRuleOperationsContext;
......@@ -579,12 +578,7 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner {
builder.add(inner.build()).add(outer.build());
break;
case REMOVE:
Iterable<FlowEntry> flows = flowRuleService.getFlowEntries(deviceId);
for (FlowEntry fe : flows) {
if (fe.equals(inner.build()) || fe.equals(outer.build())) {
builder.remove(fe);
}
}
builder.remove(inner.build()).remove(outer.build());
break;
case ADD_TO_EXISTING:
break;
......