Changing from list of dpids to labels and accordingly show tunnel output
diff --git a/cli/cli/c_actions.py b/cli/cli/c_actions.py
index ce1c9cb..06ea46a 100755
--- a/cli/cli/c_actions.py
+++ b/cli/cli/c_actions.py
@@ -100,7 +100,7 @@
url_str = "http://%s/rest/v1/tunnel/" % (sdnsh.controller)
obj_data = {}
obj_data['tunnel_id']=tunnel_id
- obj_data['tunnel_path']=entries
+ obj_data['label_path']=entries
data = sdnsh.store.rest_post_request(url_str,obj_data)
# LOOK! successful stuff should be returned in json too.
if data != "success":
@@ -2141,16 +2141,16 @@
labelStack = str(tunnel.get('labelStack'))
labelStack = remove_unicodes(labelStack)
tunnelId = tunnel.get('tunnelId')
- nodes = ''
- for node in tunnel.get("nodes"):
- nodes += (node.get('value') + ',')
- if nodes != '':
- nodes = nodes[:-1]
+ #nodes = ''
+ #for node in tunnel.get("nodes"):
+ # nodes += (node.get('value') + ',')
+ #if nodes != '':
+ # nodes = nodes[:-1]
#portNo = portData.get("portNumber")
#subnetIp = port.get("subnetIp")
combResult.append({
'tunnelId' : tunnelId,
- 'nodes' : nodes,
+ #'nodes' : nodes,
'labelStack' :labelStack,
})
entries = combResult
diff --git a/cli/cli/command.py b/cli/cli/command.py
index f585453..b1fa227 100755
--- a/cli/cli/command.py
+++ b/cli/cli/command.py
@@ -3957,6 +3957,13 @@
})
add_typedef({
+ 'name' : 'label',
+ 'help-name' : 'Segment Label',
+ 'base-type' : 'integer',
+ 'validation' : 'validate-integer',
+ })
+
+ add_typedef({
'name' : 'dpid',
'help-name' : 'switch id (8-hex bytes)',
'base-type' : 'string',
diff --git a/cli/cli/desc/version200/core.py b/cli/cli/desc/version200/core.py
index 095d47d..4100f7c 100755
--- a/cli/cli/desc/version200/core.py
+++ b/cli/cli/desc/version200/core.py
@@ -2414,8 +2414,8 @@
SHOW_TUNNEL_FORMAT = {
'show_tunnel' : {
'field-orderings' : {
- 'default' : [ 'Idx', 'tunnelId', 'nodes', 'labelStack', 'Group/DIPD',],
- 'scoped' : [ 'Idx', 'tunnelId', 'nodes', 'labelStack', 'Group/DIPD',],
+ 'default' : [ 'Idx', 'tunnelId', 'labelStack', 'Group/DIPD',],
+ 'scoped' : [ 'Idx', 'tunnelId', 'labelStack', 'Group/DIPD',],
},
},
}
diff --git a/cli/cli/desc/version200/switch.py b/cli/cli/desc/version200/switch.py
index 70ff54b..b7cff6c 100755
--- a/cli/cli/desc/version200/switch.py
+++ b/cli/cli/desc/version200/switch.py
@@ -55,15 +55,14 @@
def tunnel_node_completion(prefix, completions):
print "tunnel_node_completion:",prefix,completions
query_url = "http://127.0.0.1:8000/rest/v1/switches"
- #print query_url
result = command.sdnsh.store.rest_simple_request(query_url)
entries = json.loads(result)
for entry in entries:
- if entry['dpid'].startswith(prefix):
- completions[entry['dpid']+' '] = entry['dpid']
+ if entry['stringAttributes']['nodeSid'].startswith(prefix):
+ completions[entry['stringAttributes']['nodeSid']+' '] = entry['stringAttributes']['nodeSid']
return
-command.add_completion('tunnel-node-completion', tunnel_node_completion,
+command.add_completion('tunnel-node-label-completion', tunnel_node_completion,
{'kwargs': { 'prefix' : '$text',
'completions' : '$completions',
}})
@@ -80,11 +79,11 @@
'args' : (
{
'field' : 'node-value',
- 'completion' : 'tunnel-node-completion',
- 'type' : 'dpid',
- 'other' : 'switches|dpid',
+ 'completion' : 'tunnel-node-label-completion',
+ 'type' : 'label',
+ 'other' : 'switches|label',
# 'data-handler' : 'alias-to-value',
- 'help-name' : 'switch dpid or switch alias',
+ 'help-name' : 'Segment label',
'action' : (
{
'proc' : 'create-tunnel',
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/ISegmentRoutingService.java b/src/main/java/net/onrc/onos/apps/segmentrouting/ISegmentRoutingService.java
index e2efa42..9a887ae 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/ISegmentRoutingService.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/ISegmentRoutingService.java
@@ -6,7 +6,6 @@
import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.util.MACAddress;
import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.TunnelInfo;
-import net.onrc.onos.core.util.Dpid;
import net.onrc.onos.core.util.IPv4Net;
/**
@@ -19,11 +18,11 @@
* Create a tunnel for policy routing.
*
* @param tunnelId ID for the tunnel
- * @param Ids Node IDs for the tunnel
+ * @param labelIds Node label IDs for the tunnel
*
* @return "true/false" depending tunnel creation status
*/
- public boolean createTunnel(String tunnelId, List<Dpid> Ids);
+ public boolean createTunnel(String tunnelId, List<Integer> labelIds);
/**
* Remove a Segment Routing tunnel given a tunnel Id.
@@ -36,7 +35,7 @@
/**
* Create a policy for policy based segment routing
- *
+ *
* @param pid Unique Policy Identifier
* @param srcIP Source IP address in CIDR format
* @param dstIP Destination IP address in CIDR format
@@ -65,6 +64,6 @@
* info about tunnels
* @return Collection<TunnelInfo>
*/
-
+
public Collection<TunnelInfo> getTunnelTable();
}
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 537a894..c29fc65 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
@@ -5,6 +5,7 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -967,19 +968,20 @@
public class TunnelInfo {
private String tunnelId;
- private List<Dpid> dpids;
+ private List<Integer> labelIds;
private List<TunnelRouteInfo> routes;
- public TunnelInfo(String tid, List<Dpid> dpids, List<TunnelRouteInfo> routes) {
+ public TunnelInfo(String tid, List<Integer> labelIds, List<TunnelRouteInfo> routes) {
this.tunnelId = tid;
- this.dpids = dpids;
+ this.labelIds = labelIds;
this.routes = routes;
}
public String getTunnelId(){
return this.tunnelId;
}
- public List<Dpid> getDpids(){
- return this.dpids;
+
+ public List<Integer> getLabelids() {
+ return this.labelIds;
}
public List<TunnelRouteInfo> getRoutes(){
return this.routes;
@@ -1041,9 +1043,9 @@
* @param tid tunnel ID
* @return List of DPID
*/
- public List<Dpid> getTunnelInfo(String tid) {
+ public List<Integer> getTunnelInfo(String tid) {
TunnelInfo tunnelInfo = tunnelTable.get(tid);
- return tunnelInfo.dpids;
+ return tunnelInfo.labelIds;
}
@@ -1076,16 +1078,16 @@
* @param tunnelId Node IDs for the tunnel
* @param Ids tunnel ID
*/
- public boolean createTunnel(String tunnelId, List<Dpid> dpids) {
+ public boolean createTunnel(String tunnelId, List<Integer> labelIds) {
- if (dpids.isEmpty() || dpids.size() < 2) {
+ if (labelIds.isEmpty() || labelIds.size() < 2) {
log.debug("Wrong tunnel information");
return false;
}
List<String> Ids = new ArrayList<String>();
- for (Dpid dpid: dpids) {
- Ids.add(getMplsLabel(dpid.toString()));
+ for (Integer label : labelIds) {
+ Ids.add(label.toString());
}
List<TunnelRouteInfo> stitchingRule = getStitchingRule(Ids);
@@ -1115,7 +1117,7 @@
}
//tunnelGroupMap.put(tunnelId, switchGroupPair);
- TunnelInfo tunnelInfo = new TunnelInfo(tunnelId, dpids, stitchingRule);
+ TunnelInfo tunnelInfo = new TunnelInfo(tunnelId, labelIds, stitchingRule);
tunnelTable.put(tunnelId, tunnelInfo);
return true;
@@ -1685,14 +1687,14 @@
private void runTest() {
if (testMode == POLICY_ADD1) {
- String[] routeArray = {"101", "105", "110"};
- List<Dpid> routeList = new ArrayList<Dpid>();
+ Integer[] routeArray = {101, 105, 110};
+ /*List<Dpid> routeList = new ArrayList<Dpid>();
for (int i = 0; i < routeArray.length; i++) {
Dpid dpid = getSwitchFromNodeId(routeArray[i]).getDpid();
routeList.add(dpid);
- }
+ }*/
- if (createTunnel("1", routeList)) {
+ if (createTunnel("1", Arrays.asList(routeArray))) {
IPv4Net srcIp = new IPv4Net("10.0.1.1/24");
IPv4Net dstIp = new IPv4Net("10.1.2.1/24");
@@ -1709,15 +1711,9 @@
}
}
else if (testMode == POLICY_ADD2) {
- String[] routeArray = {"101", "102", "103", "104", "105", "108",
- "110"};
- List<Dpid> routeList = new ArrayList<Dpid>();
- for (int i = 0; i < routeArray.length; i++) {
- Dpid dpid = getSwitchFromNodeId(routeArray[i]).getDpid();
- routeList.add(dpid);
- }
+ Integer[] routeArray = {101, 102, 103, 104, 105, 108, 110};
- if (createTunnel("2", routeList)) {
+ if (createTunnel("2", Arrays.asList(routeArray))) {
IPv4Net srcIp = new IPv4Net("10.0.1.1/24");
IPv4Net dstIp = new IPv4Net("10.1.2.1/24");
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelInfo.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelInfo.java
index 785dde7..cd6f9be 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelInfo.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelInfo.java
@@ -2,30 +2,28 @@
import java.util.List;
-import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.TunnelRouteInfo;
-import net.onrc.onos.core.util.Dpid;
-
/**
* This class contains tunnel info of ONOS Segement Routing App
* Used for rest API
*/
public class SegmentRouterTunnelInfo {
private String tunnelId;
- private List<Dpid> nodes;
+ // private List<Dpid> nodes;
private List<List<String>> labelStack;
-
- public SegmentRouterTunnelInfo (String tId, List<Dpid> dpids,
+
+ public SegmentRouterTunnelInfo(String tId, /*List<Dpid> dpids,*/
List<List<String>> tunnelRoutes){
this.tunnelId = tId;
- this.nodes = dpids;
+ // this.nodes = dpids;
this.labelStack = tunnelRoutes;
}
public String getTunnelId (){
return this.tunnelId;
}
- public List<Dpid> getnodes (){
+
+ /*public List<Dpid> getnodes (){
return this.nodes;
- }
+ }*/
public List<List<String>> getLabelStack (){
return this.labelStack;
}
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelRESTParams.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelRESTParams.java
index 4248b24..6eedfb1 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelRESTParams.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelRESTParams.java
@@ -4,11 +4,11 @@
public class SegmentRouterTunnelRESTParams {
private String tunnel_id;
- private List<String> tunnel_path;
+ private List<Integer> label_path;
public SegmentRouterTunnelRESTParams() {
this.tunnel_id = null;
- this.tunnel_path = null;
+ this.label_path = null;
}
public void setTunnel_id(String tunnel_id) {
@@ -19,11 +19,11 @@
return this.tunnel_id;
}
- public void setTunnel_path(List<String> tunnel_path) {
- this.tunnel_path = tunnel_path;
+ public void setLabel_path(List<Integer> label_path) {
+ this.label_path = label_path;
}
- public List<String> getTunnel_path() {
- return this.tunnel_path;
+ public List<Integer> getLabel_path() {
+ return this.label_path;
}
}
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelResource.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelResource.java
index 3c19a21..bf3a084 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelResource.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelResource.java
@@ -2,10 +2,14 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import net.onrc.onos.apps.segmentrouting.ISegmentRoutingService;
-import net.onrc.onos.core.util.Dpid;
+import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.TunnelInfo;
+import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.TunnelRouteInfo;
import org.codehaus.jackson.map.ObjectMapper;
import org.restlet.resource.Delete;
@@ -14,17 +18,6 @@
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import net.onrc.onos.apps.segmentrouting.ISegmentRoutingService;
-import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager;
-import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.TunnelInfo;
-import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.TunnelRouteInfo;
/**
* Base class for return router statistics
*
@@ -49,14 +42,10 @@
log.error("Exception occurred parsing inbound JSON", ex);
return "fail";
}
- log.debug("createTunnel with tunnelId {} tunnelPath{}",
- createParams.getTunnel_id(), createParams.getTunnel_path());
- List<Dpid> tunnelDpids = new ArrayList<Dpid>();
- for (String dpid : createParams.getTunnel_path()) {
- tunnelDpids.add(new Dpid(dpid));
- }
+ log.debug("createTunnel with tunnelId {} Label Path{}",
+ createParams.getTunnel_id(), createParams.getLabel_path());
boolean result = segmentRoutingService.createTunnel(createParams.getTunnel_id(),
- tunnelDpids);
+ createParams.getLabel_path());
return (result == true) ? "success" : "fail";
}
@@ -99,10 +88,10 @@
labelStack.add(label.getRoute());
}
SegmentRouterTunnelInfo info = new SegmentRouterTunnelInfo(tunnelInfo.getTunnelId(),
- tunnelInfo.getDpids(), labelStack );
+ /*tunnelInfo.getDpids(),*/labelStack);
infoList.add(info);
//TODO Add Group/DPID
-
+
}
log.debug("getTunnel with params");
Map <String,List<SegmentRouterTunnelInfo>>result = new HashMap<String,List<SegmentRouterTunnelInfo>>();