Added enums for policyType, refactored 'show tunnel (details)'
diff --git a/cli/cli/desc/version200/core.py b/cli/cli/desc/version200/core.py
index 02397f7..0fe6c88 100755
--- a/cli/cli/desc/version200/core.py
+++ b/cli/cli/desc/version200/core.py
@@ -2392,8 +2392,8 @@
SHOW_TUNNEL_FORMAT = {
'show_tunnel' : {
'field-orderings' : {
- 'default' : [ 'Idx', 'tunnelId', 'policies','labelStack','tunnelPath'],
- 'details' : [ 'Idx', 'tunnelId', 'policies','labelStack', 'dpidGroup',],
+ 'default' : [ 'Idx', 'tunnelId', 'policies','tunnelPath','labelStack',],
+ 'details' : [ 'Idx', 'tunnelId', 'policies','tunnelPath','labelStack', 'dpidGroup',],
},
'fields': {
'tunnelId' : { 'verbose-name' : 'Id',
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 53eb67f..11eab2f 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
@@ -1062,18 +1062,24 @@
// Policy routing classes and functions
// ************************************
+ /**
+ * Enums for policy type
+ *
+ */
+ public enum PolicyType{
+ TUNNEL_FLOW,
+ LOADBALANCE,
+ AVOID,
+ DENY
+ }
public class PolicyInfo {
-
- public final int TYPE_EXPLICIT = 1;
- public final int TYPE_AVOID = 2;
-
private String policyId;
private PacketMatch match;
private int priority;
private String tunnelId;
- private int type;
+ private PolicyType type;
- public PolicyInfo(String pid, int type, PacketMatch match, int priority,
+ public PolicyInfo(String pid, PolicyType type, PacketMatch match, int priority,
String tid) {
this.policyId = pid;
this.match = match;
@@ -1088,7 +1094,7 @@
this.match = match;
this.priority = priority;
this.tunnelId = tid;
- this.type = 0;
+ this.type = PolicyType.TUNNEL_FLOW;
}
public String getPolicyId(){
return this.policyId;
@@ -1102,7 +1108,7 @@
public String getTunnelId(){
return this.tunnelId;
}
- public int getType(){
+ public PolicyType getType(){
return this.type;
}
}
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
index 3a27267..7129a86 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyInfo.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyInfo.java
@@ -10,12 +10,12 @@
public class SegmentRouterPolicyInfo {
private String policyId;
- private int policyType;
+ private String policyType;
private int priority;
private String tunnelId = null;
private PacketMatch match;
- public SegmentRouterPolicyInfo(String Id,int type,String tunnelUsed, int ppriority,PacketMatch flowEntries){
+ public SegmentRouterPolicyInfo(String Id,String type,String tunnelUsed, int ppriority,PacketMatch flowEntries){
this.policyId = Id;
this.policyType = type;
this.tunnelId =tunnelUsed;
@@ -25,7 +25,7 @@
public String getPolicyId(){
return this.policyId;
}
- public int getPolicyType(){
+ public String getPolicyType(){
return this.policyType;
}
public String getTunnelId(){
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 8106173..a1a8a71 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
@@ -118,7 +118,7 @@
String policyId = policy.getPolicyId();
String tunnelId = policy.getTunnelId();
int priority = policy.getPriority();
- int policyType = policy.getType();
+ String policyType = policy.getType().name();
PacketMatch flowEntries = policy.getMatch();
SegmentRouterPolicyInfo pInfo = new SegmentRouterPolicyInfo(policyId, policyType, tunnelId,
priority, flowEntries);