Added backend for 'show tunnel' and some minnor fixes
diff --git a/cli/cli/c_actions.py b/cli/cli/c_actions.py
index 9c6ee2e..92bea37 100755
--- a/cli/cli/c_actions.py
+++ b/cli/cli/c_actions.py
@@ -43,7 +43,7 @@
 #
 # ACTION PROCS
 #Format actions for stats per table
-def format_actions(actions):
+def remove_unicodes(actions):
    
     if actions:
         #TODO: Check:- Why I have to remove last two character from string
@@ -2134,20 +2134,26 @@
 
 
     if 'showtunnel' in data  and data['showtunnel'] == 'tunnel':
-        #raise error.ArgumentValidationError('\n\n\n %s' % (data))
+        #raise error.ArgumentValidationError('\n\n\n %s' % (entries))
         combResult = []
-        '''portList = entries
-        for port in portList:
-            portData = port.get("port")
-            name = portData.get("stringAttributes").get('name')
-            portNo = portData.get("portNumber")
-            subnetIp = port.get("subnetIp")
+        tunnelList = entries
+        for tunnel in tunnelList:
+            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]
+            #portNo = portData.get("portNumber")
+            #subnetIp = port.get("subnetIp")
             combResult.append({
-                               'name'            :name,
-                               'portNo'           : portNo,
-                               'subnetIp'         : subnetIp,
+                               'tunnelId'         : tunnelId,
+                               'nodes'           : nodes,
+                               'labelStack'      :labelStack,
                                })
-        entries = combResult'''
+        entries = combResult
 
     if 'showpolicy' in data  and data['showpolicy'] == 'policy':
         #raise error.ArgumentValidationError('\n\n\n %s' % (data))
@@ -2176,7 +2182,7 @@
                     #raise error.ArgumentValidationError('\n\n\n %s' % json.tool(entries))
                 instructions = ipTableEntry['instructions']
                 actions = str(instructions[0]) if instructions[0] else None
-                actions = format_actions(actions)
+                actions = remove_unicodes(actions)
                 combResult.append({
                        'switch'        : ipTableEntry['switch'],
                        'byteCount'     : ipTableEntry['byteCount'],
@@ -2200,7 +2206,7 @@
                 instructions = ipTableEntry['instructions']
                 #raise error.ArgumentValidationError('\n\n\n %s' %len(actions))
                 actions = str(instructions[0])if instructions[0] else None
-                actions = format_actions(actions)
+                actions = remove_unicodes(actions)
                 combResult.append({
                        'switch'        : ipTableEntry['switch'],
                        'byteCount'     : ipTableEntry['byteCount'],
@@ -2243,7 +2249,7 @@
                     mplsBos = match.get('mplsBos') if match.get('mplsBos') else '*'
                 instructions = ipTableEntry['instructions']
                 actions = str(instructions[0])if instructions[0] else None
-                actions = format_actions(actions)
+                actions = remove_unicodes(actions)
                 combResult.append({
                        'switch'        : ipTableEntry['switch'],
                        'byteCount'     : ipTableEntry['byteCount'],
diff --git a/cli/cli/desc/version200/core.py b/cli/cli/desc/version200/core.py
index 385476d..095d47d 100755
--- a/cli/cli/desc/version200/core.py
+++ b/cli/cli/desc/version200/core.py
@@ -2414,12 +2414,13 @@
 SHOW_TUNNEL_FORMAT = {
     'show_tunnel' : {
         'field-orderings' : {
-            'default' : [ 'Idx', 'tunnelId', 'nodes', 'LabelStack', 'Group//DIPD',]
+            'default' : [ 'Idx', 'tunnelId', 'nodes', 'labelStack', 'Group/DIPD',],
+            'scoped' : [ 'Idx', 'tunnelId', 'nodes', 'labelStack', 'Group/DIPD',],
             },
         },
 }
 
-SHOW_TUNNEL_FORMAT = {
+SHOW_POLICYL_FORMAT = {
     'show_policy' : {
         'field-orderings' : {
             'default' : [ 'Idx', 'policyId', 'tunnelId', 'flowEntries']
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 d544fc5..e2efa42 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/ISegmentRoutingService.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/ISegmentRoutingService.java
@@ -1,9 +1,11 @@
 package net.onrc.onos.apps.segmentrouting;
 
+import java.util.Collection;
 import java.util.List;
 
 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;
 
@@ -58,4 +60,11 @@
      * @return "true/false" depending tunnel deletion status
      */
     public boolean removePolicy(String pid);
+    /**
+     * Return the collection of TunnelInfo which contains
+     * 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 9380e94..1b8a450 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
@@ -937,14 +937,14 @@
     // Policy routing classes and functions
     // ************************************
 
-    class PolicyInfo {
+    public class PolicyInfo {
 
-        String policyId;
-        PacketMatch match;
-        int priority;
-        String tunnelId;
+        private String policyId;
+        private PacketMatch match;
+        private int priority;
+        private String tunnelId;
 
-        PolicyInfo(String pid, PacketMatch match, int priority, String tid) {
+        public PolicyInfo(String pid, PacketMatch match, int priority, String tid) {
             this.policyId = pid;
             this.match = match;
             this.priority = priority;
@@ -952,54 +952,63 @@
         }
     }
 
-    class TunnelInfo {
-        String tunnelId;
-        List<Dpid> dpids;
-        List<TunnelRouteInfo> routes;
+    public class TunnelInfo {
+        private String tunnelId;
+        private List<Dpid> dpids;
+        private List<TunnelRouteInfo> routes;
 
-        TunnelInfo(String tid, List<Dpid> dpids, List<TunnelRouteInfo> routes) {
+        public TunnelInfo(String tid, List<Dpid> dpids, List<TunnelRouteInfo> routes) {
             this.tunnelId = tid;
             this.dpids = dpids;
             this.routes = routes;
         }
+        public String getTunnelId(){
+            return this.tunnelId;
+        }
+        public List<Dpid> getDpids(){
+            return this.dpids;
+        }
+        public List<TunnelRouteInfo> getRoutes(){
+            return this.routes;
+        }
     }
 
-    class TunnelRouteInfo {
+    public class TunnelRouteInfo {
 
-        String srcSwDpid;
-        List<Dpid> fwdSwDpids;
-        List<String> route;
+        private String srcSwDpid;
+        private List<Dpid> fwdSwDpids;
+        private List<String> route;
 
-        TunnelRouteInfo() {
+        public TunnelRouteInfo() {
             fwdSwDpids = new ArrayList<Dpid>();
             route = new ArrayList<String>();
         }
 
-        void setSrcDpid(String dpid) {
+        private void setSrcDpid(String dpid) {
             this.srcSwDpid = dpid;
         }
 
-        void setFwdSwDpid(List<Dpid> dpid) {
+        private void setFwdSwDpid(List<Dpid> dpid) {
             this.fwdSwDpids = dpid;
         }
 
-        void addRoute(String id) {
+        private void addRoute(String id) {
             route.add(id);
         }
 
-        void setRoute(List<String> r) {
+        private void setRoute(List<String> r) {
             this.route = r;
         }
 
-        String getSrcSwDpid() {
+        public String getSrcSwDpid() {
             return this.srcSwDpid;
         }
 
-        List<Dpid> getFwdSwDpid() {
+        public List<Dpid> getFwdSwDpid() {
             return this.fwdSwDpids;
         }
 
-        List<String> getRoute() {
+        public List<String> getRoute() {
             return this.route;
         }
     }
@@ -1010,7 +1019,7 @@
      * @return collection of TunnelInfo
      */
     public Collection<TunnelInfo> getTunnelTable() {
-        return tunnelTable.values();
+        return this.tunnelTable.values();
     }
 
     /**
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
new file mode 100644
index 0000000..785dde7
--- /dev/null
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelInfo.java
@@ -0,0 +1,32 @@
+package net.onrc.onos.apps.segmentrouting.web;
+
+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<List<String>> labelStack;
+    
+    public SegmentRouterTunnelInfo (String tId, List<Dpid> dpids, 
+            List<List<String>> tunnelRoutes){
+        this.tunnelId = tId;
+        this.nodes = dpids;
+        this.labelStack = tunnelRoutes;
+    }
+    public String getTunnelId (){
+        return this.tunnelId;
+    }
+    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/SegmentRouterTunnelResource.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterTunnelResource.java
index 7bcdfa6..71cfc05 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
@@ -15,6 +15,16 @@
 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
  *
@@ -57,9 +67,30 @@
     }
 
     @Get("json")
-    public String getTunnel() {
-        String reply = "success";
+    public Object getTunnel() {
+        System.out.println("Got into getTunnel");
+        ISegmentRoutingService segmentRoutingService =
+                (ISegmentRoutingService) getContext().getAttributes().
+                        get(ISegmentRoutingService.class.getCanonicalName());
+        Iterator<TunnelInfo> ttI = segmentRoutingService.getTunnelTable().iterator();
+        List<SegmentRouterTunnelInfo> infoList = new ArrayList<SegmentRouterTunnelInfo>();
+        while(ttI.hasNext()){
+           TunnelInfo tunnelInfo = ttI.next();
+           Iterator<TunnelRouteInfo>trI = tunnelInfo.getRoutes().iterator();
+           List<List<String>> labelStack = new ArrayList<List<String>>();
+           while(trI.hasNext()){
+               TunnelRouteInfo label = trI.next();
+               labelStack.add(label.getRoute());
+           }
+           SegmentRouterTunnelInfo info = new SegmentRouterTunnelInfo(tunnelInfo.getTunnelId(),
+                   tunnelInfo.getDpids(), labelStack );
+           infoList.add(info);
+           //TODO Add Group/DPID
+           
+        }
         log.debug("getTunnel with params");
-        return reply;
+        Map <String,List<SegmentRouterTunnelInfo>>result = new HashMap<String,List<SegmentRouterTunnelInfo>>();
+        result.put("tunnels", infoList);
+        return infoList;
     }
 }
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRoutingWebRoutable.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRoutingWebRoutable.java
index 119df92..e19df8d 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRoutingWebRoutable.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRoutingWebRoutable.java
@@ -1,6 +1,9 @@
 package net.onrc.onos.apps.segmentrouting.web;
 
+import java.util.Iterator;
+
 import net.floodlightcontroller.restserver.RestletRoutable;
+import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager;
 
 import org.restlet.Context;
 import org.restlet.Restlet;