ONOS-1930 : Tunnel and policy failover with multi-instances
- Prevents tunnel delete from removing groups used for default flows
- Removes SegmentRoutingManager reference from Tunnel and Policy class
- Adds some error checks such as duplicates tunnel IDs or duplicate polices
Change-Id: I0e7d5e2eff0aea6dad13137a872fee58e083b11c
diff --git a/src/main/java/org/onosproject/segmentrouting/web/PolicyWebResource.java b/src/main/java/org/onosproject/segmentrouting/web/PolicyWebResource.java
index 97e836a..384ff0f 100644
--- a/src/main/java/org/onosproject/segmentrouting/web/PolicyWebResource.java
+++ b/src/main/java/org/onosproject/segmentrouting/web/PolicyWebResource.java
@@ -20,9 +20,7 @@
import org.onosproject.rest.AbstractWebResource;
import org.onosproject.segmentrouting.Policy;
-import org.onosproject.segmentrouting.SegmentRoutingManager;
import org.onosproject.segmentrouting.SegmentRoutingService;
-import org.onosproject.segmentrouting.TunnelPolicy;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -59,10 +57,9 @@
ObjectNode policyJson = (ObjectNode) mapper.readTree(input);
SegmentRoutingService srService = get(SegmentRoutingService.class);
Policy policyInfo = POLICY_CODEC.decode(policyJson, this);
- if (policyInfo.type() == Policy.Type.TUNNEL_FLOW) {
- TunnelPolicy policy = new TunnelPolicy((SegmentRoutingManager) srService, (TunnelPolicy) policyInfo);
- srService.createPolicy(policy);
+ if (policyInfo.type() == Policy.Type.TUNNEL_FLOW) {
+ srService.createPolicy(policyInfo);
return Response.ok().build();
} else {
return Response.serverError().build();
@@ -78,6 +75,7 @@
Policy policyInfo = POLICY_CODEC.decode(policyJson, this);
// TODO: Check the result
srService.removePolicy(policyInfo);
+
return Response.ok().build();
}