Added command 'show tunnel details', replaced node with policyIds
diff --git a/cli/cli/c_actions.py b/cli/cli/c_actions.py
index 603089a..23959c3 100755
--- a/cli/cli/c_actions.py
+++ b/cli/cli/c_actions.py
@@ -2141,16 +2141,18 @@
             labelStack = remove_unicodes(labelStack)
             tunnelId = tunnel.get('tunnelId')
             dpidGroup = str(tunnel.get('dpidGroup'))
+            policies = tunnel.get('policies')
             #nodes = ''
             #for node in tunnel.get("nodes"):
             #    nodes += (node.get('value') + ',')
             #if nodes != '':
             #    nodes = nodes[:-1]
             combResult.append({
-                               'tunnelId'         : tunnelId,
+                               'tunnelId'       : tunnelId,
                                #'nodes'           : nodes,
-                               'labelStack'      :labelStack,
+                               'labelStack'     :labelStack,
                                'dpidGroup'      :dpidGroup,
+                               'policies'       : policies,
                                })
         entries = combResult
 
diff --git a/cli/cli/desc/version200/core.py b/cli/cli/desc/version200/core.py
index fc4d2d8..edcaf64 100755
--- a/cli/cli/desc/version200/core.py
+++ b/cli/cli/desc/version200/core.py
@@ -2414,16 +2414,15 @@
 SHOW_TUNNEL_FORMAT = {
     'show_tunnel' : {
         'field-orderings' : {
-            'default' : [ 'Idx', 'tunnelId', 'labelStack',],
-            'details' : [ 'Idx', 'tunnelId', 'labelStack', 'dpidGroup',],
-            'scoped' : [ 'Idx', 'tunnelId', 'labelStack', 'dpidGroup',],
+            'default' : [ 'Idx', 'tunnelId', 'policies','labelStack',],
+            'details' : [ 'Idx', 'tunnelId', 'policies','labelStack', 'dpidGroup',],
             },
-       # 'fields': {
-       #     'tunnelId'         : { 'verbose-name' : 'Id',
-       #                        },
-       #     'dpidGroup'         : { 'verbose-name' : 'dpid/Group',
-       #                        },
-        #           }
+        'fields': {
+            'tunnelId'         : { 'verbose-name' : 'Id',
+                               },
+            'dpidGroup'         : { 'verbose-name' : 'dpid/Group',
+                               },
+                   }
         },
 }
 
diff --git a/cli/cli/desc/version200/switch.py b/cli/cli/desc/version200/switch.py
index b7cff6c..5f6eb16 100755
--- a/cli/cli/desc/version200/switch.py
+++ b/cli/cli/desc/version200/switch.py
@@ -55,14 +55,15 @@
 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['stringAttributes']['nodeSid'].startswith(prefix):
-            completions[entry['stringAttributes']['nodeSid']+' '] = entry['stringAttributes']['nodeSid']
+        if entry['dpid'].startswith(prefix):
+            completions[entry['dpid']+' '] = entry['dpid']
     return
 
-command.add_completion('tunnel-node-label-completion', tunnel_node_completion,
+command.add_completion('tunnel-node-completion', tunnel_node_completion,
                        {'kwargs': { 'prefix'       : '$text',
                                     'completions'  : '$completions',
                                     }})
@@ -79,11 +80,11 @@
     'args'                : (
          {
              'field'      : 'node-value',
-             'completion'   : 'tunnel-node-label-completion',
-             'type'         : 'label',
-             'other'        : 'switches|label',
+             'completion'   : 'tunnel-node-completion',
+             'type'         : 'dpid',
+             'other'        : 'switches|dpid',
 #             'data-handler' : 'alias-to-value',
-             'help-name'    : 'Segment label',
+             'help-name'    : 'switch dpid or switch alias',
              'action'       : (
                                 {
                                     'proc' : 'create-tunnel',
@@ -154,14 +155,14 @@
     'choices' : (
         (
             {
-                'field'        : 'src_ip',
+                'field'        : 'src-ip',
                 'type'         : 'cidr-range',
                 'help-name'    : 'src-cidr',
                 #'data-handler' : 'split-cidr-data-inverse',
                 #'dest-ip'      : 'src-ip',
                 #'dest-netmask' : 'src-ip-mask',
                 'data'         : {
-                                  'dst_ip'      : '0.0.0.0/32',
+                                  'dst-ip'      : '0.0.0.0/32',
                                  },
                 'doc'          : 'vns|vns-access-list-cidr-range',
             }
@@ -170,8 +171,8 @@
             {
                 'token'  : 'any',
                 'data'   : {
-                              'src_ip'      : '0.0.0.0/32',
-                              'dst_ip'      : '0.0.0.0/32',
+                              'src-ip'      : '0.0.0.0/32',
+                              'dst-ip'      : '0.0.0.0/32',
                            },
                 'doc'    : 'vns|vns-access-list-ip-any',
             }
@@ -181,7 +182,7 @@
 
 SRC_PORT_MATCH = (
     {
-        'field'  : 'src_tp_port_op',
+        'field'  : 'src-tp-port-op',
         'type'   : 'enum',
         'values' : ('eq', 'neq'),
         'doc'    : 'vns|vns-access-list-port-op-+',
@@ -189,7 +190,7 @@
     {
         'choices' : (
             {
-                'field'        : 'src_tp_port',
+                'field'        : 'src-tp-port',
                 'base-type'    : 'hex-or-decimal-integer',
                 'range'        : (0,65535),
                 'data-handler' : 'hex-to-integer',
@@ -197,7 +198,7 @@
                 'doc-include'  : [ 'range' ],
             },
             {
-                'field'   : 'src_tp_port',
+                'field'   : 'src-tp-port',
                 'type'    : 'enum',
                 'values'  : fmtcnv.tcp_name_to_number_dict,
                 'permute' : 'skip',
@@ -212,7 +213,7 @@
     'choices' : (
         (
             {
-                'field'        : 'dst_ip',
+                'field'        : 'dst-ip',
                 'type'         : 'cidr-range',
                 'help-name'    : 'dst-cidr',
                 #'data-handler' : 'split-cidr-data-inverse',
@@ -225,7 +226,7 @@
             {
                 'token'  : 'any',
                 'data'   : {
-                              'dst_ip'      : '0.0.0.0/32',
+                              'dst-ip'      : '0.0.0.0/32',
                            },
                 'doc'    : 'vns|vns-access-list-ip-any',
             }
@@ -236,7 +237,7 @@
 
 DST_PORT_MATCH = (
     {
-        'field' : 'dst_tp_port_op',
+        'field' : 'dst-tp-port-op',
         'type'  : 'enum',
         'values' : ('eq', 'neq'),
         'doc'          : 'vns|vns-access-list-port-op+',
@@ -244,14 +245,14 @@
     {
         'choices' : (
             {
-                'field'        : 'dst_tp_port',
+                'field'        : 'dst-tp-port',
                 'base-type'    : 'hex-or-decimal-integer',
                 'range'        : (0,65535),
                 'data-handler' : 'hex-to-integer',
                 'doc'          : 'vns|vns-access-list-port-hex',
             },
             {
-                'field'   : 'dst_tp_port',
+                'field'   : 'dst-tp-port',
                 'type'    : 'enum',
                 'values'  : fmtcnv.tcp_name_to_number_dict,
                 'permute' : 'skip'
@@ -279,13 +280,13 @@
                 {
                     'choices' : (
                         {
-                            'field'  : 'proto_type',
+                            'field'  : 'type',
                             'type'   : 'enum',
                             'values' : ('ip','tcp','udp'),
                             'doc'    : 'vns|vns-access-list-entry-type-+',
                         },
                         {
-                            'field'        : 'proto_type',
+                            'field'        : 'type',
                             'base-type'    : 'hex-or-decimal-integer',
                             'range'        : (0,255),
                             'help-name'    : 'ip protocol',
@@ -594,16 +595,6 @@
                         'field'      : 'realtimestats',
                         'type'       : 'enum',
                         'values'     : 'table',
-                        #'args':(
-                        #        {
-                        #         'field'      : 'tabletype',
-                        #             'type'       : 'enum',
-                        #             'values'     : ('ip',
-                        #                             'acl',
-                        #                             'mpls'
-                        #                             ),
-                        #         },
-                        #        )
                     },
                     {
                         'field'    : 'tabletype',
diff --git a/cli/cli/desc/version200/tunnel.py b/cli/cli/desc/version200/tunnel.py
index c32ad89..333b6b8 100644
--- a/cli/cli/desc/version200/tunnel.py
+++ b/cli/cli/desc/version200/tunnel.py
@@ -19,17 +19,16 @@
                        ],
             'format' : 'show_tunnel',
         },
-              {
+              { 
+            'optional'   : True,
             'choices' : (
                 {
                  'field'      : 'showtunnel',
                  'type'       : 'enum',
                  'values'     : ('details',),
-                 'action'     : 'display-rest',
-                 'url'        : 'showtunnel',
                  'optional'   : True,
                  'format' : 'show_tunnel',
-                 'doc'        : 'switch|show-switch-format-+',
+                 'data'         : { 'detail' : 'details' },
                 },
                          ),
                }
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 add898f..44411cd 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/ISegmentRoutingService.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/ISegmentRoutingService.java
@@ -5,6 +5,7 @@
 
 import net.floodlightcontroller.core.module.IFloodlightService;
 import net.floodlightcontroller.util.MACAddress;
+import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.PolicyInfo;
 import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.TunnelInfo;
 import net.onrc.onos.core.util.IPv4Net;
 
@@ -77,4 +78,9 @@
      * dpid is not found
      */
     public int getTunnelGroupId(String tunnelId, String dpid);
+    /**
+     * return list of all the policies currently there in Segment Router
+     * @return Collection<PolicyInfo>
+     */
+    public Collection<PolicyInfo> getPoclicyTable();
 }
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 3ed4bdf..8a9ec48 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
@@ -1052,6 +1052,10 @@
     public Collection<TunnelInfo> getTunnelTable() {
         return this.tunnelTable.values();
     }
+    
+    public Collection<PolicyInfo> getPoclicyTable() {
+        return this.policyTable.values();
+    }
 
     /**
      * Return router DPIDs for the tunnel
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 4c6457a..105983b 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
@@ -9,12 +9,14 @@
     private String tunnelId;
     private List<List<String>> labelStack;
     private List<String> dpidGroup;
+    private String policies;
     
-    public SegmentRouterTunnelInfo (String tId,
-            List<List<String>> tunnelRoutes, List<String> dpidsWithGroup){
+    public SegmentRouterTunnelInfo (String tId,List<List<String>> tunnelRoutes,
+            List<String> dpidsWithGroup,String policiesId){
         this.tunnelId = tId;
         this.labelStack = tunnelRoutes;
         this.dpidGroup = dpidsWithGroup;
+        this.policies = policiesId;
     }
     public String getTunnelId (){
         return this.tunnelId;
@@ -25,4 +27,7 @@
     public List<String> getDpidGroup (){
         return this.dpidGroup;
     }
+    public String getPolicies (){
+        return this.policies;
+    }
 }
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 d391082..32d9cc6 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,12 +2,14 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 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.PolicyInfo;
 import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.TunnelInfo;
 import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.TunnelRouteInfo;
 
@@ -80,18 +82,31 @@
         List<SegmentRouterTunnelInfo> infoList = new ArrayList<SegmentRouterTunnelInfo>();
         while(ttI.hasNext()){
            TunnelInfo tunnelInfo = ttI.next();
+           String tunnelId = tunnelInfo.getTunnelId();
+           Collection<PolicyInfo> policies = segmentRoutingService.getPoclicyTable();
+           Iterator<PolicyInfo> piI = policies.iterator();
+           String policiesId = "";
+           while(piI.hasNext()){
+               PolicyInfo policy = piI.next();
+               if(policy.getTunnelId().equals(tunnelId)){
+                   policiesId += (policy.getPolicyId()+",");
+               }
+           }
+           if (policiesId.endsWith(",")){
+               policiesId = (String) policiesId.subSequence(0, policiesId.length()-1);
+           }
            Iterator<TunnelRouteInfo>trI = tunnelInfo.getRoutes().iterator();
            List<List<String>> labelStack = new ArrayList<List<String>>();
            List<String> dpidGroup = new ArrayList<String>();
            while(trI.hasNext()){
                TunnelRouteInfo label = trI.next();
                labelStack.add(label.getRoute());
-               Integer gId = segmentRoutingService.getTunnelGroupId(tunnelInfo.getTunnelId(), 
+               Integer gId = segmentRoutingService.getTunnelGroupId(tunnelId, 
                        label.getSrcSwDpid());
                dpidGroup.add(label.getSrcSwDpid() + "/"+ gId);
            }
-           SegmentRouterTunnelInfo info = new SegmentRouterTunnelInfo(tunnelInfo.getTunnelId(),
-                    labelStack, dpidGroup);
+           SegmentRouterTunnelInfo info = new SegmentRouterTunnelInfo(tunnelId,
+                    labelStack, dpidGroup, policiesId);
            infoList.add(info);
         }
         log.debug("getTunnel with params");