CLI support for adjacency labels and policy type
diff --git a/cli/cli/c_actions.py b/cli/cli/c_actions.py
index 70220a4..93c00c0 100755
--- a/cli/cli/c_actions.py
+++ b/cli/cli/c_actions.py
@@ -87,8 +87,10 @@
         tunnel_dict[tunnel_id]=[]
     if sdnsh.description:   # description debugging
         print "tunnel_create:" , tunnel_id, tunnel_dict
-    if data.has_key('node-value'):    
-        tunnel_dict[tunnel_id].append(data['node-value'])
+    if data.has_key('node-label'):    
+        tunnel_dict[tunnel_id].append(data['node-label'])
+    if data.has_key('adjacency-label'):    
+        tunnel_dict[tunnel_id].append(data['adjacency-label'])
 
 def tunnel_config_exit():
     global tunnel_id,tunnel_dict
@@ -131,7 +133,8 @@
         print "policy_create:" , data
     if data.has_key('policy-id'):
         policy_obj_data['policy_id'] = data['policy-id']
-    if data.has_key('src-ip'):
+        policy_obj_data['policy_type'] = data['policy-type']
+    if data.has_key('src_ip'):
         for key in data:
             policy_obj_data[key] = data[key]
     if data.has_key('priority'):
diff --git a/cli/cli/climodelinfo.py b/cli/cli/climodelinfo.py
index 89ba58e..22fdded 100755
--- a/cli/cli/climodelinfo.py
+++ b/cli/cli/climodelinfo.py
@@ -248,6 +248,42 @@
         },
 
 
+        'tunnel-config' : {
+            'source'          : 'user-config',
+            'source'          : 'display',
+            'url'             : 'tunnel-config',
+            'config-obj-type' : 'tunnel-config',
+
+            'fields' : {
+                'tunnel-id'               : {
+                                         'edit' : False,
+                                         'max_length': 32,
+                                         'null': False,
+                                         'primary_key': True,
+                                         'type': 'CharField',
+                                         'edit' : False,
+                                       },
+                        },
+        },
+                                      
+        'policy-config' : {
+            'source'          : 'user-config',
+            'source'          : 'display',
+            'url'             : 'policy-config',
+            'config-obj-type' : 'policy-config',
+
+            'fields' : {
+                'policy-id'               : {
+                                         'edit' : False,
+                                         'max_length': 32,
+                                         'null': False,
+                                         'primary_key': True,
+                                         'type': 'CharField',
+                                         'edit' : False,
+                                       },
+                        },
+        },
+                                      
         'switch-alias' : {
             'source'          : 'user-config',
             'cascade_delete'  : True,
diff --git a/cli/cli/desc/version200/policy.py b/cli/cli/desc/version200/policy.py
index c5174d4..13d21aa 100644
--- a/cli/cli/desc/version200/policy.py
+++ b/cli/cli/desc/version200/policy.py
@@ -1,4 +1,322 @@
-#import fmtcnv
+import command
+import json
+import fmtcnv
+"""
+POLICY_SUBMODE_COMMAND_DESCRIPTION = {
+    'name'          : 'policy',
+    'short-help'    : 'Enter policy submode, configure SR policy details',
+    'mode'          : 'config',
+    'parent-field'  : None,
+    'command-type'  : 'config-submode',
+    'obj-type'      : 'policy-config',
+    'submode-name'  : 'config-policy',
+    'doc'           : 'policy|policy',
+    'doc-example'   : 'policy|tunnel-example',
+    'args' : (
+        {
+            'field'        : 'policy-id',
+            'type'         : 'identifier',
+            'completion'   : 'complete-object-field',
+            'syntax-help'  : 'Enter a policy id',
+            'doc'          : 'policy|policy',
+            'doc-include'  : [ 'type-doc' ],
+            'action'       : (
+                                {
+                                    'proc' : 'create-policy',
+                                },
+                                {
+                                    'proc' : 'push-mode-stack',
+                                },
+                              ),
+            'no-action': (
+                {
+                    'proc' : 'remove-policy',
+                }
+            ),
+        }
+    )
+}
+"""
+POLICY_CONFIG_FORMAT = {
+    'policy-config' : {
+        'field-orderings' : {
+            'default' : [
+                          'policy-id',
+                        ],
+        },
+    },
+}
+
+POLICY_SUBMODE_COMMAND_DESCRIPTION = {
+    'name'          : 'policy',
+    'short-help'    : 'Enter policy submode, configure SR policy details',
+    'mode'          : 'config',
+    'command-type'  : 'config-submode',
+    'obj-type'      : 'policy-config',
+    'submode-name'  : 'config-policy',
+    'parent-field'  : None,
+    'doc'           : 'policy|policy',
+    'doc-example'   : 'policy|policy-example',
+    'args' : {
+        'action'       : (
+                            {
+                                'proc' : 'create-policy',
+                            },
+                            {
+                                'proc' : 'push-mode-stack',
+                            },
+                         ),
+        'no-action'    : (
+                            {
+                                'proc' : 'remove-policy',
+                            },
+                         ),
+        'choices'      : (
+            (
+                {
+                    'field'        : 'policy-id',
+                    'type'         : 'identifier',
+                    'completion'   : 'complete-object-field',
+                    'syntax-help'  : 'Enter a policy name',
+                    'doc'          : 'policy|policy',
+                    #'doc-include'  : [ 'type-doc' ],
+                },
+                {
+                    'token'        : 'type',
+                    'short-help'   : 'Set type of policy',
+                    'doc'          : 'policy|policy',
+                    'completion'   : 'complete-object-field',
+                },
+                {
+                    'field'        : 'policy-type',
+                    'type'         : 'enum',
+                    'values'       : ('tunnel','loadbalanced','avoid','deny'), 
+                    'completion'   : 'complete-object-field',
+                    'syntax-help'  : 'Enter a policy type',
+                    'doc'          : 'policy|policy',
+                    #'doc-include'  : [ 'type-doc' ],
+                },
+            ),
+        ),
+    }
+}
+
+SRC_IP_MATCH = {
+    'choices' : (
+        (
+            {
+                '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',
+                                 },
+                'doc'          : 'vns|vns-access-list-cidr-range',
+            }
+        ),
+        (
+            {
+                'token'  : 'any',
+                'data'   : {
+                              'src_ip'      : '0.0.0.0/32',
+                              'dst_ip'      : '0.0.0.0/32',
+                           },
+                'doc'    : 'vns|vns-access-list-ip-any',
+            }
+        ),
+    )
+}
+
+SRC_PORT_MATCH = (
+    {
+        'field'  : 'src_tp_port_op',
+        'type'   : 'enum',
+        'values' : ('eq', 'neq'),
+        'doc'    : 'vns|vns-access-list-port-op-+',
+    },
+    {
+        'choices' : (
+            {
+                'field'        : 'src_tp_port',
+                'base-type'    : 'hex-or-decimal-integer',
+                'range'        : (0,65535),
+                'data-handler' : 'hex-to-integer',
+                'doc'          : 'vns|vns-access-list-port-hex',
+                'doc-include'  : [ 'range' ],
+            },
+            {
+                'field'   : 'src_tp_port',
+                'type'    : 'enum',
+                'values'  : fmtcnv.tcp_name_to_number_dict,
+                'permute' : 'skip',
+                'doc'     : 'vns|vns-access-list-port-type',
+            },
+        ),
+    },
+)
+
+
+DST_IP_MATCH = {
+    'choices' : (
+        (
+            {
+                'field'        : 'dst_ip',
+                'type'         : 'cidr-range',
+                'help-name'    : 'dst-cidr',
+                #'data-handler' : 'split-cidr-data-inverse',
+                #'dest-ip'      : 'dst-ip',
+                #'dest-netmask' : 'dst-ip-mask',
+                'doc'          : 'vns|vns-access-list-cidr-range',
+            },
+        ),
+        (
+            {
+                'token'  : 'any',
+                'data'   : {
+                              'dst_ip'      : '0.0.0.0/32',
+                           },
+                'doc'    : 'vns|vns-access-list-ip-any',
+            }
+        ),
+    )
+}
+
+
+DST_PORT_MATCH = (
+    {
+        'field' : 'dst_tp_port_op',
+        'type'  : 'enum',
+        'values' : ('eq', 'neq'),
+        'doc'          : 'vns|vns-access-list-port-op+',
+    },
+    {
+        'choices' : (
+            {
+                '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',
+                'type'    : 'enum',
+                'values'  : fmtcnv.tcp_name_to_number_dict,
+                'permute' : 'skip'
+            },
+        ),
+    }
+)
+
+POLICY_FLOW_ENTRY_COMMAND_DESCRIPTION = {
+    'name'            : 'flow-entry',
+    'mode'            : 'config-policy',
+    'command-type'    : 'config',
+    'short-help'      : 'Configure flow entry',
+    'doc'             : 'flow-entry|flow-entry',
+    'doc-example'     : 'flow-entry|flow-entry-example',
+    'parent-field'    : 'policy',
+    'args' : {
+        'action'       : (
+                            {
+                                'proc' : 'create-policy',
+                            },
+                         ),
+        'choices' : (
+            (
+                {
+                    'choices' : (
+                        {
+                            'field'  : 'proto_type',
+                            'type'   : 'enum',
+                            'values' : ('ip','tcp','udp'),
+                            'doc'    : 'vns|vns-access-list-entry-type-+',
+                        },
+                        {
+                            'field'        : 'proto_type',
+                            'base-type'    : 'hex-or-decimal-integer',
+                            'range'        : (0,255),
+                            'help-name'    : 'ip protocol',
+                            'data-handler' : 'hex-to-integer',
+                            'doc'          : 'vns|vns-access-entry-type-ip-protocol',
+                            'doc-include'  : [ 'range' ],
+                        },
+                    )
+                },
+                # Complexity arises from the SRC_IP match part 
+                # being, required, while the port match
+                # is optional, as is the DST_IP match, but the
+                # DST_PORT_MATCH is only possible to describe when
+                # the DST_IP part is included
+                SRC_IP_MATCH,
+                {
+                    'optional' : True,
+                    'optional-for-no' : True,
+                    'args' : SRC_PORT_MATCH,
+                },
+                {
+                    'optional' : True,
+                    'optional-for-no' : True,
+                    'args' : (
+                        DST_IP_MATCH,
+                        {
+                            'optional' : True,
+                            'optional-for-no' : True,
+                            'args' : DST_PORT_MATCH,
+                        },
+                    ),
+                },
+            ),
+        ),
+    },
+}
+
+POLICY_TUNNEL_ID_COMMAND_DESCRIPTION = {
+    'name'            : 'tunnel',
+    'mode'            : 'config-policy',
+    #'obj-type'        : 'policy-config',
+    'command-type'    : 'config',
+    'short-help'      : 'Configure tunnel id',
+    #'doc'             : 'policy|tunnel',
+    #'doc-example'     : 'policy|policy-tunnel-example',
+    'parent-field'    : 'policy',
+    'args' : {
+        'action'       : (
+                            {
+                                'proc' : 'create-policy',
+                            },
+                         ),
+        'field'        : 'tunnel-id',
+        'type'         : 'identifier',
+        'syntax-help'  : 'Enter tunnel id',
+        'doc'          : 'policy|tunnel-id',
+        'doc-include'  : [ 'type-doc' ],
+    }
+}
+
+POLICY_PRIORITY_COMMAND_DESCRIPTION = {
+    'name'            : 'priority',
+    'mode'            : 'config-policy',
+    'command-type'    : 'config',
+    'short-help'      : 'Configure policy priority',
+    'doc'             : 'policy|priority',
+    'doc-example'     : 'policy|policy-priority-example',
+    'parent-field'    : 'policy',
+    'args' : {
+        'action'       : (
+                            {
+                                'proc' : 'create-policy',
+                            },
+                         ),
+        'field'     : 'priority',
+        'base-type' : 'integer',
+        'range'     : (0, 65535),
+    }
+}
+
 SWITCH_TUNNEL_COMMAND_DESCRIPTION = {
     'name'                : 'show',
     'mode'                : 'login',
diff --git a/cli/cli/desc/version200/switch.py b/cli/cli/desc/version200/switch.py
index 5f6eb16..7daabcd 100755
--- a/cli/cli/desc/version200/switch.py
+++ b/cli/cli/desc/version200/switch.py
@@ -17,356 +17,6 @@
 import json
 import fmtcnv
 
-TUNNEL_SUBMODE_COMMAND_DESCRIPTION = {
-    'name'          : 'tunnel',
-    'short-help'    : 'Enter tunnel submode, configure tunnel details',
-    'mode'          : 'config',
-    'parent-field'  : None,
-    'command-type'  : 'config-submode',
-    'obj-type'      : 'tunnel-config',
-    'submode-name'  : 'config-tunnel',
-    'doc'           : 'tunnel|tunnel',
-    'doc-example'   : 'tunnel|tunnel-example',
-    'args' : (
-        {
-            'field'        : 'tunnel-id',
-            'type'         : 'identifier',
-            'completion'   : 'complete-object-field',
-            'syntax-help'  : 'Enter a tunnel name',
-            'doc'          : 'tunnel|tunnel',
-            'doc-include'  : [ 'type-doc' ],
-            'action'       : (
-                                {
-                                    'proc' : 'create-tunnel',
-                                },
-                                {
-                                    'proc' : 'push-mode-stack',
-                                },
-                              ),
-            'no-action': (
-                {
-                    'proc' : 'remove-tunnel',
-                }
-            ),
-        }
-    )
-}
-
-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']
-    return
-
-command.add_completion('tunnel-node-completion', tunnel_node_completion,
-                       {'kwargs': { 'prefix'       : '$text',
-                                    'completions'  : '$completions',
-                                    }})
-
-# obj_type flow-entry field hard-timeout
-TUNNEL_NODE_ENTRY_COMMAND_DESCRIPTION = {
-    'name'                : 'node',
-    'mode'                : 'config-tunnel',
-    'short-help'          : 'Set node for this tunnel',
-    'doc'                 : 'tunnel|node',
-    'doc-example'         : 'tunnel|node',
-    'parent-field'        : 'tunnel',
-    'command-type'        : 'config',
-    'args'                : (
-         {
-             'field'      : 'node-value',
-             'completion'   : 'tunnel-node-completion',
-             'type'         : 'dpid',
-             'other'        : 'switches|dpid',
-#             'data-handler' : 'alias-to-value',
-             'help-name'    : 'switch dpid or switch alias',
-             'action'       : (
-                                {
-                                    'proc' : 'create-tunnel',
-                                },
-                              ),
-         }
-    )
-}
-"""
-TUNNEL_ADJACENCY_ENTRY_COMMAND_DESCRIPTION = {
-    'name'                : 'adjacency',
-    'mode'                : 'config-tunnel',
-    'short-help'          : 'Set adjacency for this tunnel',
-    'doc'                 : 'tunnel|path',
-    'doc-example'         : 'tunnel|path',
-    'command-type'        : 'config',
-    'args'                : (
-         {
-             'field'      : 'adjacency-value',
-             'type'       : 'string',
-             'help-name'  : 'switch port',
-             'action'       : (
-                                {
-                                    'proc' : 'create-tunnel',
-                                },
-                              ),
-         }
-    )
-}
-"""
-
-POLICY_SUBMODE_COMMAND_DESCRIPTION = {
-    'name'          : 'policy',
-    'short-help'    : 'Enter policy submode, configure SR policy details',
-    'mode'          : 'config',
-    'command-type'  : 'config-submode',
-    'obj-type'      : 'policy-config',
-    'submode-name'  : 'config-policy',
-    'parent-field'  : None,
-    'doc'           : 'policy|policy',
-    'doc-example'   : 'policy|policy-example',
-    'args' : (
-        {
-            'field'        : 'policy-id',
-            'type'         : 'identifier',
-            'completion'   : 'complete-object-field',
-            'syntax-help'  : 'Enter a policy name',
-            'doc'          : 'policy|policy',
-            'doc-include'  : [ 'type-doc' ],
-            'action'       : (
-                                {
-                                    'proc' : 'create-policy',
-                                },
-                                {
-                                    'proc' : 'push-mode-stack',
-                                },
-                              ),
-            'no-action': (
-                {
-                    'proc' : 'remove-policy',
-                },
-            )
-        }
-    )
-}
-
-SRC_IP_MATCH = {
-    'choices' : (
-        (
-            {
-                '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',
-                                 },
-                'doc'          : 'vns|vns-access-list-cidr-range',
-            }
-        ),
-        (
-            {
-                'token'  : 'any',
-                'data'   : {
-                              'src-ip'      : '0.0.0.0/32',
-                              'dst-ip'      : '0.0.0.0/32',
-                           },
-                'doc'    : 'vns|vns-access-list-ip-any',
-            }
-        ),
-    )
-}
-
-SRC_PORT_MATCH = (
-    {
-        'field'  : 'src-tp-port-op',
-        'type'   : 'enum',
-        'values' : ('eq', 'neq'),
-        'doc'    : 'vns|vns-access-list-port-op-+',
-    },
-    {
-        'choices' : (
-            {
-                'field'        : 'src-tp-port',
-                'base-type'    : 'hex-or-decimal-integer',
-                'range'        : (0,65535),
-                'data-handler' : 'hex-to-integer',
-                'doc'          : 'vns|vns-access-list-port-hex',
-                'doc-include'  : [ 'range' ],
-            },
-            {
-                'field'   : 'src-tp-port',
-                'type'    : 'enum',
-                'values'  : fmtcnv.tcp_name_to_number_dict,
-                'permute' : 'skip',
-                'doc'     : 'vns|vns-access-list-port-type',
-            },
-        ),
-    },
-)
-
-
-DST_IP_MATCH = {
-    'choices' : (
-        (
-            {
-                'field'        : 'dst-ip',
-                'type'         : 'cidr-range',
-                'help-name'    : 'dst-cidr',
-                #'data-handler' : 'split-cidr-data-inverse',
-                #'dest-ip'      : 'dst-ip',
-                #'dest-netmask' : 'dst-ip-mask',
-                'doc'          : 'vns|vns-access-list-cidr-range',
-            },
-        ),
-        (
-            {
-                'token'  : 'any',
-                'data'   : {
-                              'dst-ip'      : '0.0.0.0/32',
-                           },
-                'doc'    : 'vns|vns-access-list-ip-any',
-            }
-        ),
-    )
-}
-
-
-DST_PORT_MATCH = (
-    {
-        'field' : 'dst-tp-port-op',
-        'type'  : 'enum',
-        'values' : ('eq', 'neq'),
-        'doc'          : 'vns|vns-access-list-port-op+',
-    },
-    {
-        'choices' : (
-            {
-                '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',
-                'type'    : 'enum',
-                'values'  : fmtcnv.tcp_name_to_number_dict,
-                'permute' : 'skip'
-            },
-        ),
-    }
-)
-
-POLICY_FLOW_ENTRY_COMMAND_DESCRIPTION = {
-    'name'            : 'flow-entry',
-    'mode'            : 'config-policy',
-    'command-type'    : 'config',
-    'short-help'      : 'Configure flow entry',
-    'doc'             : 'flow-entry|flow-entry',
-    'doc-example'     : 'flow-entry|flow-entry-example',
-    'parent-field'    : 'policy',
-    'args' : {
-        'action'       : (
-                            {
-                                'proc' : 'create-policy',
-                            },
-                         ),
-        'choices' : (
-            (
-                {
-                    'choices' : (
-                        {
-                            'field'  : 'type',
-                            'type'   : 'enum',
-                            'values' : ('ip','tcp','udp'),
-                            'doc'    : 'vns|vns-access-list-entry-type-+',
-                        },
-                        {
-                            'field'        : 'type',
-                            'base-type'    : 'hex-or-decimal-integer',
-                            'range'        : (0,255),
-                            'help-name'    : 'ip protocol',
-                            'data-handler' : 'hex-to-integer',
-                            'doc'          : 'vns|vns-access-entry-type-ip-protocol',
-                            'doc-include'  : [ 'range' ],
-                        },
-                    )
-                },
-                # Complexity arises from the SRC_IP match part 
-                # being, required, while the port match
-                # is optional, as is the DST_IP match, but the
-                # DST_PORT_MATCH is only possible to describe when
-                # the DST_IP part is included
-                SRC_IP_MATCH,
-                {
-                    'optional' : True,
-                    'optional-for-no' : True,
-                    'args' : SRC_PORT_MATCH,
-                },
-                {
-                    'optional' : True,
-                    'optional-for-no' : True,
-                    'args' : (
-                        DST_IP_MATCH,
-                        {
-                            'optional' : True,
-                            'optional-for-no' : True,
-                            'args' : DST_PORT_MATCH,
-                        },
-                    ),
-                },
-            ),
-        ),
-    },
-}
-
-POLICY_TUNNEL_ID_COMMAND_DESCRIPTION = {
-    'name'            : 'tunnel',
-    'mode'            : 'config-policy',
-    #'obj-type'        : 'policy-config',
-    'command-type'    : 'config',
-    'short-help'      : 'Configure tunnel id',
-    #'doc'             : 'policy|tunnel',
-    #'doc-example'     : 'policy|policy-tunnel-example',
-    'parent-field'    : 'policy',
-    'args' : {
-        'action'       : (
-                            {
-                                'proc' : 'create-policy',
-                            },
-                         ),
-        'field'        : 'tunnel-id',
-        'type'         : 'identifier',
-        'syntax-help'  : 'Enter tunnel id',
-        'doc'          : 'policy|tunnel-id',
-        'doc-include'  : [ 'type-doc' ],
-    }
-}
-
-POLICY_PRIORITY_COMMAND_DESCRIPTION = {
-    'name'            : 'priority',
-    'mode'            : 'config-policy',
-    'command-type'    : 'config',
-    'short-help'      : 'Configure policy priority',
-    'doc'             : 'policy|priority',
-    'doc-example'     : 'policy|policy-priority-example',
-    'parent-field'    : 'policy',
-    'args' : {
-        'action'       : (
-                            {
-                                'proc' : 'create-policy',
-                            },
-                         ),
-        'field'     : 'priority',
-        'base-type' : 'integer',
-        'range'     : (0, 65535),
-    }
-}
-
 """
 SWITCH_SUBMODE_COMMAND_DESCRIPTION = {
     'name'          : 'switch',
diff --git a/cli/cli/desc/version200/tunnel.py b/cli/cli/desc/version200/tunnel.py
index 333b6b8..0ef077e 100644
--- a/cli/cli/desc/version200/tunnel.py
+++ b/cli/cli/desc/version200/tunnel.py
@@ -1,4 +1,150 @@
+import command
+import json
 import fmtcnv
+
+
+TUNNEL_SUBMODE_COMMAND_DESCRIPTION = {
+    'name'          : 'tunnel',
+    'short-help'    : 'Enter tunnel submode, configure tunnel details',
+    'mode'          : 'config',
+    'parent-field'  : None,
+    'command-type'  : 'config-submode',
+    'obj-type'      : 'tunnel-config',
+    'submode-name'  : 'config-tunnel',
+    'doc'           : 'tunnel|tunnel',
+    'doc-example'   : 'tunnel|tunnel-example',
+    'args' : (
+        {
+            'field'        : 'tunnel-id',
+            'type'         : 'identifier',
+            'completion'   : 'complete-object-field',
+            'syntax-help'  : 'Enter a tunnel name',
+            'doc'          : 'tunnel|tunnel',
+            'doc-include'  : [ 'type-doc' ],
+            'action'       : (
+                                {
+                                    'proc' : 'create-tunnel',
+                                },
+                                {
+                                    'proc' : 'push-mode-stack',
+                                },
+                              ),
+            'no-action': (
+                {
+                    'proc' : 'remove-tunnel',
+                }
+            ),
+        }
+    )
+}
+
+TUNNEL_CONFIG_FORMAT = {
+    'tunnel-config' : {
+        'field-orderings' : {
+            'default' : [
+                          'tunnel-id',
+                        ],
+        },
+    },
+}
+
+
+def tunnel_node_label_completion(prefix, completions):
+    #print "tunnel_node_label_completion:",prefix,completions
+    query_url = "http://127.0.0.1:8000/rest/v1/switches"
+    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']
+    return
+
+command.add_completion('tunnel-node-label-completion', tunnel_node_label_completion,
+                       {'kwargs': { 'prefix'       : '$text',
+                                    'completions'  : '$completions',
+                                    }})
+
+def tunnel_adjacency_label_completion(prefix, data, completions):
+    #print "tunnel_adjacency_label_completion:",prefix,data,completions
+    query_url = "http://127.0.0.1:8000/rest/v1/switches"
+    result = command.sdnsh.store.rest_simple_request(query_url)
+    entries = json.loads(result)
+    for entry in entries:
+        if (int(entry['stringAttributes']['nodeSid']) != int(data['node-label'])):
+            continue
+        adjacencySids = entry['stringAttributes']['adjacencySids']
+        #print "adjacencySids=",adjacencySids
+        for subs in adjacencySids.split('}'):
+            pair = subs.split('adjSid\":')
+            if len(pair) < 2:
+                continue
+            adjacency_label = pair[1]
+            #adjacency_label = entry['stringAttributes']['nodeSid'] + ':' + pair[1]
+            #print "adjacency_label=",adjacency_label 
+            if adjacency_label.startswith(prefix):
+                completions[adjacency_label+' '] = adjacency_label
+    return
+
+command.add_completion('tunnel-adjacency-label-completion', tunnel_adjacency_label_completion,
+                       {'kwargs': { 'prefix'       : '$text',
+                                    'data'         : '$data',
+                                    'completions'  : '$completions',
+                                    }})
+
+TUNNEL_ADJACENCY_INFO = (
+    {
+        'token'               : 'adjacency',
+        'short-help'          : 'Set adjacency label on this node',
+        'doc'                 : 'tunnel|adjacency',
+        'doc-example'         : 'tunnel|adjacency',
+    },
+    {
+         'field'      : 'adjacency-label',
+         'type'       : 'label',
+         'completion' : 'tunnel-adjacency-label-completion',
+         'help-name'  : 'Adjacency label',
+         'data'       : {
+                          'node_label'      : '$node-label',
+                        },
+         'action'       : (
+                            {
+                                'proc' : 'create-tunnel',
+                            },
+                          ),
+    }
+)
+
+# obj_type flow-entry field hard-timeout
+TUNNEL_NODE_ENTRY_COMMAND_DESCRIPTION = {
+    'name'                : 'node',
+    'mode'                : 'config-tunnel',
+    'short-help'          : 'Set node for this tunnel',
+    'doc'                 : 'tunnel|node',
+    'doc-example'         : 'tunnel|node',
+    'parent-field'        : 'tunnel',
+    'command-type'        : 'config',
+    'args'                : (
+         {
+             'field'      : 'node-label',
+             'completion'   : 'tunnel-node-label-completion',
+             'type'         : 'label',
+             'other'        : 'switches|label',
+#             'data-handler' : 'alias-to-value',
+             'help-name'    : 'Segment label',
+             'action'       : (
+                                {
+                                    'proc' : 'create-tunnel',
+                                },
+                              ),
+         },
+         {
+            'optional' : True,
+            'optional-for-no' : True,
+            'args' : TUNNEL_ADJACENCY_INFO,
+         },
+    )
+}
+
 SWITCH_TUNNEL_COMMAND_DESCRIPTION = {
     'name'                : 'show',
     'mode'                : 'login',
diff --git a/cli/sdncon/controller/models.py b/cli/sdncon/controller/models.py
index 25f715c..88ac7ad 100755
--- a/cli/sdncon/controller/models.py
+++ b/cli/sdncon/controller/models.py
@@ -64,21 +64,6 @@
     """
     return int(time.time()*1000000)
 
-class TunnelPathSeqId(models.Model):
-
-    pathid_seq = models.IntegerField(
-        primary_key=True,
-        verbose_name = 'Path Id Seq',
-        help_text='ID of this Tunnel Path Entry')
-
-    def __unicode__ (self):
-        return self.pathid_seq
-
-    class Rest:
-        NAME = 'tunnel-pathid-seq'
-        FIELD_INFO = (
-        )
-            
 class Tunnel(models.Model):
 
     id_max_length = 64
@@ -108,9 +93,6 @@
     def __unicode__ (self):
         return self.tunnel_id
     
-    class CassandraSettings:
-        COMPOUND_KEY_FIELDS = ('tunnel_id')
-
     def delete(self):
         super(Tunnel, self).delete()
     class Rest:
@@ -120,7 +102,7 @@
             {'name': 'path_seq',     'rest_name': 'path-seq'},
             )
 
-class SRPolicy(models.Model):
+class Policy(models.Model):
 
     id_max_length = 64
     #
@@ -136,21 +118,25 @@
         validators   = [ TenantNameValidator() ],
         max_length   = id_max_length)
     
+    sr_policy_type = models.CharField(
+        verbose_name = 'SR Policy Type',
+        help_text    = 'Type of SR Policy',
+        validators   = [ TenantNameValidator() ],
+        max_length   = id_max_length)
     #
     # end fields ----------------------------------------
 
     def __unicode__ (self):
-        return self.tunnel_id
+        return self.sr_policy_id
     
-    class CassandraSettings:
-        COMPOUND_KEY_FIELDS = ('sr_policy_id')
-
     def delete(self):
-        super(Tunnel, self).delete()
+        super(Policy, self).delete()
+
     class Rest:
         NAME = 'policy-config'
         FIELD_INFO = (
             {'name': 'sr_policy_id',    'rest_name': 'policy-id'},
+            {'name': 'sr_policy_type',    'rest_name': 'policy-type'},
             )
 
 #