Added back end of 'show policy', removed unicode from 'show tunnel detail'
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
index 8a9ec48..32ec6c1 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
@@ -964,6 +964,7 @@
this.match = match;
this.priority = priority;
this.tunnelId = tid;
+ this.type = 0;
}
public String getPolicyId(){
return this.policyId;
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyInfo.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyInfo.java
new file mode 100644
index 0000000..6b98dcd
--- /dev/null
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyInfo.java
@@ -0,0 +1,35 @@
+package net.onrc.onos.apps.segmentrouting.web;
+
+import net.onrc.onos.core.matchaction.match.PacketMatch;
+
+/**
+ * Contains the policies info of the segment router that
+ * are exposed, through REST API
+ *
+ */
+
+public class SegmentRouterPolicyInfo {
+ private String policyId;
+ private int policyType;
+ private int priority;
+ private PacketMatch match;
+
+ public SegmentRouterPolicyInfo(String Id,int type, int ppriority,PacketMatch flowEntries){
+ this.policyId = Id;
+ this.policyType = type;
+ this.priority = ppriority;
+ this.match = flowEntries;
+ }
+ public String getPolicyId(){
+ return this.policyId;
+ }
+ public int getPolicyType(){
+ return this.policyType;
+ }
+ public int getPriority(){
+ return this.priority;
+ }
+ public PacketMatch getMatch(){
+ return this.match;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyResource.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyResource.java
index cbea58d..0931dd3 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyResource.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyResource.java
@@ -1,8 +1,14 @@
package net.onrc.onos.apps.segmentrouting.web;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
import net.onrc.onos.apps.segmentrouting.ISegmentRoutingService;
+import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.PolicyInfo;
+import net.onrc.onos.core.matchaction.match.PacketMatch;
import net.onrc.onos.core.packet.IPv4;
import net.onrc.onos.core.util.IPv4Net;
@@ -95,9 +101,23 @@
}
@Get("json")
- public String getPolicy() {
- String reply = "success";
+ public Object getPolicy() {
+ ISegmentRoutingService segmentRoutingService =
+ (ISegmentRoutingService) getContext().getAttributes().
+ get(ISegmentRoutingService.class.getCanonicalName());
+ List<SegmentRouterPolicyInfo> policyList = new ArrayList<SegmentRouterPolicyInfo>();
+ Collection<PolicyInfo> policies = segmentRoutingService.getPoclicyTable();
+ Iterator<PolicyInfo> piI = policies.iterator();
+ while(piI.hasNext()){
+ PolicyInfo policy = piI.next();
+ String policyId = policy.getPolicyId();
+ int priority = policy.getPriority();
+ int policyType = policy.getType();
+ PacketMatch flowEntries = policy.getMatch();
+ SegmentRouterPolicyInfo pInfo = new SegmentRouterPolicyInfo(policyId, policyType, priority, flowEntries);
+ policyList.add(pInfo);
+ }
log.debug("getPolicy with params");
- return reply;
+ return policyList;
}
}