Adding ONOS Segment Routing CLI files to new repo
diff --git a/cli/desc/__init__.py b/cli/desc/__init__.py
new file mode 100755
index 0000000..9ab2783
--- /dev/null
+++ b/cli/desc/__init__.py
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
diff --git a/cli/desc/version200/__init__.py b/cli/desc/version200/__init__.py
new file mode 100755
index 0000000..9ab2783
--- /dev/null
+++ b/cli/desc/version200/__init__.py
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
diff --git a/cli/desc/version200/address_space.py b/cli/desc/version200/address_space.py
new file mode 100755
index 0000000..9dfe17f
--- /dev/null
+++ b/cli/desc/version200/address_space.py
@@ -0,0 +1,637 @@
+#
+# Copyright (c) 2011,2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+import fmtcnv
+'''
+def address_space_origin_external (data):
+ """
+ Return origin-name when the address space wasn't created by the cli,
+ return None otherwise.
+ """
+ pk = command.mi.pk('address-space')
+ if not pk in data:
+ return;
+
+ address_space = command.sdnsh.get_table_from_store('address-space', pk,
+ data[pk])
+ if len(address_space) == 0:
+ return None
+
+ local = ['cli', 'rest']
+ if 'origin' in address_space[0] and not address_space[0]['origin'] in local:
+ return address_space[0]['origin']
+ return None
+
+
+def address_space_warn_external_config (data):
+ """
+ From the named address-space, look up the entry, if it exists in the
+ database, validate the 'origin' is either null, or 'cli',
+ otherwise provide a warning about this particular address-space
+ (along with the originator name)
+ """
+ external_origin = address_space_origin_external(data)
+ if external_origin:
+ command.sdnsh.warning(
+ 'address-space %s may not be intended for cli update, '
+ 'origin/creator "%s" ' % (data['name'], external_origin))
+
+
+command.add_action('address-space-warn-external-config',
+ address_space_warn_external_config,
+ {'kwargs': {'data' : '$data',}})
+
+
+def address_space_confirm_external_delete (data):
+ """
+ From the named address-space, look up the entry, if it exists in the
+ database, validate the 'origin' is either null, or 'cli',
+ otherwise provide a warning about this particular address-space
+ (along with the originator name)
+ """
+ external_origin = address_space_origin_external(data)
+ if external_origin:
+ confirm = command.action_registry['confirm'][0] # XXX accessor?
+ confirm('address-space %s may not be intended for cli delete, '
+ 'origin/creator "%s"\nEnter y or yes to continue delete: '
+ % (data['name'], external_origin))
+
+command.add_action('address-space-confirm-external-delete',
+ address_space_confirm_external_delete,
+ {'kwargs': {'data' : '$data',}})
+'''
+"""
+#
+# ----------------------------------------------------------------------
+# address-space submode configuration commands
+#
+
+#
+# conf: [no] address-space <address-space-name>
+#
+ADDRESS_SPACE_COMMAND_DESCRIPTION = {
+ 'name' : 'address-space',
+ 'help' : 'Enter Address-space submode',
+ 'mode' : 'config*',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'address-space',
+ 'submode-name' : 'config-address-space',
+ 'short-help' : 'Enter address space submode',
+ 'doc' : 'address-space|address-space',
+ 'doc-example' : 'address-space|address-space-example',
+ 'args' : (
+ {
+ 'field' : 'name',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ 'syntax-help' : 'Enter an address-space name',
+ 'doc' : 'address-space|identifier',
+ 'doc-include' : [ 'type-doc' ],
+ 'action' : (
+ {
+ 'proc' : 'address-space-warn-external-config',
+ },
+ {
+ 'proc' : 'push-mode-stack',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'address-space-confirm-external-delete',
+ },
+ {
+ 'proc' : 'delete-objects',
+ },
+ )
+ }
+ ),
+}
+
+#
+# conf/address-space <as>/active {True | False}
+#
+ADDRESS_SPACE_ACTIVE_COMMAND_DESCRIPTION = {
+ 'name' : 'active',
+ 'short-help' : 'Set address-space active',
+ 'mode' : 'config-address-space',
+ 'doc' : 'address-space|active',
+ 'doc-example' : 'address-space|active-example',
+ 'doc-include' : [ 'default' ],
+ 'args' : (),
+ 'action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : True },
+ 'syntax-help' : 'mark the address-space as active',
+ }
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : False },
+ 'syntax-help' : 'mark the address-space as inactive',
+ }
+ )
+}
+
+#
+# conf/address-space <as>/origin {cli | rest | ... }
+#
+ADDRESS_SPACE_ORIGIN_COMMAND_DESCRIPTION = {
+ 'name' : 'origin',
+ 'short-help' : 'Describe address-space origin',
+ 'mode' : 'config-address-space',
+ 'command-type' : 'config',
+ 'doc' : 'address-space|origin',
+ 'doc-example' : 'address-space|origin-example',
+ 'args' : (
+ {
+ 'field' : 'origin',
+ 'type' : 'string',
+ 'action' : (
+ {
+ 'proc' : 'address-space-warn-external-config',
+ },
+ {
+ 'proc' : 'write-fields',
+ },
+ ),
+ },
+ ),
+}
+
+#
+# conf/address-space <as>/priority <pri>
+#
+ADDRESS_SPACE_PRIORITY_COMMAND_DESCRIPTION = {
+ 'name' : 'priority',
+ 'short-help' : 'Set address-space priority',
+ 'mode' : 'config-address-space',
+ 'command-type' : 'config',
+ 'doc' : 'address-space|priority',
+ 'doc-example' : 'address-space|priority-example',
+ 'doc-include' : [ 'range', 'default' ],
+ 'args' : (
+ {
+ 'field' : 'priority',
+ 'base-type' : 'integer',
+ 'range' : (0, 65535),
+ }
+ )
+}
+"""
+
+def address_space_check_unique_vlan(data):
+ """
+ Peek to see if the vlan is in use by any other address-space
+ """
+ vlan_field = 'vlan-tag-on-egress'
+ in_use = command.sdnsh.get_table_from_store('address-space',
+ vlan_field,
+ str(data[vlan_field]))
+ vlan_field = 'vlan-tag-on-egress'
+ if len(in_use) > 0:
+ current_as = command.sdnsh.get_current_mode_obj()
+ other_as = [x['name'] for x in in_use if x['name'] != current_as]
+ if len(other_as):
+ command.sdnsh.warning(
+ 'vlan %s currently in use by other address-spaces: %s' %
+ (data[vlan_field], ', '.join(other_as)))
+
+
+command.add_action('address-space-check-unique-vlan',
+ address_space_check_unique_vlan,
+ {'kwargs': {'data' : '$data',}})
+
+"""
+#
+# conf/address-space <as>/vlan-tag-on-egress <tag>
+#
+ADDRESS_SPACE_VLAN_TAG_ON_EGRESS_COMMAND_DESCRIPTION = {
+ 'name' : 'vlan-tag-on-egress',
+ 'short-help' : 'Egress VLAN tag',
+ 'mode' : 'config-address-space',
+ 'command-type' : 'config',
+ 'doc' : 'address-space|vlan-tag-on-egress',
+ 'doc-example' : 'address-space|vlan-tag-on-egress-example',
+ 'args' : (
+ {
+ 'field' : 'vlan-tag-on-egress',
+ 'base-type' : 'integer',
+ 'range' : (1, 4096),
+ 'action' : (
+ {
+ 'proc' : 'address-space-check-unique-vlan',
+ },
+ {
+ 'proc' : 'write-fields',
+ },
+ ),
+ }
+ )
+}
+
+#
+# conf/address-space <as>/description <descr>
+#
+ADDRESS_SPACE_DESCRIPTION_COMMAND_DESCRIPTION = {
+ 'name' : 'description',
+ 'short-help' : 'Provide description for this address-space',
+ 'mode' : 'config-address-space',
+ 'command-type' : 'config',
+ 'doc' : 'address-space|description',
+ 'doc-example' : 'address-space|description-example',
+ 'args' : (
+ {
+ 'field' : 'description',
+ 'type' : 'string',
+ }
+ ),
+}
+
+#
+# conf/address-space <as>/identifier-rule <ir>
+#
+ADDRESS_SPACE_IDENTIFIER_RULE_COMMAND_DESCRIPTION = {
+ 'name' : 'identifier-rule',
+ 'short-help' : 'Set an address-space identifier rule',
+ 'mode' : 'config-address-space*',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'address-space-identifier-rule',
+ 'parent-field' : 'address-space',
+ 'submode-name' : 'config-address-space-id-rule',
+ 'doc' : 'address-space|identifier-rule',
+ 'doc-example' : 'address-space|identifier-rule-example',
+ 'args' : (
+ {
+ 'field' : 'rule',
+ 'type' : 'identifier',
+ 'syntax-help' : 'Enter an address-space identifier rule name',
+ 'completion' : 'complete-object-field',
+ 'doc-include' : [ 'type-doc' ],
+ 'doc' : 'address-space|id-rule-identifier',
+ 'scoped' : True,
+ }
+ )
+}
+
+#
+# ----------------------------------------------------------------------
+# address-space identifier rules submode
+#
+
+#
+# conf/address-space <as>/identifier-rule <ir>/active {True | False}
+#
+ADDRESS_SPACE_ID_ACTIVE_COMMAND_DESCRIPTION = {
+ 'name' : 'active',
+ 'mode' : 'config-address-space-id-rule',
+ 'short-help' : 'Set rule to Active',
+ 'command-type' : 'config',
+ 'doc' : 'address-space|id-active',
+ 'doc-example' : 'address-space|id-active-example',
+ 'doc-include' : [ 'default' ],
+ 'args' : (),
+ 'action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : True }
+ }
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : False }
+ }
+ )
+}
+
+#
+# conf/address-space <as>/identifier-rule <ir>/description <descr>
+#
+ADDRESS_SPACE_ID_DESCRIPTION_COMMAND_DESCRIPTION = {
+ 'name' : 'description',
+ 'short-help' : 'Provide description for identifier rule',
+ 'mode' : 'config-address-space-id-rule',
+ 'command-type' : 'config',
+ 'doc' : 'address-space|id-description',
+ 'doc-example' : 'address-space|id-description-example',
+ 'args' : (
+ {
+ 'field' : 'description',
+ 'type' : 'string',
+ }
+ ),
+}
+
+#
+# conf/address-space <as>/identifier-rule <ir>/priority <pri>
+#
+ADDRESS_SPACE_ID_PRIORITY_COMMAND_DESCRIPTION = {
+ 'name' : 'priority',
+ 'short-help' : 'Describe priority for identifier rule',
+ 'mode' : 'config-address-space-id-rule',
+ 'command-type' : 'config',
+ 'doc' : 'address-space|id-priority',
+ 'doc-include' : [ 'range', 'default' ],
+ 'doc-example' : 'address-space|id-priority-example',
+ 'args' : (
+ {
+ 'field' : 'priority',
+ 'value' : 'integer',
+ }
+ ),
+}
+
+#
+# conf/address-space <as>/identifier-rule <ir>/switch <swt-dpid>
+#
+ADDRESS_SPACE_ID_MATCH_SWITCH_COMMAND_DESCRIPTION = {
+ 'name' : 'match',
+ 'short-help' : 'Associate switch with identifier rule',
+ 'all-help' : 'Configure a match for this identifier rule',
+ 'mode' : 'config-address-space-id-rule',
+ 'command-type' : 'config',
+ 'obj-type' : 'address-space-identifier-rule',
+ 'doc-all' : 'address-space|match',
+ 'doc-example' : 'address-space|match-switch-example',
+ 'data' : { # for no command reset
+ 'switch' : None,
+ 'ports' : None,
+ },
+ 'args' : (
+ {
+ 'token' : 'switch',
+ 'doc' : 'address-space|match-switch',
+ },
+ {
+ # constructed as args to ensure that the ports isn't
+ # completed along with swtich values for 'no match switch'
+ 'optional-for-no' : True,
+ 'args' : (
+ {
+ 'field' : 'switch',
+ 'type' : 'string',
+ 'parent-field' : None,
+ 'completion' : [
+ 'complete-object-field',
+ 'complete-alias-choice',
+ ],
+ 'help-name' : 'switch dpid or switch alias',
+ 'data-handler' : 'alias-to-value',
+ 'other' : 'switches|dpid',
+ },
+ {
+ 'field' : 'ports',
+ 'optional' : True,
+ 'type' : 'string',
+ 'help-name' : 'switch interface, or range, or list',
+ 'completion' : 'complete-interface-list',
+ 'optional-for-no' : True,
+ 'doc' : 'address-space|match-switch-ports',
+ },
+ ),
+ },
+ ),
+}
+
+
+#
+# conf/address-space <as>/identifier-rule <ir>/tag <name-val-pair>
+#
+ADDRESS_SPACE_ID_MATCH_TAG_COMMAND_DESCRIPTION = {
+ 'name' : 'match',
+ 'short-help' : 'Associate tag with identifier rule',
+ 'mode' : 'config-address-space-id-rule',
+ 'command-type' : 'config',
+ 'data' : { # for no command reset
+ 'tag' : None,
+ },
+ 'doc-example' : 'address-space|match-tag-example',
+ 'args' : (
+ {
+ 'token' : 'tags',
+ 'doc' : 'address-space|match-tag',
+ },
+ {
+ 'field' : 'tag',
+ 'type' : 'string',
+ 'optional-for-no' : True,
+ }
+ )
+}
+
+#
+# conf/address-space <as>/identifier-rule <ir>/vlans <vl>
+#
+ADDRESS_SPACE_ID_MATCH_VLANS_COMMAND_DESCRIPTION = {
+ 'name' : 'match',
+ 'short-help' : 'Associate vlans with identifier rule',
+ 'mode' : 'config-address-space-id-rule',
+ 'command-type' : 'config',
+ 'data' : { # for no command reset
+ 'vlans' : None,
+ },
+ 'doc-example' : 'address-space|match-vlan-example',
+ 'args' : (
+ {
+ 'token' : 'vlans',
+ 'doc' : 'address-space|match-vlan',
+ },
+ {
+ 'field' : 'vlans',
+ 'value' : 'string',
+ 'help-name' : 'Vlan number (1-4095) or range, or list',
+ 'optional-for-no' : True,
+ }
+ ),
+}
+
+#
+# ----------------------------------------------------------------------
+# show address-space commands
+#
+
+#
+# show address-space <cr>
+#
+ADDRESS_SPACE_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'address-space',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'all-help' : 'Show address space information',
+ 'short-help' : 'Show all address spaces',
+ 'doc' : 'address-space|show',
+ 'doc-example' : 'address-space|show-example',
+ 'args' : (
+ 'address-space',
+ ),
+}
+
+#
+# show address-space <as> [brief | details] <cr>
+#
+ADDRESS_SPACE_SHOW_ID_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'address-space',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'short-help' : 'Show a specific address space',
+ 'doc' : 'address-space|show-id',
+ 'doc-example' : 'address-space|show-id-example',
+ 'args' : (
+ 'address-space',
+ {
+ 'choices' : (
+ {
+ 'field' : 'name',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ 'help-name' : "address-space-name",
+ },
+ {
+ 'field' : 'name',
+ 'type' : 'enum',
+ 'values' : 'all',
+ }
+ ),
+ },
+ {
+ 'field' : 'detail',
+ 'optional' : True,
+ 'type' : 'enum',
+ 'values' : ('details', 'brief'),
+ 'doc' : 'format|+',
+ }
+ )
+}
+
+#
+# show address-space <as> [ identifier-rules ] ...
+#
+ADDRESS_SPACE_SHOW_ID_DETAILS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'address-space',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'short-help' : 'Show the configured identifier-rules for a specific address space',
+ 'doc' : 'address-space|show-id-rules',
+ 'doc-example' : 'address-space|show-id-rules-example',
+ 'args' : (
+ 'address-space',
+ {
+ 'choices' : (
+ {
+ 'field' : 'name',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ 'help-name' : "address-space-name",
+ },
+ {
+ 'field' : 'name',
+ 'type' : 'enum',
+ 'values' : 'all',
+ }
+ ),
+ },
+ {
+ # show address-space <as> { identifier-rules }
+ 'choices' : (
+ {
+ 'field' : 'identifier-rules',
+ 'type' : 'enum',
+ 'values' : 'identifier-rules',
+ 'action' : 'display-table',
+ 'obj-type' : 'address-space-identifier-rule',
+ },
+ )
+ }
+ ),
+}
+
+#
+# FORMATS
+# perhaps these ought be moved next to their respective show commands
+#
+
+ADDRESS_SPACE_FORMAT = {
+ 'address-space' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'name', 'active', 'priority',
+ 'vlan-tag-on-egress'],
+ 'address-space-config' : ['Idx', 'name', 'active',
+ 'vlan-tag-on-egress'],
+ 'brief' : ['Idx', 'name', 'vlan-tag-on-egress'],
+ 'details' : ['Idx', 'name', 'active', 'priority',
+ 'description', 'vlan-tag-on-egress'],
+ },
+ 'fields' : {
+ 'name' : { 'verbose-name' : 'Address Space',
+ },
+ 'active' : {
+ },
+ 'priority' : {
+ },
+ 'vlan-tag-on-egress': {
+ 'verbose-name' : 'Vlan Tag on Egress',
+ },
+ 'description' : {
+ },
+ }
+ },
+}
+
+
+ADDRESS_SPACE_IDENTIFIER_RULE_FORMAT = {
+ 'address-space-identifier-rule' : {
+ 'field-orderings': {
+ 'default' : [ 'Idx', 'address-space', 'rule',
+ 'active', 'priority', 'switch', 'ports',
+ 'tag', 'vlans'
+ ],
+ 'address-space-config' : [ 'Idx', 'rule', 'description',
+ 'active', 'priority', 'switch', 'ports',
+ 'tag', 'vlans'
+ ],
+ },
+ 'fields': {
+ 'rule' : { 'verbose-name' : 'Address Space Rule ID',
+ },
+ 'address-space' : {
+ 'verbose-name' : 'Address Space'
+ },
+ 'active' : {
+ },
+ 'description' : {
+ },
+ 'ports' : {
+ },
+ 'priority' : {
+ },
+ 'rule' : {
+ },
+ 'switch' : {
+ },
+ 'tag' : {
+ },
+ 'vlans' : {
+ },
+ }
+ },
+}
+"""
diff --git a/cli/desc/version200/address_space_model.py b/cli/desc/version200/address_space_model.py
new file mode 100755
index 0000000..91046aa
--- /dev/null
+++ b/cli/desc/version200/address_space_model.py
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_enable_cascade_delete('address-space')
+command.model_obj_type_enable_cascade_delete('address-space-identifier-rule')
+
+command.model_obj_type_disable_submode('address-space')
+command.model_obj_type_disable_submode('address-space-identifier-rule')
+
+command.model_obj_type_disable_edit('address-space', 'active')
+command.model_obj_type_disable_edit('address-space', 'description')
+command.model_obj_type_disable_edit('address-space', 'priority')
+command.model_obj_type_disable_edit('address-space', 'vlan-tag-on-egress')
+command.model_obj_type_disable_edit('address-space', 'origin')
+
+command.model_obj_type_disable_edit('address-space-identifier-rule', 'rule')
+command.model_obj_type_disable_edit('address-space-identifier-rule', 'active')
+command.model_obj_type_disable_edit('address-space-identifier-rule', 'ports')
+command.model_obj_type_disable_edit('address-space-identifier-rule', 'mac')
+command.model_obj_type_disable_edit('address-space-identifier-rule', 'priority')
+command.model_obj_type_disable_edit('address-space-identifier-rule', 'switch')
+command.model_obj_type_disable_edit('address-space-identifier-rule', 'tag')
+command.model_obj_type_disable_edit('address-space-identifier-rule', 'vlans')
diff --git a/cli/desc/version200/address_space_run_config.py b/cli/desc/version200/address_space_run_config.py
new file mode 100755
index 0000000..c68bc1b
--- /dev/null
+++ b/cli/desc/version200/address_space_run_config.py
@@ -0,0 +1,293 @@
+#
+# Copyright (c) 2012,2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# address_space_run_config.py
+#
+# show running address-space [as]
+#
+
+import run_config
+import command
+import fmtcnv
+import utif
+import sys
+from midw import *
+
+def address_space_running_config_include_field(context, config,
+ address_space, obj_type, field, value, indent, prefix = ""):
+ """
+ Identify fields of obj_types who's values differ from the default
+ values, since these need to be included into the running-config
+ """
+ if context.mi.not_default_value(obj_type, field, value):
+ if context.mi.is_field_string(obj_type, field):
+ config.append(' ' * (indent + indent) + prefix + field +
+ " %s\n" % utif.quote_string(value))
+ else:
+ config.append(' ' * (indent + indent) + prefix + field +
+ ' %s\n' % value)
+
+#
+# address_space_running_config_details
+#
+# Show an address-space configuration in detail
+#
+def address_space_running_config_details (context, config, address_space):
+ """
+ Display the details for the fields of a address_space which may have
+ non-default values.
+ """
+
+ #
+ # 'active' is True by default. Prepend 'no' into the generated config
+ # if this item is not active.
+ #
+ if address_space['active'] != \
+ context.mi.field_default_value('address-space', 'active'):
+ config.append(' no active\n')
+
+ #
+ # Show the rest of the fields
+ #
+ address_space_fields = ['description', 'origin', 'priority',
+ 'vlan-tag-on-egress']
+
+ for field in sorted(address_space_fields):
+ address_space_running_config_include_field(context, config,
+ address_space, 'address-space', field,
+ address_space.get(field,''), 1)
+
+#
+# address_space_running_config_id_rule
+#
+# Generate indentifier-rule under address-space configuration
+#
+def address_space_running_config_id_rule (context, config, address_space,
+ address_space_id_rule_entries):
+
+ #
+ # Iterate through each identifier-rule and show its contents
+ #
+ for rule in address_space_id_rule_entries:
+
+ #
+ # Show the rule header line
+ #
+ config.append(' identifier-rule %s\n' % rule['rule'])
+
+ #
+ # Iterate through each field configurable and generate the config
+ # if present.
+ #
+ for field in ['description', 'active', 'priority']:
+ address_space_running_config_include_field(context, config,
+ address_space, 'address-space-identifier-rule', field,
+ rule.get(field, ''), 2)
+
+ for field in ['vlans', 'tag']:
+ address_space_running_config_include_field(context, config,
+ address_space, 'address-space-identifier-rule', field,
+ rule.get(field, ''), 2, "match ")
+
+ #
+ # Manage switch and ports differently, placing both on the
+ # same line when ports exist, and replacing the switch alias
+ # when its available.
+ if 'switch' in rule:
+ dpid_or_alias = alias_lookup_with_foreign_key('switch-alias',
+ rule['switch'])
+ if dpid_or_alias == None:
+ dpid_or_alias = rule['switch'] # dpid
+ if 'ports' in rule:
+ config.append(' match switch %s %s\n' % \
+ (dpid_or_alias, rule['ports']))
+ else:
+ config.append(' match switch %s\n' % dpid_or_alias)
+
+ #
+ # This configuration section complete, print the trailer.
+ #
+
+
+#
+# running_config_specific_address_space
+#
+# Show running configuration of one particular address-space
+#
+def running_config_specific_address_space (context, config, address_space_name):
+
+ #
+ # Have a temporary holder to store generated configuration.
+ #
+ tmp_config = [ ]
+
+ #
+ # Retrieve the configuration from the data store. Catch all possible
+ # exceptions and report back as appropriate.
+ #
+ try:
+ address_space = context.get_object_from_store(
+ 'address-space', address_space_name)
+ except:
+
+ #
+ # This particular address-space is not available in the
+ # data base. Report error back.
+ #
+ return ('Error: no address-space name %s, Error %s' % \
+ (address_space_name, sys.exc_info()[0]))
+
+ #
+ # Show the configured sub items under this address-space.
+ #
+ address_space_running_config_details(context, tmp_config, address_space)
+
+ #
+ # Retrieve all the identifier rules configured. There may not be any
+ # rule present. Handle it gracefully.
+ #
+ address_space_rules = None
+ try:
+ address_space_rules = context.get_table_from_store(
+ 'address-space-identifier-rule',
+ 'address-space',
+ address_space_name, "exact")
+ except Exception:
+ pass
+
+ #
+ # Show each rule configured in detail
+ #
+ if address_space_rules:
+ address_space_running_config_id_rule(context, tmp_config, address_space,
+ address_space_rules)
+
+ #
+ # Don't shown empty configuration for default address-space.
+ #
+ if len(tmp_config) > 0 or address_space['name'] != 'default':
+ config.append("address-space %s\n" % address_space_name)
+ config += tmp_config
+
+#
+# running_config_address_space
+#
+# Show running configuration for 'all' address-space configured
+#
+def running_config_address_space (context, config, words):
+ """
+ Add the Address Space configuration detils
+ """
+
+ #
+ # Check if this is request for a specific address-space
+ #
+ if len(words) > 0:
+ return running_config_specific_address_space(context, config, words[0])
+
+ #
+ # Retrieve all address-space configurations
+ #
+ address_space_list = None
+ try:
+ address_space_list = \
+ context.get_table_from_store('address-space')
+ except Exception:
+ pass
+
+ #
+ # Retrieve all address-spaces' identifier rules
+ #
+ address_space_rules = None
+ try:
+ address_space_rules = \
+ context.get_table_from_store('address-space-identifier-rule')
+ except Exception:
+ pass
+
+ #
+ # Walk each address-space found and print its contents
+ #
+ if address_space_list:
+ for address_space in address_space_list:
+ tmp_config = [ ]
+
+ #
+ # Now print its contents in details
+ #
+ address_space_running_config_details(context, tmp_config,
+ address_space)
+
+ #
+ # If there is any identifier-rule configured, show each of them.
+ #
+ if address_space_rules:
+ address_space_running_config_id_rule(context, tmp_config,
+ address_space,
+ [rule for rule in address_space_rules \
+ if rule['address-space'] == address_space['name']])
+
+
+ #
+ # Don't shown empty configuration for default address-space.
+ #
+ if len(tmp_config) > 0 or address_space['name'] != 'default':
+ config.append("!\naddress-space %s\n" % address_space['name'])
+ config += tmp_config
+
+#
+# address_space_running_config_tuple
+#
+# address-space configuration tuple that we intend to process wrt
+# generating their running configuration
+#
+address_space_running_config_tuple = (
+ (
+ #
+ # show running-configuration address-space
+ #
+ {
+ 'optional' : False,
+ 'field' : 'running-config',
+ 'type' : 'enum',
+ 'values' : 'address-space',
+ 'short-help' : 'Configuration for address spaces',
+ 'doc' : 'running-config|show-address-space',
+ },
+
+ #
+ # show running-configuration address-space <address-space>
+ #
+ {
+ 'field' : 'word',
+ 'type' : 'identifier',
+ 'completion' : 'complete-from-another',
+ 'other' : 'address-space|name',
+ 'parent-field' : None,
+ 'action' : 'legacy-cli',
+ 'optional' : True,
+ }
+ ),
+)
+
+#
+# Register with run_config module, our callback to process running configs for
+# address-space configuration items
+#
+run_config.register_running_config('address-space', 4000, None,
+ running_config_address_space,
+ address_space_running_config_tuple)
+
diff --git a/cli/desc/version200/controller_node.py b/cli/desc/version200/controller_node.py
new file mode 100755
index 0000000..4c71c5b
--- /dev/null
+++ b/cli/desc/version200/controller_node.py
@@ -0,0 +1,1078 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+import fmtcnv
+"""
+CONTROLLER_NODE_FORMAT = {
+ 'controller-node' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'Idx',
+ 'alias',
+ 'me',
+ 'ha-role',
+ 'change-date-time',
+ 'change-description',
+ 'status',
+ 'uptime',
+ 'errors'
+ #'domain-lookups-enabled',
+ #'logging-enabled',
+ ],
+ 'brief' : [
+ 'Idx',
+ 'alias',
+ 'me',
+ 'ha-role',
+ 'change-date-time',
+ 'change-description',
+ 'status',
+ 'uptime',
+ 'errors',
+ ],
+ 'details' : [
+ 'Idx',
+ 'alias',
+ 'id',
+ 'me',
+ 'ha-role',
+ 'change-date-time',
+ 'change-description',
+ 'status',
+ 'uptime',
+ 'errors',
+ 'domain-lookups-enabled', 'domain-name-servers',
+ 'domain-name', 'default-gateway',
+ 'ntp-server', 'time-zone',
+ 'logging-enabled', 'logging-server',
+ ],
+ 'without-vns' : [
+ 'Idx',
+ 'id',
+ 'me',
+ 'alias',
+ 'ha-role',
+ 'change-date-time',
+ 'change-description',
+ 'uptime',
+ 'domain-lookups-enabled', 'domain-name-servers',
+ 'domain-name', 'default-gateway',
+ 'ntp-server', 'time-zone',
+ 'logging-enabled', 'logging-server', 'logging-level',
+ ]
+ },
+ 'fields': {
+ 'id' : {
+ 'verbose-name' : 'Controller ID',
+ },
+ 'me' : {
+ 'verbose-name' : '@',
+ 'formatter' : fmtcnv.controller_node_me,
+ 'entry-formatter' : fmtcnv.controller_node_me_entry
+ },
+ 'domain-lookups-enabled' : {
+ 'verbose-name' : 'DNS',
+ 'formatter' : fmtcnv.replace_boolean_with_enable_disable,
+ },
+ 'domain-name-servers' : {
+ 'verbose-name' : 'DNS Servers',
+ 'formatter' : fmtcnv.print_domain_name_servers,
+ 'entry-formatter' : fmtcnv.print_all_domain_name_servers,
+ },
+ 'domain-name' : {
+ },
+ 'default-gateway' : {
+ },
+ 'ntp-server' : {
+ },
+ 'time-zone' : {
+ },
+ 'logging-enabled' : { 'verbose-name' : 'Logging',
+ 'formatter' : fmtcnv.replace_boolean_with_enable_disable,
+ },
+ 'logging-server' : {
+ },
+ 'logging-level' : {
+ },
+ 'ha-role' : {
+ 'verbose-name' : 'HA Role',
+ },
+ 'change-date-time' : {
+ 'verbose-name' : 'HA Last Change Time',
+ 'formatter' : fmtcnv.print_time_since_utc_timestr,
+ },
+ 'change-description' : {
+ 'verbose-name' : 'HA Change Reason',
+ },
+ 'uptime' : {
+ 'verbose-name' : 'Uptime',
+ 'formatter' : fmtcnv.print_timesince_msec_since
+ },
+ },
+ },
+}
+
+controller_node_show_actions = (
+ {
+ 'proc' : 'query-table',
+ },
+ {
+ 'proc' : 'join-table',
+ 'obj-type' : 'controller-alias',
+ 'key' : 'controller',
+ 'join-field' : 'id', # field in queried items
+ },
+ {
+ 'proc' : 'join-rest',
+ 'url' : 'system/controller',
+ 'rest-type' : 'dict-with-id',
+ 'key' : 'id',
+ 'join-field' : 'id',
+ 'add-field' : 'me',
+ },
+ # need a description mechanism to join ha-role, which
+ # needs to send urls to controller-node interfaces
+ # ie: the rest actions alwaus use the local controller
+ # (uptime has the same issue)
+ {
+ 'proc' : 'display',
+ 'format' : 'controller-node',
+ },
+),
+
+
+CONTROLLER_NODE_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'controller-node',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'all-help' : 'Show controller node information',
+ 'short-help' : 'Show controller nodes summaries',
+ 'doc' : 'controller|show',
+ 'args' : (
+ {
+ 'token' : 'controller-node',
+ 'action' : controller_node_show_actions,
+ }
+ ),
+}
+CONTROLLER_NODE_INTERFACE_FORMAT = {
+ 'controller-interface' : {
+ 'field-orderings': {
+ 'default' : ['Idx',
+ 'controller',
+ 'type',
+ 'number',
+ 'mode',
+ 'ip',
+ 'discovered-ip',
+ 'netmask',
+ 'mac',
+ 'firewall']
+ },
+ 'fields' : {
+ 'controller' : {
+ 'formatter' : fmtcnv.replace_controller_node_with_alias,
+ },
+ 'number' : {
+ },
+ 'ifname' : {
+ 'formatter' : lambda i, data: '%s%s' % (data['type'],
+ data['number'])
+ },
+ 'ip' : {
+ },
+ 'discovered-ip' : { 'verbose-name' : 'Found IP',
+ },
+ 'mode' : {
+ },
+ 'netmask' : {
+ },
+ 'type' : {
+ },
+ 'firewall' : {
+ 'verbose-name' : 'Firewall',
+ },
+ }
+ },
+}
+
+
+CONTROLLER_NODE_SUMMARY_FORMAT = {
+ 'controller-summary' : {
+ 'field-orderings' : {
+ 'default' : [
+ '# inter-switch links',
+ '# hosts',
+ '# attachment points',
+ '# IP Addresses',
+ '# VNSes',
+ '# Access Control Lists',
+ '# VNS Interfaces with ACL applied',
+ '# VNS Interfaces',
+ ]
+ },
+
+ 'fields' : {
+ '# Access Control Lists' : { 'verbose-name' : 'Access Control Lists'
+ },
+ '# VNS Interfaces' : { 'verbose-name' : 'VNS Interfaces'
+ },
+ '# hosts' : { 'verbose-name' : 'Hosts'
+ },
+ '# VNSes' : { 'verbose-name' : 'VNSesx'
+ },
+ '# attachment points' : { 'verbose-name' : 'Attachment Points'
+ },
+ '# inter-switch links' : { 'verbose-name' : 'Links'
+ },
+ '# IP Addresses' : { 'verbose-name' : 'Ip Addresses'
+ },
+ '# VNS Interfaces with ACL applied' : { 'verbose-name' : 'VNS If with Acl Applied'
+ },
+ },
+ },
+}
+
+
+COTROLLER_NODE_SWITCHES_FORMAT = {
+ 'controller-switches' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'Idx', 'dpid',
+ ],
+ },
+ 'fields' : {
+ 'dpid' : { 'primary_key' : True,
+ 'verbose-name': 'Connected Switches',
+ 'formatter' : fmtcnv.print_switch_and_alias }
+ }
+ },
+
+}
+
+
+CONTROLLER_NODE_FIREWALL_RULE_FORMAT = {
+ 'firewall-rule' : {
+
+ 'field-orderings': {
+ 'default' : ['Idx',
+ 'controller',
+ 'type',
+ 'number',
+ 'src-ip',
+ 'vrrp-ip',
+ 'port',
+ 'proto',
+ 'rule']
+ },
+ 'fields' : {
+
+ 'controller' : {
+ 'formatter' : fmtcnv.replace_controller_node_with_alias,
+ },
+ 'interface' : {
+ },
+ 'port' : {
+ },
+ 'proto' : {
+ },
+ 'rule' : {
+ 'verbose-name' : 'Firewall Rule'
+ },
+ }
+ },
+}
+
+
+def controller_completion_add_localhost(completions, prefix):
+ if completions == None:
+ completions = {}
+ if not 'localhost ' in completions and 'localhost'.startswith(prefix) :
+ completions['localhost '] = 'Select currently logged in controller'
+
+
+command.add_completion('controller-add-localhost', controller_completion_add_localhost,
+ {'kwargs': { 'completions' : '$completions',
+ 'prefix' : '$text',
+ }})
+
+CONTROLLER_NODE_SHOW_ID_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'controller-node',
+ 'mode' : 'login',
+ 'short-help' : 'Show controller-node associated details by name',
+ 'no-supported' : False,
+ 'action' : controller_node_show_actions,
+ 'doc' : 'controller|show-details',
+ 'args' : (
+ 'controller-node',
+ {
+ 'choices' : (
+ {
+ 'field' : 'id',
+ 'type' : 'identifier',
+ 'completion' : [
+ 'complete-object-field',
+ 'controller-add-localhost',
+ ],
+ 'data-handler' : 'alias-to-value',
+ 'action' : controller_node_show_actions,
+ 'doc' : 'controller|show-id',
+ },
+ {
+ 'token' : 'all',
+ 'doc' : 'reserved|all',
+ }
+ ),
+
+ },
+ {
+ 'optional' : True,
+ 'choices' : (
+ {
+ 'token' : 'interfaces',
+ 'obj-type' : 'controller-interface',
+ 'action' : 'display-table',
+ 'short-help' : 'Show network interface information for controller node',
+ 'doc' : 'controller|show-interfaces',
+ },
+ {
+ 'token' : 'firewall',
+ 'obj-type' : 'firewall-rule',
+ 'action' : 'display-table',
+ 'short-help' : 'Show firewall rules for controller node',
+ 'doc' : 'controller|show-firewall',
+ },
+ {
+ 'token' : 'summary',
+ 'action' : 'display-rest',
+ 'url' : 'controller/summary',
+ 'rest-type' : 'dict',
+ 'format' : 'controller-summary',
+ 'short-help' : 'Show a summary of configuration for controller node',
+ 'doc' : 'controller|show-summary',
+ },
+ {
+ 'token' : 'switches',
+ 'action' : 'display-rest',
+ 'url' : 'controller/stats/switches',
+ 'format' : 'controller-switches',
+ 'short-help' : 'Show switches connected to controller node',
+ 'doc' : 'controller|show-switches',
+ },
+ {
+ 'token' : 'alias',
+ 'action' : 'display-table',
+ 'obj-type' : 'controller-alias',
+ 'short-help' : 'Show the alias for controller node',
+ 'doc' : 'controller|show-alias',
+ },
+ )
+ },
+ {
+ 'optional' : True,
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details','brief'),
+ 'doc' : 'controller|show-detail',
+ }
+ ),
+}
+
+CONTROLLER_NODE_SHOW_STATS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'controller-node',
+ 'mode' : 'login',
+ 'short-help' : 'Show statistics for a given controller node',
+ 'command-type' : 'display-table',
+ 'doc' : 'show-stats',
+ 'args' : (
+ 'controller-node',
+ {
+ 'choices' : (
+ {
+ 'field' : 'id',
+ 'type' : 'identifier',
+ 'completion' : [
+ 'complete-object-field',
+ 'controller-add-localhost',
+ ],
+ 'action' : 'display-table',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'controller|id',
+ },
+ {
+ 'field' : 'id',
+ 'type' : 'enum',
+ 'values' : 'all',
+ 'doc' : 'reserved|all',
+ }
+ ),
+ },
+ {
+ 'field' : 'stats',
+ 'type' : 'enum',
+ 'values' : 'stats',
+ 'obj-type' : 'controller-stats',
+ 'action' : 'legacy-cli',
+ },
+ ),
+}
+
+CONTROLLER_NODE_SHOW_OBJECT_STATS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'controller-node',
+ 'mode' : 'login',
+ 'short-help' : 'Show detailed controller-node related statistics',
+ 'command-type' : 'display-table',
+ 'args' : (
+ 'controller-node',
+ {
+ 'choices' : (
+ {
+ 'field' : 'id',
+ 'type' : 'identifier',
+ 'completion' : [
+ 'complete-object-field',
+ 'controller-add-localhost',
+ ],
+ 'action' : 'display-table',
+ 'data-handler' : 'alias-to-value',
+ },
+ {
+ 'field' : 'id',
+ 'type' : 'enum',
+ 'values' : 'all',
+ 'doc' : 'reserved|all',
+ }
+ ),
+ },
+ {
+ 'field' : 'stats',
+ 'type' : 'enum',
+ 'values' : 'stats',
+ 'obj-type' : 'controller-stats',
+ 'action' : 'legacy-cli',
+ },
+ {
+ 'field' : 'stats-type',
+ 'type' : 'enum',
+ 'values' : (
+ 'cpu-user',
+ 'disk-root',
+ 'mem-used',
+ 'mem-free',
+ 'cli-cpu',
+ 'database-cpu',
+ 'swap-used',
+ 'disk-boot',
+ 'statd-cpu',
+ 'cpu-system',
+ 'cpu-idle',
+ 'apache-cpu',
+ 'cpu-nice',
+ 'disk-log',
+ 'sdnplatform-cpu'
+ ),
+ 'doc' : 'controller|show-stats-type',
+ },
+ {
+ 'field' : 'start-time',
+ 'tag' : 'start-time',
+ 'type' : 'string',
+ 'short-help' : 'Start time for displaying the stats',
+ 'optional' : True,
+ 'doc' : 'controller|show-stats-start-time',
+ },
+ {
+ 'field' : 'end-time',
+ 'tag' : 'end-time',
+ 'type' : 'string',
+ 'short-help' : 'End time for displaying the stats',
+ 'optional' : True,
+ 'doc' : 'controller|show-stats-end-time',
+ },
+ {
+ 'field' : 'duration',
+ 'tag' : 'duration',
+ 'type' : 'string',
+ 'short-help' : 'Duration from the start or end for displaying the stats',
+ 'optional' : True,
+ 'doc' : 'controller|show-stats-duration',
+ },
+ {
+ 'field' : 'sample-interval',
+ 'tag' : 'sample-interval',
+ 'type' : 'integer',
+ 'short-help' : 'Spacing between sampling windows',
+ 'optional' : True,
+ 'doc' : 'controller|show-stats-sample-interval',
+ },
+ {
+ 'field' : 'sample-count',
+ 'tag' : 'sample-count',
+ 'type' : 'integer',
+ 'short-help' : 'Number of samples to show',
+ 'optional' : True,
+ 'doc' : 'controller|show-stats-sample-count',
+ },
+ {
+ 'field' : 'sample-window',
+ 'tag' : 'sample-window',
+ 'type' : 'integer',
+ 'optional' : True,
+ 'short-help' : 'Number of raw sample values to average around each down-sampled data point',
+ 'doc' : 'controller|show-stats-sample-window',
+ },
+ {
+ 'field' : 'data-format',
+ 'tag' : 'data-format',
+ 'type' : 'enum',
+ 'values' : ('value', 'rate'),
+ 'short-help' : 'Whether to display as a raw value or rate',
+ 'optional' : True,
+ 'doc' : 'controller|show-stats-data-format',
+ },
+ {
+ 'field' : 'display',
+ 'tag' : 'display',
+ 'type' : 'enum',
+ 'values' : ('latest-value',
+ 'graph',
+ 'table',
+ ),
+ 'short-help' : 'Display the latest value, a graph, or a table',
+ 'optional' : True,
+ 'doc' : 'controller|show-stats-display',
+ },
+ ),
+}
+
+CONTROLLER_INTERFACES_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'controller-interface',
+ 'short-help' : 'Show controller-node associated interfaces',
+ 'mode' : 'config-controller',
+ 'command-type' : 'display-table',
+ 'scoped' : True, # entries displayed filtered by pushed obj id
+ 'doc' : 'controller|show-interfaces',
+ 'args' : (
+ 'interfaces',
+ {
+ 'field' : 'type',
+ 'tag' : 'type',
+ 'type' : 'string',
+ 'optional' : True,
+ 'doc' : 'controller|show-interfaces-type',
+ },
+ {
+ 'field' : 'number',
+ 'tag' : 'number',
+ 'type' : 'integer',
+ 'optional' : True,
+ 'doc' : 'controller|show-interfaces-number',
+ },
+ )
+}
+
+
+CONTROLLER_NODE_SUBMODE_COMMAND_DESCRIPTION = {
+ 'name' : 'controller-node',
+ 'obj-type' : 'controller-node',
+ 'mode' : 'config*',
+ 'short-help' : 'Enter configuration submode for controller-nodes',
+ 'no-supported' : False, # don't allow removal of controller-nodes
+ # 'create' : False, # don't allow creation of new controller-nodes
+ 'command-type' : 'config-submode',
+ 'parent-field' : None,
+ 'current-mode-obj-id' : None,
+ 'submode-name' : 'config-controller',
+ 'doc' : 'controller|controller-node',
+ 'doc-example' : 'controller|controller-node-example',
+ 'args' : (
+ {
+ 'field' : 'id',
+ 'type' : 'identifier',
+ 'completion' : [
+ 'complete-alias-choice',
+ 'controller-add-localhost',
+ ],
+ 'data-handler' : 'alias-to-value',
+ 'optional-for-no' : False,
+ 'doc' : 'controller|controller-node-name',
+ }
+ )
+}
+
+
+CONTROLLER_NODE_ALIAS_COMMAND_DESCRIPTION = {
+ 'name' : 'controller-alias',
+ 'mode' : 'config-controller',
+ 'short-help' : 'Attach alias to controller',
+ 'command-type' : 'manage-alias',
+ 'obj-type' : 'controller-alias',
+ 'scoped' : True,
+ 'reserved' : 'localhost',
+ 'doc' : 'controller|alias',
+ 'args' : (
+ {
+ 'field' : 'alias',
+ 'optional-for-no' : True,
+ 'completion' : 'complete-object-field',
+ 'doc' : 'controller|alias-name',
+ 'action' : (
+ {
+ 'proc' : 'create-alias',
+ },
+ {
+ 'proc' : 'prompt-update',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'delete-alias',
+ },
+ {
+ 'proc' : 'prompt-update',
+ },
+ )
+ }
+ )
+}
+
+
+CONTROLLER_NODE_INTERFACE_COMMAND_DESCRIPTION = {
+ 'name' : 'interface',
+ 'new-style' : True,
+ 'mode' : 'config-controller*',
+ 'short-help' : 'Enter interface submode, configure controller interface',
+ 'command-type': 'config-submode',
+ 'submode-name': 'config-controller-if',
+ 'obj-type': 'controller-interface',
+ 'parent-field': 'controller',
+ 'doc' : 'controller|interface',
+ 'args': (
+ {
+ 'field' : 'type',
+ 'help-name' : 'interface-type',
+ 'type' : 'enum',
+ 'values' : ('Ethernet',),
+ 'syntax-help' : 'Enter the interface type (e.g. Ethernet)',
+ 'doc' : 'controller|interface-type',
+ },
+ {
+ 'field' : 'number',
+ 'help-name' : 'interface-number',
+ 'base-type' : 'integer',
+ 'range' : (0,1000000),
+ #'completion' : 'complete-object-field',
+ 'syntax-help' : 'Enter the interface number, a small non-negative number (e.g. 0 or 1)',
+ 'doc' : 'controller|interface-number',
+ }
+ ),
+ 'no-action': ('begin-default-gateway-check', 'delete-objects', 'end-default-gateway-check'),
+}
+
+CONTROLLER_NODE_DOMAIN_NAME_SERVER_FORMAT = {
+ 'controller-domain-name-server' : {
+ 'field-orderings': {
+ 'default' : ['Idx', 'id', 'controller', 'priority', 'ip']
+ },
+ 'fields' : {
+ 'ip' : {
+ },
+ 'controller' : {
+ 'formatter' : fmtcnv.replace_controller_node_with_alias,
+ },
+ }
+ },
+}
+
+CONTROLLER_IP_COMMAND_DESCRIPTION = {
+ 'name' : 'ip',
+ 'mode' : 'config-controller',
+ 'short-help' : 'Associate dns, default gateway with the controller node',
+ 'doc' : 'controller|ip',
+ 'args' : {
+ 'choices': (
+ {
+ 'command-type': 'config',
+ 'obj-type': 'controller-node',
+ 'doc': 'controller|ip-domain',
+ 'args': (
+ 'domain',
+ {
+ 'choices': (
+ {
+ 'field' : 'domain-lookups-enabled',
+ 'token' : 'lookup',
+ 'type' : 'boolean',
+ 'doc' : 'controller|ip-domain-lookups',
+ 'no-action' : {
+ 'proc' : 'write-fields',
+ 'data' : {
+ 'domain-lookups-enabled' : False,
+ },
+ },
+ },
+ {
+ 'field': 'domain-name',
+ 'tag': 'name',
+ 'type': 'domain-name',
+ 'syntax-help': "Enter the network's domain name",
+ 'default-for-no': 'xyz.com',
+ 'doc': 'controller|ip-domain-name',
+ },
+ ),
+ },
+ ),
+ },
+ (
+ {
+ 'command-type': 'config-object',
+ 'obj-type': 'controller-domain-name-server',
+ 'parent-field': 'controller',
+ 'doc': 'controller|ip-name-server',
+ 'args': (
+ {
+ 'tag' : 'name-server',
+ 'field' : 'ip',
+ 'type' : 'ip-address-not-mask',
+ 'syntax-help' : 'Enter the IP address of the domain name server',
+ 'doc' : 'controller|ip-name-server-value',
+ },
+ ),
+ },
+ ),
+ {
+ 'field': 'default-gateway',
+ 'command-type': 'config-with-default-gateway-check',
+ 'obj-type': 'controller-node',
+ 'doc': 'controller|ip-default-gateway',
+ 'args': {
+ 'tag': 'default-gateway',
+ 'field': 'default-gateway',
+ 'type': 'ip-address-not-mask',
+ 'syntax-help': 'Enter the IP address of the default gateway',
+ 'default-for-no': '10.10.10.10',
+ 'doc': 'controller|ip-default-gateway-value',
+ },
+ },
+ ),
+ },
+}
+
+INTERFACE_IP_COMMAND_DESCRIPTION = {
+ 'name' : 'ip',
+ 'mode' : 'config-controller-if',
+ 'command-type' : 'config-with-default-gateway-check',
+ 'obj-type' : 'controller-interface',
+ 'short-help' : 'Associate ip address with interface',
+ 'doc' : 'controller|ip',
+ 'args' : {
+ 'choices' : (
+ {
+ 'fields': ('ip', 'netmask'),
+ 'doc': 'controller|ip-address',
+ 'args': (
+ 'address',
+ {
+ 'choices': (
+ (
+ {
+ 'field': 'ip',
+ 'help-name': 'ip-address',
+ 'type': 'ip-address-not-mask',
+ 'syntax-help': 'Enter an IP or CIDR address',
+ 'default-for-no' : '10.10.10.10',
+ 'doc': 'controller|ip-address-value',
+ },
+ {
+ 'field': 'netmask',
+ 'type': 'netmask',
+ 'syntax-help': 'Enter a netmask',
+ 'default-for-no' : '0.0.0.0',
+ 'doc': 'controller|ip-address-netmask',
+ }
+ ),
+ {
+ 'field': 'cidr',
+ 'help-name': 'cidr-address',
+ 'type': 'cidr-range',
+ 'data-handler': 'split-cidr-data',
+ 'completion-text': None,
+ 'dest-ip': 'ip',
+ 'dest-mask': 'mask',
+ 'doc': 'controller|ip-address-cidr',
+ }
+ )
+ },
+ ),
+ },
+ {
+ 'args': {
+ 'tag': 'mode',
+ 'field': 'mode',
+ 'type': 'enum',
+ 'values': ('dhcp', 'static'),
+ 'syntax-help': 'Enter the IP address configuration mode, either "dhcp" or "static"',
+ 'default-for-no': 'static',
+ 'doc': 'controller|ip-mode',
+ },
+ },
+ ),
+ }
+}
+
+NTP_COMMAND_DESCRIPTION = {
+ 'name' : 'ntp',
+ 'mode' : 'config-controller',
+ 'short-help' : 'Configure ntp for controller-node',
+ 'command-type': 'config',
+ 'obj-type' : 'controller-node',
+ 'doc' : 'controller|ntp',
+ 'doc-example' : 'controller|ntp-example',
+ 'args': {
+ 'tag' : 'server',
+ 'field' : 'ntp-server',
+ 'type' : 'ip-address-or-domain-name',
+ 'syntax-help' : 'Enter the IP address or domain name of the NTP server',
+ 'short-help' : 'Configure the NTP server name',
+ 'default-for-no': 'xyz.com',
+ 'completion' : 'complete-object-field',
+ 'doc' : 'controller|ntp-server',
+ }
+}
+
+LOGGING_COMMAND_DESCRIPTION = {
+ 'name' : 'logging',
+ 'short-help' : 'Configure logging (syslog) for controller-node',
+ 'mode' : 'config-controller',
+ 'command-type': 'config',
+ 'obj-type' : 'controller-node',
+ 'doc' : 'controller|logging',
+ 'doc-example' : 'controller|logging-example',
+ 'args': {
+ 'choices': (
+ {
+ 'field' : 'logging-enabled',
+ 'token' : 'on',
+ 'type' : 'boolean',
+ 'short-help' : 'Enable remote logging',
+ 'doc' : 'controller|logging-enable',
+ },
+ (
+ {
+ 'token' : 'server',
+ 'short-help' : 'Set the remote syslog server name',
+ 'doc' : 'controller|logging-server',
+ },
+ {
+ 'field' : 'logging-server',
+ 'help-name' : 'server-ip-or-domain',
+ 'type' : 'ip-address-or-domain-name',
+ 'syntax-help' : 'Enter the IP address or domain name of the syslog server',
+ 'completion' : 'complete-object-field',
+ 'match-for-no' : 'logging-server',
+ 'no-action' : 'reset-fields',
+ },
+ {
+ 'field' : 'logging-level',
+ 'tag' : 'level',
+ 'short-help' : 'Set the logging level for remote syslog',
+ 'type' : 'enum',
+ 'optional' : True,
+ 'values' : ('emerg', 'alert', 'crit', 'err',
+ 'warning', 'notice', 'info', 'debug',
+ '0', '1', '2', '3', '4', '5', '6', '7'
+ ),
+ 'doc' : 'controller|logging-level',
+ }
+ ),
+ )
+ }
+}
+
+FIREWALL_COMMAND_DESCRIPTION = {
+ 'name' : 'firewall',
+ 'short-help' : 'Configure firewall rule for controller-node',
+ 'command-type' : 'config-object',
+ 'mode' : 'config-controller-if',
+ 'obj-type' : 'firewall-rule',
+ 'doc' : 'controller|firewall',
+ 'parent-field' : 'interface',
+ 'args': (
+ # This arg/token is really just syntactic sugar for the command.
+ # There's no 'deny' value, because things are denied by default.
+ # Instead you just use a 'no' command to delete the firewall rule.
+ {
+ 'token' : 'allow',
+ 'short-help' : 'Allow a given set of traffic',
+ 'doc' : 'controller|firewall-allow',
+ },
+ {
+ 'field' : 'src-ip',
+ 'tag' : 'from',
+ 'type' : 'ip-address',
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'match-for-no' : True,
+ 'doc' : 'controller|firewall-src-ip',
+ },
+ {
+ 'field' : 'vrrp-ip',
+ 'tag' : 'local-ip',
+ 'type' : 'ip-address',
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'match-for-no' : True,
+ 'doc' : 'controller|firewall-local-ip',
+ },
+ {
+ 'choices' : (
+ {
+ 'field' : 'port',
+ 'type' : 'enum',
+ 'short-help' : 'Configure rule for a specific service port',
+ 'doc' : 'controller|firewall-port',
+ 'data' : { 'proto' : 'tcp' },
+ 'values': {
+ 'openflow' : 6633,
+ 'web' : 80,
+ 'ssl' : 443,
+ 'ssh' : 22
+ },
+ 'match-for-no' : True,
+ 'doc' : 'controller|firewall-+',
+ },
+ (
+ {
+ 'field' : 'proto',
+ 'type' : 'enum',
+ 'short-help' : 'Configure rule for protocol (TCP, UDP)',
+ 'values' : ('udp', 'tcp'),
+ 'doc' : 'controller|firewall-+',
+ 'match-for-no' : True,
+ },
+ {
+ 'optional-for-no' : False,
+ 'choices': (
+ {
+ 'field' : 'port',
+ 'type' : 'enum',
+ 'short-help' : 'Configure rule for a specific service port',
+ 'doc': 'controller|firewall-port',
+ 'values': {
+ 'openflow' : 6633,
+ 'web' : 80,
+ 'ssl' : 443,
+ 'ssh' : 22
+ },
+ 'match-for-no' : True,
+ 'doc' : 'controller|firewall-+',
+ },
+ {
+ 'field' : 'port',
+ 'base-type' : 'integer',
+ 'range' : (0, 65535),
+ 'completion-text' : '0-65535',
+ 'doc' : 'controller|firewall-port',
+ 'match-for-no' : True,
+ },
+ )
+ },
+ ),
+ {
+ 'field' : 'proto',
+ 'type' : 'enum',
+ 'short-help' : 'Configure rule for protocol (TCP, UDP)',
+ 'values' : 'vrrp',
+ 'doc' : 'controller|firewall-+',
+ 'match-for-no' : True,
+ },
+ ),
+ },
+ )
+}
+
+MONTH_NAMES = ('January', 'February', 'March', 'April', 'May', 'June',
+ 'July', 'August', 'September', 'October', 'November', 'December')
+
+
+
+CLOCK_TIMEZONE_COMMAND_DESCRIPTION = {
+ 'name' : 'clock',
+ 'mode' : 'config-controller',
+ 'short-help' : 'Configure time zone',
+ 'doc' : 'controller|clock-timezone',
+ 'doc-example' : 'controller|clock-timezone-example',
+ 'command-type' : 'config',
+ 'obj-type' : 'controller-node',
+ 'args' : {
+ 'tag' : 'timezone',
+ 'field' : 'time-zone',
+ 'type' : 'string',
+ 'default-for-no' : 'UTC',
+ 'completion' : 'time-zone-completion',
+ 'validation' : 'time-zone-validation',
+ 'syntax-help' : 'Enter the time zone',
+ 'short-help' : 'Configure the time zone',
+ }
+}
+
+CLOCK_SET_COMMAND_DESCRIPTION = {
+ 'name' : 'clock',
+ 'mode' : 'config-controller',
+ 'no-supported' : False,
+ 'short-help' : 'Set clock',
+ 'doc' : 'controller|clock-set',
+ 'doc-example' : 'controller|clock-set-example',
+ 'command-type' : 'realtime',
+ 'action' : 'set-clock',
+ 'args' : (
+ {
+ 'token' : 'set',
+ 'short-help' : 'Set the current time and date'
+ },
+ {
+ 'field' : 'time',
+ 'base-type' : 'string',
+ 'pattern' : '^[0-9]{1,2}:[0-9]{1,2}:[0-9]{2}$',
+ 'syntax-help' : 'Enter the time (HH:MM:SS)'
+ },
+ {
+ 'field' : 'day-of-month',
+ 'base-type' : 'integer',
+ 'range' : (1,31),
+ 'syntax-help' : 'Enter the day of the month (1-31)'
+ },
+ {
+ 'field' : 'month',
+ 'type' : 'enum',
+ 'values' : MONTH_NAMES,
+ 'syntax-help' : 'Enter the month (e.g. January, March)'
+ },
+ {
+ 'field' : 'year',
+ 'base-type' : 'integer',
+ 'range' : (0,10000),
+ 'syntax-help' : 'Enter the year'
+ },
+ )
+}
+"""
diff --git a/cli/desc/version200/controller_node_model.py b/cli/desc/version200/controller_node_model.py
new file mode 100755
index 0000000..d197794
--- /dev/null
+++ b/cli/desc/version200/controller_node_model.py
@@ -0,0 +1,56 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_enable_cascade_delete('controller-node')
+command.model_obj_type_enable_cascade_delete('controller-interface')
+command.model_obj_type_enable_cascade_delete('controller-domain-name-server')
+command.model_obj_type_enable_cascade_delete('controller-alias')
+command.model_obj_type_enable_cascade_delete('firewall-rule')
+
+command.model_obj_type_disable_submode('controller-node')
+command.model_obj_type_disable_submode('controller-interface')
+command.model_obj_type_disable_submode('controller-domain-name-server')
+command.model_obj_type_disable_submode('controller-alias')
+command.model_obj_type_disable_submode('firewall-rule')
+
+command.model_obj_type_disable_edit('controller-node', 'domain-lookups-enabled')
+command.model_obj_type_disable_edit('controller-node', 'domain-name')
+command.model_obj_type_disable_edit('controller-node', 'default-gateway')
+command.model_obj_type_disable_edit('controller-node', 'ntp-server')
+command.model_obj_type_disable_edit('controller-node', 'time-zone')
+command.model_obj_type_disable_edit('controller-node', 'logging-enabled')
+command.model_obj_type_disable_edit('controller-node', 'logging-server')
+command.model_obj_type_disable_edit('controller-node', 'logging-level')
+
+command.model_obj_type_disable_edit('controller-interface', 'type')
+command.model_obj_type_disable_edit('controller-interface', 'number')
+command.model_obj_type_disable_edit('controller-interface', 'ip')
+command.model_obj_type_disable_edit('controller-interface', 'netmask')
+command.model_obj_type_disable_edit('controller-interface', 'mac')
+command.model_obj_type_disable_edit('controller-interface', 'discovered-ip')
+command.model_obj_type_disable_edit('controller-interface', 'mode')
+command.model_obj_type_disable_edit('controller-interface', 'status')
+
+command.model_obj_type_disable_edit('controller-domain-name-server', 'ip')
+command.model_obj_type_disable_edit('controller-domain-name-server', 'sequence-number')
+command.model_obj_type_disable_edit('controller-domain-name-server', 'controller')
+
+command.model_obj_type_disable_edit('firewall-rule', 'interface')
+command.model_obj_type_disable_edit('firewall-rule', 'port')
+command.model_obj_type_disable_edit('firewall-rule', 'proto')
+command.model_obj_type_disable_edit('firewall-rule', 'rule')
diff --git a/cli/desc/version200/core.py b/cli/desc/version200/core.py
new file mode 100755
index 0000000..0e0f3c1
--- /dev/null
+++ b/cli/desc/version200/core.py
@@ -0,0 +1,2674 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+import run_config
+
+"""
+SHOW_RUNNING_CONFIG_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show the current active configuration',
+ 'action' : 'legacy-cli',
+ 'no-supported' : False,
+ 'obj-type' : 'running-config',
+ 'doc' : 'running-config|show',
+ 'doc-example' : 'running-config|show-example',
+ 'args' : (
+ 'running-config',
+ run_config.running_config_command_choices,
+ )
+}
+
+SHOW_CLOCK_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show the current date and time',
+ 'action' : 'display-rest',
+ 'no-supported' : False,
+ 'url' : 'system/clock/local',
+ 'rest-type' : 'dict-with-time|tz|year|month|day|hour|minute|second',
+ 'format' : 'system-clock',
+ 'doc' : 'clock|show',
+ 'doc-example' : 'clock|show-example',
+ 'args' : (
+ 'clock',
+ {
+ 'optional' : True,
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details'),
+ 'short-help' : 'Show more date/time information',
+ 'doc' : 'clock|show-format-details',
+ },
+ )
+}
+
+SHOW_CONFIG_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show saved configs (ex: startup-config, etc)',
+ 'action' : 'legacy-cli',
+ 'obj-type' : 'config',
+ 'no-supported' : False,
+ 'doc' : 'config|show',
+ 'doc-example' : 'config|show-example',
+ 'args' : (
+ 'config',
+ {
+ 'optional' : True,
+ 'choices' : (
+ # <first> [ <version> ]
+ # <first> diff <second> [ version ]
+ ( # 1nd choice 'diff' <config> <config> [ version ]
+ {
+ 'optional' : False,
+ 'field' : 'first',
+ 'type' : 'config',
+ 'completion' : 'complete-config',
+ 'doc' : 'config|show-first',
+ },
+ {
+ 'optional' : False,
+ 'token' : 'diff',
+ # XXX implies config's aren't called 'diff'
+ },
+ {
+ 'optional' : False,
+ 'field' : 'second',
+ 'type' : 'config',
+ 'completion' : 'complete-config',
+ 'doc' : 'config|show-second',
+ },
+ {
+ 'optional' : True,
+ 'field' : 'version',
+ 'type' : 'string',
+ 'doc' : 'config|show-version',
+ },
+
+ ),
+ ( # 2st choice <name> [ version ]
+ {
+ 'optional' : False,
+ 'field' : 'config',
+ 'type' : 'config',
+ 'completion' : 'complete-config',
+ 'syntax-help' : 'Config file name',
+ 'doc' : 'config|show-single',
+ },
+ {
+ 'optional' : True,
+ 'field' : 'version',
+ 'type' : 'string',
+ 'doc' : 'config|show-version',
+ },
+ ),
+ )
+ }
+ )
+}
+
+SHOW_CONFIG_FILE_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show a specific saved config file',
+ 'doc' : 'config-file|show',
+ 'doc-example' : 'config-file|show-example',
+ 'obj-type' : 'config-file',
+ 'action' : 'legacy-cli',
+ 'no-supported' : False,
+ 'args' : (
+ 'config-file',
+ {
+ 'optional' : True,
+ 'field' : 'config',
+ 'type' : 'config',
+ 'completion' : 'complete-config',
+ 'syntax-help' : 'Config file name',
+ }
+ ),
+}
+
+SHOW_TECH_SUPPORT_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show tech-support, collect output of various commands',
+ 'doc' : 'tech-support|show',
+ 'doc-example' : 'tech-support|show-example',
+ 'obj-type' : 'tech-support',
+ 'action' : 'legacy-cli',
+ 'no-supported' : False,
+ 'args' : (
+ 'tech-support',
+ ),
+}
+
+SHOW_FLOW_ENTRY_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'flow-entry',
+ 'short-help' : 'Show configured static flow-entries',
+ 'doc' : 'flow-entry|show',
+ 'doc-example' : 'flow-entry|show-example',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'args' : (
+ 'flow-entry',
+ {
+ 'field' : 'name',
+ 'optional' : True,
+ 'base-type' : 'identifier',
+ 'reserved' : [ 'switch' ],
+ 'completion' : 'complete-object-field',
+ },
+ {
+ 'field' : 'switch',
+ 'tag' : 'switch',
+ 'optional' : True,
+ 'type' : 'dpid',
+ 'completion' : 'complete-from-another',
+ 'other' : 'switches',
+ 'syntax-help' : 'switch dpid or alias',
+ 'short-help' : 'Show flow entries for a specific switch'
+ }
+
+ )
+}
+
+SHOW_FIREWALL_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'firewall-rule',
+ 'short-help' : 'Show firewall rules for controller interfaces',
+ 'doc' : 'firewall-rule|show',
+ 'doc-example' : 'firewall-rule|show-example',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'args' : (
+ 'firewall-rule',
+ {
+ 'optional' : True,
+ 'tag' : 'controller',
+ 'field' : 'controller',
+ 'type' : 'string',
+ 'short-help': 'Show rules from a specific controller',
+ 'doc' : 'firewall-rule|show-controller',
+ },
+ {
+ 'optional' : True,
+ 'tag' : 'type',
+ 'field' : 'type',
+ 'type' : 'string',
+ 'short-help': 'Show rules with a specific rule type',
+ 'doc' : 'firewall-rule|show-type',
+ },
+ {
+ 'optional' : True,
+ 'tag' : 'number',
+ 'field' : 'number',
+ 'type' : 'integer',
+ 'short-help': 'Show rules with a specific rule number',
+ 'doc' : 'firewall-rule|show-number',
+ },
+ {
+ 'optional' : True,
+ 'tag' : 'port',
+ 'field' : 'port',
+ 'type' : 'integer',
+ 'short-help': 'Show rules with a specific port number',
+ 'doc' : 'firewall-rule|show-port',
+ },
+ {
+ 'optional' : True,
+ 'tag' : 'proto',
+ 'field' : 'proto',
+ 'type' : 'enum',
+ 'values' : ('tcp', 'udp', 'vrrp'),
+ 'short-help': 'Show rules with a specific IP protocol',
+ 'doc' : 'firewall-rule|show-proto',
+ },
+ {
+ 'optional' : True,
+ 'field' : 'src-ip',
+ 'tag' : 'src-ip',
+ 'type' : 'ip-address',
+ 'short-help' : 'Show rules with this src-ip configured',
+ 'doc' : 'firewall-rule|show-src-ip',
+ },
+ {
+ 'optional' : True,
+ 'field' : 'vrrp-ip',
+ 'tag' : 'local-ip',
+ 'type' : 'ip-address',
+ 'short-help' : 'Show rules with this src-ip configured',
+ 'doc' : 'firewall-rule|show-src-ip',
+ },
+ )
+}
+
+SHOW_THIS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'this',
+ 'mode' : 'config-*',
+ 'short-help' : 'Show the object associated with the current submode',
+ 'doc' : 'show-this',
+ 'doc-example' : 'show-this-example',
+ 'action' : 'legacy-cli',
+ 'no-supported' : False,
+ 'args' : (
+ 'this',
+ )
+}
+
+SHOW_SWITCH_CLUSTER_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'obj-type' : 'switch-cluster',
+ 'short-help' : 'Show groups of interconnected openflow switches',
+ 'doc' : 'switch-cluster|show',
+ 'doc-example' : 'switch-cluster|show-example',
+ 'command-type' : 'display-rest',
+ 'url' : 'realtimestatus/network/cluster/',
+ 'rest-type' : 'dict-of-list-of-cluster-id|[switches]',
+ 'format' : 'switch-cluster',
+ 'args' : (
+ {
+ 'token' : 'switch-cluster',
+ }
+ )
+}
+
+SHOW_EXTERNAL_PORTS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'obj-type' : 'external-ports',
+ 'short-help' : 'Show switch ports connected to external L2 networks',
+ 'doc' : 'external-ports|show',
+ 'doc-example' : 'external-ports|show-example',
+ 'command-type' : 'display-rest',
+ 'url' : 'realtimestatus/network/externalports/',
+ 'rest-type' : 'dict-of-list-of-id|[ports]',
+ 'format' : 'external-ports',
+ 'args' : (
+ {
+ 'token' : 'external-ports',
+ }
+ )
+}
+
+
+SHOW_VERSION_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show current build version number',
+ 'doc' : 'core|version',
+ 'doc-example' : 'core|version-example',
+ 'action' : 'display-rest',
+ 'no-supported' : False,
+ 'url' : 'system/version',
+ 'format' : 'version',
+ 'detail' : 'details',
+ 'args' : (
+ 'version',
+ )
+}
+
+
+SHOW_LOGGING_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show various controller logs',
+ 'doc' : 'show-logging',
+ 'doc-example' : 'show-logging-example',
+ 'no-supported' : False,
+ 'obj-type' : 'logging',
+ 'args' : (
+ 'logging',
+ {
+ 'optional' : 'true',
+ 'args' : (
+ {
+ 'token' : 'controller',
+ },
+ {
+ 'choices' : (
+ {
+ 'field' : 'controller-node',
+ 'type' : 'enum',
+ 'values' : 'all',
+ },
+ {
+ 'field' : 'controller-node',
+ 'type' : 'identifier',
+ 'completion' : 'complete-from-another',
+ 'other' : 'controller-node|id',
+ 'data-handler' : 'alias-to-value',
+ }
+ ),
+ }
+ ),
+ },
+ {
+ 'field' : 'log-name',
+ 'type' : 'string',
+ 'completion' : 'complete-log-names',
+ 'doc' : 'show-logging-+',
+ 'action' : 'dump-log',
+ },
+ ),
+}
+
+SHOW_EVENT_HISTORY_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show recent network or system events',
+ 'doc' : 'event-history|show',
+ 'doc-example' : 'event-history|show-example',
+ 'action' : 'legacy-cli',
+ 'no-supported' : False,
+ 'obj-type' : 'event-history',
+ 'args' : (
+ 'event-history',
+ {
+ 'field' : 'event',
+ 'type' : 'enum',
+ 'values' : (
+ # 'attachment-point', not currently available
+ # 'packet-in', not currently available
+ 'topology-link',
+ 'topology-switch',
+ 'topology-cluster',
+ ),
+ 'doc' : 'show-event-history-+',
+ },
+ {
+ 'optional' : True,
+ 'field' : 'count',
+ 'tag' : 'last',
+ 'base-type' : 'integer',
+ 'range' : (1,10000),
+ 'doc' : 'show-event-history-count',
+ }
+ ),
+}
+
+SHOW_FLOW_CACHE_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show the contents of the controller flow cache',
+ 'doc' : 'flow-cache|show',
+ 'doc-example' : 'flow-cache|show-example',
+ 'action' : 'display-rest',
+ 'url' : 'flow-cache/vns/all/all',
+ 'rest-type' : 'dict-with-flows',
+ 'format' : 'flow-cache',
+ 'no-supported' : False,
+ #'obj-type' : 'flow-cache',
+ 'args' : (
+ 'flow-cache',
+ {
+ 'optional' : True,
+ 'choices' : (
+ (
+ {
+ 'optional' : False,
+ 'field' : 'application',
+ 'tag' : 'app',
+ 'type' : 'string',
+ 'short-help': 'Show the entries associated with a specific application',
+ 'doc' : 'flow-cache|show-application',
+ },
+ {
+ 'optional' : False,
+ 'field' : 'instance',
+ 'tag' : 'app-instance',
+ 'type' : 'string',
+ 'doc' : 'flow-cache|show-instance',
+ 'action' : 'display-rest',
+ 'url' : 'flow-cache/%(application)s/%(instance)s/all',
+ 'rest-type': 'dict-with-flows',
+ },
+ ),
+ {
+ 'field' : 'counters',
+ 'type' : 'enum',
+ 'values' : 'counters',
+ 'action' : 'display-rest',
+ 'url' : 'flow-cache/vns/all/counters',
+ 'format' : 'flow-cache-counters',
+ 'rest-type' : 'dict-with-counters|status',
+ 'detail' : 'details',
+ 'short-help': 'Show the counters for the flow cache',
+ 'doc' : 'flow-cache|show-counters',
+ },
+ )
+ }
+ ),
+}
+
+FEATURE_COMMAND_DESCRIPTION = {
+ 'name' : 'feature',
+ 'mode' : 'config',
+ 'short-help' : 'Enable features for controller',
+ 'doc' : 'feature',
+ 'doc-example' : 'feature-example',
+ 'command-type' : 'config',
+ 'obj-type' : 'feature',
+ 'args': {
+ 'choices': (
+ {
+ 'token' : 'vns',
+ 'short-help' : 'Enable the VNS feature',
+ 'doc' : 'feature-vns',
+ 'action' : (
+ {
+ 'proc' : 'write-object',
+ 'data' : {
+ # The primary key ('id') must be present to
+ # read the old row value, and update items,
+ # otherwise a 'new' row is written with default
+ # values
+
+ 'id' : 'feature',
+ 'netvirt-feature' : True,
+ },
+ },
+ {
+ 'proc' : 'wait-for-controller',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'feature',
+ 'netvirt-feature' : False ,
+ },
+ },
+ {
+ 'proc' : 'wait-for-controller',
+ },
+ )
+ },
+ {
+ 'token' : 'flow-pusher',
+ 'short-help' : 'Enable the static flow pusher feature',
+ 'doc' : 'feature-flow-pusher',
+ 'action' : (
+ {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'feature',
+ 'static-flow-pusher-feature' : True,
+ },
+ },
+ {
+ 'proc' : 'wait-for-controller',
+ },
+
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'feature',
+ 'static-flow-pusher-feature' : False,
+ },
+ },
+ {
+ 'proc' : 'wait-for-controller',
+ },
+ )
+ },
+ {
+ 'token' : 'performance-monitor',
+ 'short-help' : 'Enable the performance monitor feature',
+ 'doc' : 'feature-performance-monitor',
+ 'action' : (
+ {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'feature',
+ 'performance-monitor-feature' : True,
+ },
+ },
+ {
+ 'proc' : 'wait-for-controller',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'feature',
+ 'performance-monitor-feature' : False,
+ },
+ },
+ {
+ 'proc' : 'wait-for-controller',
+ },
+ )
+ },
+ ),
+ },
+}
+
+
+SHOW_FEATURE_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show enabled and disabled features',
+ 'doc' : 'show-feature',
+ 'doc-example' : 'show-feature-example',
+ 'command-type' : 'display-table',
+ 'obj-type' : 'feature',
+ 'data' : { 'id' : 'feature' },
+ 'args' : (
+ 'feature',
+ )
+}
+
+
+VERSION_COMMAND_DESCRIPTION = {
+ 'name' : 'version',
+ 'no-supported' : False,
+ 'short-help' : 'Move to a specific version of command syntax',
+ 'doc' : 'core|version',
+ 'doc-example' : 'core|version-example',
+ 'mode' : 'config*',
+ 'action' : 'version',
+ 'args': {
+ 'field' : 'version',
+ 'type' : 'string',
+ 'completion' : 'description-versions'
+ }
+}
+
+"""
+CLEAR_COMMAND_DESCRIPTION = {
+ 'name' : 'clearterm',
+ 'no-supported' : False,
+ 'short-help' : 'Clears and resets the terminal screen',
+ 'doc' : 'clearterm',
+ 'doc-example' : 'clearterm-example',
+ 'mode' : 'login',
+ 'action' : 'clearterm',
+ 'args' : {}
+}
+"""
+
+COPY_COMMAND_DESCRIPTION = {
+ 'name' : 'copy',
+ 'no-supported' : False,
+ 'short-help' : 'Copy configs to other configs',
+ 'doc' : 'copy|copy',
+ 'doc-example' : 'copy|copy-example',
+ 'mode' : 'enable',
+ 'action' : 'legacy-cli',
+ 'obj-type' : 'copy',
+ 'args': (
+ {
+ 'choices' : (
+ {
+ 'field' : 'source',
+ 'type' : 'config',
+ 'completion' : 'complete-config-copy',
+ 'help-name' : 'source specifier',
+ 'doc' : 'copy|copy-source',
+ },
+ ),
+ },
+ {
+ 'optional': True,
+ 'choices' : (
+ {
+ 'field' : 'dest',
+ 'type' : 'config',
+ 'completion' : 'complete-config-copy',
+ 'help-name' : 'destination specifier',
+ 'doc' : 'copy|copy-dest',
+ },
+ )
+ },
+ )
+}
+
+
+WRITE_COMMAND_DESCRIPTION = {
+ 'name' : 'write',
+ 'no-supported' : False,
+ 'short-help' : 'Write config to memory or terminal, or clear',
+ 'doc' : 'core|write',
+ 'doc-example' : 'core|write-example',
+ 'mode' : 'enable',
+ 'action' : 'legacy-cli',
+ 'obj-type' : 'write',
+ 'args': (
+ {
+ 'field' : 'source',
+ 'type' : 'enum',
+ 'values' : {'terminal' : 'running-config'},
+ 'short-help' : 'Show the current active configuration',
+ 'doc' : 'core|write-terminal',
+ 'action' : 'legacy-cli',
+ 'obj-type' : 'copy',
+ 'doc-example' : 'write-source-+',
+ },
+ ),
+}
+
+WRITE_ERASE_COMMAND_DESCRIPTION = {
+ 'name' : 'write',
+ 'no-supported' : False,
+ 'mode' : 'enable',
+ 'args' : (
+ {
+ 'field' : 'erase',
+ 'type' : 'enum',
+ 'values' : ('erase'),
+ 'short-help' : 'Erase settings and restore to factory defaults',
+ 'doc' : 'core|factory-default',
+ }
+ ),
+ 'action' : (
+ {
+ 'proc' : 'factory-default',
+ },
+ )
+}
+"""
+ENABLE_SUBMODE_COMMAND_DESCRIPTION = {
+ 'name' : 'enable',
+ 'mode' : 'login',
+ 'no-supported' : False,
+ 'help' : 'Enter enable mode',
+ 'short-help' : 'Enter enable mode',
+ 'doc' : 'enable',
+ 'doc-example' : 'enable-example',
+ 'command-type' : 'config-submode',
+ 'obj-type' : None,
+ 'parent-field' : None,
+ 'submode-name' : 'enable',
+ 'args' : (),
+}
+
+CONFIGURE_SUBMODE_COMMAND_DESCRIPTION = {
+ 'name' : 'configure',
+ 'mode' : 'enable',
+ 'no-supported' : False,
+ 'help' : 'Enter configure mode',
+ 'short-help' : 'Enter configure mode',
+ 'doc' : 'config',
+ 'doc-example' : 'config-example',
+ 'command-type' : 'config-submode',
+ 'obj-type' : None,
+ 'parent-field' : None,
+ 'submode-name' : 'config',
+ 'args' : {
+ 'token' : 'terminal',
+ 'optional' : 'true',
+ },
+}
+"""
+DEBUG_CLI_COMMAND_DESCRIPTION = {
+ 'name' : 'debug',
+ 'mode' : ['login', 'enable', 'config*'],
+ 'short-help' : 'Manage various cli debugging features',
+ 'doc' : 'debug|debug-cli',
+ 'doc-example' : 'debug|debug-cli-example',
+ 'args' : {
+ 'choices' : (
+ {
+ 'token' : 'cli',
+ 'action' : 'cli-set',
+ 'no-action' : 'cli-unset',
+ 'variable' : 'debug',
+ 'short-help' : 'Display more detailed information on errors',
+ 'doc' : 'debug|cli',
+ },
+ {
+ 'token' : 'cli-backtrace',
+ 'action' : 'cli-set',
+ 'no-action' : 'cli-unset',
+ 'variable' : 'cli-backtrace',
+ 'short-help' : 'Display backtrace information on errors',
+ 'doc' : 'debug|cli-backtrace',
+ },
+ {
+ 'token' : 'cli-batch',
+ 'action' : 'cli-set',
+ 'no-action' : 'cli-unset',
+ 'variable' : 'cli-batch',
+ 'short-help' : 'Disable any prompts to allow simpler batch processing',
+ 'doc' : 'debug|cli-batch',
+ },
+ {
+ 'token' : 'description',
+ 'action' : 'cli-set',
+ 'no-action' : 'cli-unset',
+ 'variable' : 'description',
+ 'short-help' : 'Display verbose debug information while processing commands',
+ 'doc' : 'debug|description',
+ },
+ (
+ {
+ 'token' : 'rest',
+ 'action' : 'cli-set',
+ 'no-action' : 'cli-unset',
+ 'variable' : 'rest',
+ 'short-help' : 'Display URLs of any information retrieved via REST',
+ 'doc' : 'debug|rest',
+ },
+ {
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'choices' : (
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details', 'brief'),
+ 'short-help' : 'Display both URLs and returned content for REST requests',
+ 'doc' : 'debug|debug-cli-rest-format',
+ },
+ {
+ 'field' : 'record',
+ 'tag' : 'record',
+ 'type' : 'string',
+ 'short-help' : 'record rest api activitiy',
+ },
+ ),
+ },
+ ),
+ {
+ 'token' : 'python',
+ 'action' : 'shell-command',
+ 'command' : 'python',
+ 'short-help' : 'Enter a python shell',
+ 'doc' : 'debug|python',
+ },
+ {
+ 'token' : 'bash',
+ 'action' : 'shell-command',
+ 'command' : 'bash',
+ 'short-help' : 'Enter a bash shell',
+ 'doc' : 'debug|bash',
+ },
+ {
+ 'token' : 'cassandra-cli',
+ 'action' : 'shell-command',
+ 'command' : 'cassandra-cli',
+ 'short-help' : 'Enter a cassandra shell',
+ 'doc' : 'debug|assandra-cli',
+ },
+ {
+ 'token' : 'netconfig',
+ 'action' : 'shell-command',
+ 'command' : 'netconfig',
+ 'short-help' : 'Enter a netconfig shell',
+ 'doc' : 'debug|netconfig',
+ },
+ # tcpdump requires that the 'tail' of the debug command be tcpdump syntax,
+ # but that would mean describing the complete tcpdump syntax here, and parsing it
+ # {
+ # 'token' : 'tcpdump',
+ # 'action' : 'shell-command',
+ # 'command' : '/opt/sdnplatform/sys/bin/bscnetconfig',
+ # },
+ )
+ }
+}
+
+
+HA_CONFIG_CLI_COMMAND_DESCRIPTION = {
+ 'name' : 'ha',
+ 'short-help' : 'Configure high availability',
+ 'doc' : 'ha|ha-vrrp',
+ 'doc-example' : 'ha|ha-vrrp-example',
+ 'mode' : 'config*',
+ 'feature' : 'ha',
+ 'args' : {
+ 'choices' : (
+ {
+ 'field' : 'cluster-number',
+ 'tag' : 'cluster-number',
+ 'base-type' : 'integer',
+ 'range' : (1, 255),
+ 'completion-text' : '1-255',
+ 'syntax-help' : "Enter a small integer (1-255) to distinguish different controller clusters",
+ 'short-help' : 'Set the VRRP cluster number',
+ 'doc' : 'ha|ha-cluster-number',
+ 'obj-type' : 'global-config',
+ 'obj-id' : 'global',
+ 'default-for-no' : 1,
+ 'action' : 'write-fields-explicit',
+ 'no-action' : 'reset-fields-explicit',
+ },
+ )
+ }
+}
+
+HA_CLI_COMMAND_DESCRIPTION = {
+ 'name' : 'ha',
+ 'no-supported' : False,
+ 'short-help' : 'Perform actions related to high availability',
+ 'doc' : 'ha|ha-failover',
+ 'doc-example' : 'ha|ha-failover-example',
+ 'feature' : 'ha',
+ 'mode' : 'enable',
+ 'args' : {
+ 'choices' : (
+ {
+ 'token' : 'failover',
+ 'short-help': 'Trigger a failure of the current node',
+ 'path' : 'system/ha/failback',
+ 'action' : (
+ {
+ 'proc' : 'confirm',
+ 'prompt' : 'Fallback will change the HA operating mode,'
+ 'enter "yes" (or "y") to continue:',
+ },
+ {
+ 'proc' : 'rest-post-data',
+ },
+ ),
+ },
+ (
+ {
+ 'token' : 'provision',
+ },
+ {
+ 'field' : 'ip',
+ 'type' : 'ip-address-not-mask',
+ 'action' : (
+ {
+ 'proc' : 'confirm',
+ 'prompt' : "Confirm to continue addition of new ip, "
+ 'enter "yes" (or "y") to continue:',
+ },
+ {
+ 'proc' : 'rest-post-data',
+ 'path' : 'system/ha/provision'
+ },
+ ),
+ },
+ ),
+ (
+ {
+ 'token' : 'decommission',
+ },
+ {
+ 'action' : 'controller-decommission',
+ 'obj-type' : 'controller-node',
+ 'optional' : False,
+ 'field' : 'id',
+ 'type' : 'identifier',
+ 'completion' : 'complete-alias-choice',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'controller|controller-node-name',
+ },
+ ),
+ )
+ }
+}
+
+
+SHOW_HA_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'no-supported' : False,
+ 'short-help' : 'Show high availability configuration',
+ 'doc' : 'ha|show',
+ 'doc-example' : 'ha|show-example',
+ 'feature' : 'ha',
+ 'mode' : 'login',
+ 'obj-type' : 'global-config',
+ 'command-type' : 'display-table',
+ 'action' : (
+ {
+ 'proc' : 'display-table',
+ },
+ # borrowed from controller-node, would be better to
+ # have this in common code
+ {
+ 'proc' : 'query-table',
+ 'obj-type' : 'controller-node',
+ },
+ {
+ 'proc' : 'join-table',
+ 'obj-type' : 'controller-alias',
+ 'key' : 'controller',
+ 'join-field' : 'id', # field in queried items
+ },
+ {
+ 'proc' : 'join-rest',
+ 'url' : 'system/controller',
+ 'rest-type' : 'dict-with-id',
+ 'key' : 'id',
+ 'join-field' : 'id',
+ 'add-field' : 'me',
+ },
+ # need a description mechanism to join ha-role, which
+ # needs to send urls to controller-node interfaces
+ # ie: the rest actions alwaus use the local controller
+ # (uptime has the same issue)
+ {
+ 'proc' : 'display',
+ 'title' : '\nController Nodes\n',
+ 'format' : 'controller-node',
+ }
+ ),
+ 'args' : (
+ 'ha',
+ {
+ 'optional' : True,
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : 'details',
+ 'doc' : 'format|details',
+ },
+
+ )
+}
+
+BOOT_COMMAND_DESCRIPTION = {
+ 'name' : 'boot',
+ 'no-supported' : False,
+ 'short-help' : 'Configure system boot options',
+ 'doc' : 'core|boot',
+ 'doc-example' : 'core|boot-example',
+ 'mode' : 'enable',
+ 'args' : (
+ {
+ 'field' : 'factory-default',
+ 'type' : 'enum',
+ 'values' : ('factory-default'),
+ 'short-help' : 'Erase settings and restore to factory defaults',
+ 'doc' : 'core|factory-default',
+ }
+ ),
+ 'action' : (
+ {
+ 'proc' : 'factory-default',
+ },
+ )
+}
+
+RELOAD_COMMAND_DESCRIPTION = {
+ 'name' : 'reload',
+ 'no-supported' : False,
+ 'short-help' : 'Reload and reboot',
+ 'doc' : 'core|reload',
+ 'doc-example' : 'core|reload-example',
+ 'mode' : 'enable',
+ 'args' : (),
+ 'obj-type' : 'reload',
+ 'action' : (
+ {
+ 'proc' : 'confirm',
+ 'prompt' : 'Confirm Reload (yes to continue) '
+ },
+ # XXX what about checking to see if the running-config
+ # has been copied to the startup config?
+ {
+ 'proc' : 'query-rest',
+ 'url' : 'system/reload'
+ },
+ )
+}
+
+UPGRADE_COMMAND_DESCRIPTION = {
+ 'name' : 'upgrade',
+ 'no-supported' : False,
+ 'short-help' : 'Manage the controller upgrade process',
+ 'doc' : 'core|upgrade',
+ 'doc-example' : 'core|upgrade-example',
+ 'mode' : 'enable',
+ 'args' : (
+ {
+ 'optional' : True,
+ 'type' : 'enum',
+ 'field' : 'force',
+ 'values' : ('force'),
+ 'short-help' : 'Ignore validation errors and upgrade anyway',
+ 'doc' : 'core|upgrade-force'
+ },
+ {
+ 'optional' : True,
+ 'type' : 'enum',
+ 'field' : 'details',
+ 'values' : ('details'),
+ 'short-help' : 'Display more information on the upgrade',
+ 'doc' : 'core|upgrade-details'
+ }
+ ),
+ 'obj-type' : 'upgrade',
+ 'action' : 'controller-upgrade',
+}
+
+UPGRADE_ABORT_COMMAND_DESCRIPTION = {
+ 'name' : 'upgrade',
+ 'no-supported' : False,
+ 'short-help' : 'Manage the controller upgrade process',
+ 'mode' : 'enable',
+ 'doc-example' : 'core|upgrade-abort-example',
+ 'obj-type' : 'upgrade',
+ 'args' : (
+ {
+ 'type' : 'enum',
+ 'field' : 'abort',
+ 'values' : 'abort',
+ 'short-help' : 'Abort an upgrade already installed',
+ 'doc' : 'core|upgrade-abort'
+ },
+ ),
+ 'action' : (
+ {
+ 'proc' : 'confirm',
+ 'prompt' : 'Confirm to abort an upgrade already installed'\
+ ' onto second partition\n'\
+ 'enter "yes" (or "y") to continue:',
+ },
+ {
+ 'proc' : 'rest-post-data',
+ 'path' : 'system/upgrade/abort'
+ },
+ )
+}
+
+ROLLBACK_COMMAND_DESCRIPTION = {
+ 'name' : 'rollback',
+ 'no-supported' : False,
+ 'short-help' : 'rollback cluster to specified config',
+ 'mode' : 'enable',
+ 'doc-example' : 'core|rollback-config-example',
+ 'obj-type' : 'rollback',
+ 'args' : (
+ {
+ 'type' : 'enum',
+ 'field' : 'dir',
+ 'short-help' : 'source directory',
+ 'values' : ('images://', 'saved-configs://'),
+ },
+ {
+ 'field' : 'file',
+ 'type' : 'string',
+ 'short-help' : 'config file name',
+ },
+ ),
+ 'action' : 'controller-config-rollback'
+}
+
+
+command.add_action('implement-connect', command.sdnsh.implement_connect,
+ {'kwargs': {'data' : '$data',}})
+
+
+CONNECT_COMMAND_DESCRIPTION = {
+ 'name' : 'connect',
+ 'mode' : 'login',
+ 'no-supported' : False,
+ 'short-help' : 'Connect to a controller\'s REST API',
+ 'doc' : 'connect|connect',
+ 'doc-example' : 'connect|connect-example',
+ 'obj-type' : 'controller-node',
+ 'action' : 'implement-connect',
+ 'args' : (
+ {
+ 'choices': (
+ {
+ 'field' : 'controller-id',
+ 'type' : 'obj-type',
+ 'completion' : 'complete-alias-choice',
+ 'completion-text' : 'controller id or alias',
+ 'short-help' : 'controller-id',
+ 'doc' : 'connect|connect-id',
+ },
+ {
+ 'field' : 'ip-address',
+ 'type' : 'ip-address',
+ 'completion' : 'complete-alias-choice',
+ 'completion-text' : 'ip address',
+ 'short-help' : 'controller-id',
+ 'doc' : 'connect|connect-ip',
+ },
+ ),
+ },
+ {
+ 'field' : 'port',
+ 'tag' : 'port',
+ 'type' : 'integer',
+ 'range' : (1,65535),
+ 'optional' : True,
+ 'doc' : 'connect|connect-port'
+ },
+ )
+}
+
+command.add_action('implement-ping', command.sdnsh.implement_ping,
+ {'kwargs': {'data' : '$data',}})
+
+PING_COMMAND_DESCRIPTION = {
+ 'name' : 'ping',
+ 'mode' : 'login',
+ 'no-supported' : False,
+ 'short-help' : 'ping a switch or ip address',
+ 'doc' : 'ping|ping',
+ 'doc-example' : 'ping|ping-example',
+ 'obj-type' : 'switches',
+ 'action' : 'implement-ping',
+ 'args' : (
+ {
+ 'field' : 'count',
+ 'type' : 'integer',
+ 'tag' : 'count',
+ 'optional' : True,
+ 'completion-text' : 'ping count',
+ 'doc' : 'ping|ping-count'
+ },
+ {
+ 'field' : 'ip-address',
+ 'type' : 'resolvable-ip-address',
+ 'completion-text' : 'ip-address ping target',
+ 'other' : 'switches|dpid',
+ 'completion' : [
+ 'complete-alias-choice',
+ 'complete-from-another',
+ ],
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'types|resolvable-ip-address'
+ },
+ ),
+}
+
+
+command.add_action('implement-traceroute', command.sdnsh.implement_traceroute,
+ {'kwargs': {'data' : '$data',}})
+
+TRACEROUTE_COMMAND_DESCRIPTION = {
+ 'name' : 'traceroute',
+ 'mode' : 'login',
+ 'no-supported' : False,
+ 'short-help' : 'Determine the L3 path to some destination',
+ 'doc' : 'traceroute|traceroute',
+ 'doc-example' : 'traceroute|traceroute-example',
+ 'obj-type' : 'switches',
+ 'action' : 'implement-traceroute',
+ 'args' : (
+ {
+ 'field' : 'ip-address',
+ 'type' : 'resolvable-ip-address',
+ 'completion-text' : 'ip-address ping target',
+ 'other' : 'switches|dpid',
+ 'completion' : [
+ 'complete-alias-choice',
+ 'complete-from-another',
+ ],
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'types|resolvable-ip-address'
+ },
+ ),
+}
+
+SET_CLI_COMMAND_DESCRIPTION = {
+ 'name' : 'set',
+ 'mode' : 'login',
+ 'no-supported' : False,
+ 'short-help' : 'Manage CLI sessions settings',
+ 'doc' : 'set|set',
+ 'doc-example' : 'set|set-example',
+ 'action' : 'cli-set',
+ 'variable' : 'set',
+ 'args' : (
+ 'length',
+ {
+ 'choices' : (
+ {
+ 'field' : 'length',
+ 'base-type' : 'integer',
+ 'range' : (0,512),
+ },
+ {
+ 'field' : 'length',
+ 'type' : 'enum',
+ 'values' : 'term',
+ },
+ )
+ },
+ ),
+}
+#"""
+#
+# FORMATS
+#
+
+import fmtcnv
+
+"""
+GLOBAL_CONFIG_FORMAT = {
+ 'global-config' : {
+ 'field-orderings' : {
+ 'details' : [
+ 'cluster-name',
+ 'cluster-number',
+ 'ha-enabled',
+ ],
+ 'default' : [
+ 'cluster-name',
+ 'cluster-number',
+ 'ha-enabled',
+ ],
+ },
+
+ 'fields' : {
+ 'cluster-name' : {
+ 'verbose-name' : 'Cluster Name',
+ },
+ 'cluster-number' : {
+ 'verbose-name' : 'Cluster Number',
+ },
+ 'ha-enabled' : {
+ 'verbose-name' : 'HA Enabled',
+ },
+ },
+ },
+}
+
+
+FEATURE_FORMAT = {
+ 'feature' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'netvirt-feature',
+ 'static-flow-pusher-feature',
+ 'performance-monitor-feature',
+ ],
+ },
+
+ 'fields' : {
+ 'netvirt-feature' : { 'verbose-name' : 'VNS Feature',
+ 'formatter' : fmtcnv.replace_boolean_with_enable_disable,
+ },
+ 'static-flow-pusher-feature' : { 'verbose-name' : 'Static Flow Pusher Feature',
+ 'formatter' : fmtcnv.replace_boolean_with_enable_disable,
+ },
+ 'performance-monitor-feature' : { 'verbose-name' : 'Performance Monitoring Feature',
+ 'formatter' : fmtcnv.replace_boolean_with_enable_disable,
+ },
+ }
+ },
+}
+
+LINK_FORMAT = {
+ 'link' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'src-switch', 'src-port', 'src-port-state',
+ 'Idx', 'dst-switch', 'dst-port', 'dst-port-state', 'link-type' ]
+ },
+ 'fields' : {
+ 'src-port' : { 'formatter' : fmtcnv.decode_openflow_port_src_switch },
+ 'dst-port' : { 'formatter' : fmtcnv.decode_openflow_port_dst_switch },
+ 'src-switch' : { 'formatter' : fmtcnv.replace_switch_with_alias },
+ 'dst-switch' : { 'formatter' : fmtcnv.replace_switch_with_alias },
+ 'src-port-state' : { 'formatter' : fmtcnv.decode_port_state },
+ 'dst-port-state' : { 'formatter' : fmtcnv.decode_port_state },
+ 'link-type' : { 'verbose-name' : 'Link Type',
+ },
+ }
+ },
+}
+
+CONFIG_FORMAT = {
+ 'config' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'name', 'length', 'version', 'timestamp' ],
+ },
+ 'fields' : {
+ 'name' : { 'primary_key': True
+ },
+ 'version' : {
+ },
+ 'length' : {
+ },
+ 'timestamp': {
+ },
+ },
+ },
+}
+
+
+TEST_PKTIN_ROUTE_FORMAT = {
+ 'test-pktin-route' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'cluster', 'hop', 'dpid', 'inPort', 'outPort'],
+ },
+ 'fields' : {
+ 'cluster' : {'verbose-name' : 'Cluster',
+ 'formatter' : fmtcnv.print_cluster_id
+ },
+ 'hop' : {'verbose-name' : 'Hop'
+ },
+ 'dpid' : {'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.print_switch_and_alias,
+ },
+ 'inPort' : {'verbose-name' : 'Input-Intf',
+ 'formatter' : fmtcnv.decode_openflow_port_dpid,
+ },
+ 'outPort': {'verbose-name': 'Output-Intf',
+ 'formatter' : fmtcnv.decode_openflow_port_dpid,
+ },
+ },
+ },
+}
+
+
+PERFORMANCE_DATA_FORMAT = {
+ 'performance-data' : {
+ 'field-orderings' : {
+ 'default' : ['BktNo', 'StartTime', 'CompName', 'Pkts', 'Avg',
+ 'Min', 'Max', 'StdDev'],
+ },
+ 'fields' : {
+ 'Pkts' : {'verbose-name': 'Pkts*'
+ },
+ 'CompName' : {'verbose-name' : 'Component'
+ },
+ 'StartTime': {'verbose-name' : 'Start Time'
+ }
+ }
+ },
+}
+
+
+FLOW_CACHE_COUNTERS_FORMAT = {
+ 'flow-cache-counters' : {
+ 'field-orderings' : {
+ 'details' : [
+ 'applName',
+ 'maxFlows',
+ 'activeCnt',
+ 'inactiveCnt',
+ 'addCnt',
+ 'delCnt',
+ 'activatedCnt',
+ 'deactivatedCnd',
+ 'cacheHitCnt',
+ 'missCnt',
+ 'flowModRemovalMsgLossCnt',
+ 'notStoredFullCnt',
+ 'fcObjFreedCnt',
+ 'unknownOperCnt',
+ 'flowCacheAlmostFull',
+ ],
+
+ },
+
+ 'fields' : {
+ 'applName' : { 'verbose-name' : 'Application name',
+ },
+ 'maxFlows' : { 'verbose-name' : 'Max flow cache size',
+ },
+ 'activeCnt' : { 'verbose-name' : 'Active entries',
+ },
+ 'inactiveCnt' : { 'verbose-name' : 'Inactive entries',
+ },
+ 'addCnt' : { 'verbose-name' : 'Add operations',
+ },
+ 'delCnt' : { 'verbose-name' :'Del operations',
+ },
+ 'activatedCnt' : { 'verbose-name' : 'Activated',
+ },
+ 'deactivatedCnd' : { 'verbose-name' : 'Deactivated',
+ },
+ 'cacheHitCnt' : { 'verbose-name' : 'Cache hits',
+ },
+ 'missCnt' : { 'verbose-name' : 'Cache misses',
+ },
+ 'flowModRemovalMsgLossCnt' : { 'verbose-name' : 'Lost removal messages',
+ },
+ 'notStoredFullCnt' : { 'verbose-name' : 'Not stored; cache full',
+ },
+ 'fcObjFreedCnt' : { 'verbose-name' : 'Free count',
+ },
+ 'unknownOperCnt' : { 'verbose-name' : 'Unknown operations',
+ },
+ 'flowCacheAlmostFull' : { 'verbose-name' : 'Cache near full',
+ },
+ },
+ },
+}
+
+
+FLOW_CACHE_FORMAT = {
+ 'flow-cache' : {
+ 'field-orderings' : {
+ 'default': ['Idx', 'Appl', 'AppInst', 'VLAN', 'PCP', 'SrcMAC',
+ 'DestMAC', 'EtherType', 'SrcIPAddr', 'DstIPAddr',
+ 'Protocol', 'TOS', 'SrcPort', 'DstPort',
+ 'Source-Switch', 'InputPort', 'Wildcards', 'Action',
+ 'Cookie', 'State', 'Time', 'SC'],
+ },
+ 'fields' : {
+ 'VLAN' : {'formatter' : fmtcnv.convert_signed_short_for_vlan
+ },
+ 'Source-Switch' : {'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'InputPort' : {'formatter' : fmtcnv.decode_openflow_port_source_switch
+ },
+ 'SrcMAC' : {'formatter' : fmtcnv.print_host_and_alias
+ },
+ 'DestMAC' : {'formatter' : fmtcnv.print_host_and_alias
+ },
+ 'EtherType' : {'formatter' : fmtcnv.decode_ether_type
+ },
+ 'Protocol' : {'formatter' : fmtcnv.decode_network_protocol
+ },
+ 'SrcPort' : {'formatter' : fmtcnv.decode_src_port
+ },
+ 'DstPort' : {'formatter' : fmtcnv.decode_dst_port
+ },
+ 'Cookie' : {'formatter' : fmtcnv.decode_flow_cookie
+ },
+ 'Time' : {'formatter' : fmtcnv.timestamp_to_local_timestr
+ },
+ }
+ },
+}
+
+
+EV_HIST_TOPOLOGY_FORMAT = {
+ 'ev-hist-topology-switch' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'Time', 'Switch' , 'IpAddr', 'Port',
+ 'State', 'Action', 'Reason' ],
+ },
+ 'fields' : {
+ 'Time' : {
+ 'verbose-name' : 'Time'
+ },
+ 'Switch' : {'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'Port' : {'verbose-name' : 'Port'
+ },
+ 'IpAddr' : {'verbose-name' : 'IpAddr.'
+ },
+ 'Action' : {'verbose-name' : 'Action'
+ },
+ 'Reason' : {'verbose-name' : 'Reason'
+ },
+ 'State' : {'verbose-name' : 'State'
+ },
+ }
+ },
+}
+
+
+
+EV_HIST_TOPOLOGY_CLUSTER_FORMAT = {
+ 'ev-hist-topology-cluster' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'Time', 'Switch' , 'OldClusterId',
+ 'NewClusterId', 'State', 'Action', 'Reason' ],
+ },
+ 'fields' : {
+ 'Time' : {
+ 'verbose-name' : 'Time'
+ },
+ 'Switch' : {'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'Action' : {'verbose-name' : 'Action'
+ },
+ 'Reason' : {'verbose-name' : 'Reason'
+ },
+ 'State' : {'verbose-name' : 'State'
+ },
+ }
+ },
+}
+
+
+EV_HIST_TOPOLOGY_LINK_FORMAT = {
+ 'ev-hist-topology-link' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'Time', 'Source-Switch' , 'Dest-Switch',
+ 'SrcPort', 'DstPort',
+ 'SrcPortState', 'DstPortState',
+ 'State', 'Action', 'Reason' ],
+ },
+ 'fields' : {
+ 'Time' : {
+ 'verbose-name' : 'Time'
+ },
+ 'Source-Switch' : {'verbose-name' : 'Source-Switch',
+ 'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'Dest-Switch' : {'verbose-name' : 'Dest-Switch',
+ 'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'SrcPort' : {'verbose-name' : 'SrcPort',
+ 'formatter' : fmtcnv.decode_openflow_port_source_switch
+ },
+ 'DstPort' : {'verbose-name' : 'DstPort',
+ 'formatter' : fmtcnv.decode_openflow_port_dest_switch
+ },
+ 'SrcPortState' : {'verbose-name' : 'SrcPrtSt'
+ },
+ 'DstPortState' : {'verbose-name' : 'DstPrtSt'
+ },
+ 'Action' : {'verbose-name' : 'Action'
+ },
+ 'Reason' : {'verbose-name' : 'Reason'
+ },
+ 'State' : {'verbose-name' : 'State'
+ },
+ }
+ },
+}
+
+
+EV_HIST_ATTACHMENT_POINT_FORMAT = {
+ 'ev-hist-attachment-point' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'Time', 'Host', 'Switch' , 'Port', 'VLAN',
+ 'Action', 'Reason' ],
+ },
+ 'fields' : {
+ 'Time_ns' : {
+ 'verbose-name' : 'Time'
+ #'formatter' : fmtcnv.timestamp_ns_to_local_timestr
+ },
+ 'Host' : {'verbose-name' : 'Host',
+ 'formatter' : fmtcnv.print_host_and_alias
+ },
+ 'Switch' : {'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'Port' : {'verbose-name' : 'IF',
+ 'formatter' : fmtcnv.decode_openflow_port,
+ },
+ 'VLAN' : {'verbose-name' : 'VLAN'
+ },
+ 'Action' : {'verbose-name' : 'Action'
+ },
+ 'Reason' : {'verbose-name' : 'Reason'
+ },
+ }
+ },
+}
+
+
+EV_HIST_PACKET_IN_FORMAT = {
+ 'ev-hist-packet-in' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'Time',
+ 'dataLayerSource',
+ 'dataLayerDestination',
+ 'dataLayerType',
+ 'dataLayerVirtualLan',
+ #'dataLayerVirtualLanPriorityCodePoint',
+ 'inputSwitch',
+ 'inputPort',
+ 'networkSource',
+ 'networkDestination',
+ #'networkSourceMaskLen',
+ #'networkDestinationMaskLen',
+ 'networkProtocol',
+ 'networkTypeOfService',
+ 'transportSource',
+ 'transportDestination',
+ #'Action', 'reason'
+ ],
+ },
+ 'fields' : {
+ 'Time' : {
+ 'verbose-name' : 'Time'
+ #'formatter' : fmtcnv.timestamp_ns_to_local_timestr
+ },
+ 'wildcards' : { 'verbose-name' : 'Wildcards',
+ 'formatter' : fmtcnv.convert_integer_to_bitmask
+ },
+ 'dataLayerSource' : { 'verbose-name' : 'Src MAC',
+ 'formatter' : fmtcnv.print_host_and_alias
+ },
+ 'dataLayerDestination' : { 'verbose-name' : 'Dst MAC',
+ 'formatter' : fmtcnv.print_host_and_alias
+ },
+ 'dataLayerType' : { 'verbose-name' : 'Eth Type',
+ 'formatter' : fmtcnv.decode_ether_type
+ },
+ 'dataLayerVirtualLan' : { 'verbose-name' : 'VLAN',
+ 'formatter' : fmtcnv.convert_signed_short_for_vlan
+ },
+ 'dataLayerVirtualLanPriorityCodePoint' : { 'verbose-name' : 'VLAN PCP'
+ },
+ 'inputSwitch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'inputPort' : { 'verbose-name' : 'Port',
+ 'formatter' : fmtcnv.decode_openflow_port_inputSwitch
+ },
+ 'networkSource' : { 'verbose-name' : 'Src IP'
+ },
+ 'networkDestination' : { 'verbose-name' : 'Dst IP'
+ },
+ 'networkSourceMaskLen' : { 'verbose-name' : 'Src IP Bits'
+ },
+ 'networkDestinationMaskLen' : { 'verbose-name' : 'Dst IP Bits'
+ },
+ 'networkProtocol' : { 'verbose-name' : 'Proto.',
+ 'formatter' : fmtcnv.decode_network_protocol
+ },
+ 'networkTypeOfService' : { 'verbose-name' : 'TOS'
+ },
+ 'transportSource' : { 'verbose-name' : 'NwSPort',
+ 'formatter' : fmtcnv.decode_src_port
+ },
+ 'transportDestination' : { 'verbose-name' : 'NwDPort',
+ 'formatter' : fmtcnv.decode_dst_port
+ },
+ 'Action' : {'verbose-name' : 'Action'
+ },
+ 'Reason' : {'verbose-name' : 'Reason'
+ },
+ }
+ },
+}
+"""
+
+def realtime_flow_timeout(i, data=None):
+ return ('%s/%s' %
+ (fmtcnv.convert_signed_short_to_unsigned(data['hardTimeout']),
+ fmtcnv.convert_signed_short_to_unsigned(data['idleTimeout'])))
+
+REALTIME_FLOW_FORMAT = {
+ 'realtime_flow' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'Idx', 'switch', 'cookie',
+ 'byteCount', 'packetCount',
+ 'actions', 'dataLayerSource', 'dataLayerDestination',
+ 'flow-brief',
+ ],
+ 'scoped' : [
+ 'Idx', 'cookie',
+ 'byteCount', 'packetCount',
+ 'actions', 'dataLayerSource', 'dataLayerDestination',
+ 'flow-brief',
+
+ ],
+ 'brief' : [ 'Idx', 'switch', 'cookie', 'dataLayerSource', 'dataLayerDestination',
+ 'networkSource', 'networkDestination', 'networkProtocol',
+ 'transportSource', 'transportDestination'],
+ 'default' : [ 'Idx', 'switch', 'byteCount', 'packetCount', 'durationSeconds',
+ 'cookie', 'inputPort', 'dataLayerSource', 'dataLayerDestination',
+ 'dataLayerType', 'networkSource', 'networkDestination', 'networkProtocol',
+ 'transportSource', 'transportDestination'],
+ 'scoped' : [ 'Idx', 'switch', 'byteCount', 'packetCount', 'durationSeconds',
+ 'cookie', 'inputPort', 'dataLayerSource', 'dataLayerDestination',
+ 'dataLayerType', 'networkSource', 'networkDestination', 'networkProtocol',
+ 'transportSource', 'transportDestination'],
+ 'details' : [ 'Idx', 'switch', 'byteCount', 'packetCount', 'durationSeconds',
+ 'cookie', 'hardTimeout', 'idleTimeout', 'priority', 'tableId', 'inputPort',
+ 'dataLayerSource', 'dataLayerDestination', 'dataLayerType', 'dataLayerVirtualLan',
+ 'dataLayerVirtualLanPriorityCodePoint', 'networkSource', 'networkDestination',
+ 'networkProtocol', 'transportSource', 'transportDestination',
+ 'networkTypeOfService', 'actions'],
+ 'vns_flow': [ 'Idx', 'dataLayerSource', 'dataLayerDestination', 'dataLayerVirtualLan', 'dataLayerType'],
+ 'summary' : [ 'Idx', 'vnsName', 'vnsFlowCnt', 'flowEntryCnt'],
+ },
+ 'fields': {
+ 'switch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'flow-brief' : {
+ 'verbose-name' : 'Match',
+ 'formatter' : fmtcnv.realtime_flow_brief,
+ },
+ 'flow-timeout' : {
+ 'verbose-name' : 'H/I',
+ 'formatter' : realtime_flow_timeout,
+ },
+ 'byteCount' : { 'verbose-name': 'Bytes',
+ 'primary_key':True
+ },
+ 'packetCount' : { 'verbose-name' : 'Packets'
+ },
+ 'cookie' : { 'verbose-name' : 'Author',
+ 'formatter' : fmtcnv.decode_flow_cookie,
+ },
+ 'durationSeconds' : { 'verbose-name' : 'Dur(s)'
+ },
+ 'durationNanoseconds' : { 'verbose-name' : 'Dur(ns)'
+ },
+ 'hardTimeout' : { 'verbose-name' : 'Hard Timeout',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'idleTimeout' : { 'verbose-name' : 'Idle Timeout',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'length' : { 'verbose-name' : 'Length'
+ },
+ 'priority' : { 'verbose-name' : 'Priority',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'tableId' : { 'verbose-name' : 'Table' },
+ 'wildcards' : { 'verbose-name' : 'Wildcards',
+ 'formatter' : fmtcnv.convert_integer_to_bitmask
+ },
+ 'dataLayerSource' : { 'verbose-name' : 'Src MAC',
+ 'formatter' : fmtcnv.replace_host_with_alias
+ },
+ 'dataLayerDestination' : { 'verbose-name' : 'Dst MAC',
+ 'formatter' : fmtcnv.replace_host_with_alias
+ },
+ 'dataLayerType' : { 'verbose-name' : 'Ether Type',
+ 'formatter' : fmtcnv.decode_ether_type
+ },
+ 'dataLayerVirtualLan' : { 'verbose-name' : 'VLAN ID',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'dataLayerVirtualLanPriorityCodePoint' : { 'verbose-name' : 'VLAN PCP'
+ },
+ 'inputPort' : { 'verbose-name' : 'In Port',
+ 'formatter' : fmtcnv.decode_openflow_port
+ },
+ 'networkSource' : { 'verbose-name' : 'Src IP'
+ },
+ 'networkDestination' : { 'verbose-name' : 'Dst IP'
+ },
+ 'networkSourceMaskLen' : { 'verbose-name' : 'Src IP Bits'
+ },
+ 'networkDestinationMaskLen' : { 'verbose-name' : 'Dst IP Bits'
+ },
+ 'networkProtocol' : { 'verbose-name' : 'Protocol',
+ 'formatter' : fmtcnv.decode_network_protocol
+ },
+ 'networkTypeOfService' : { 'verbose-name' : 'TOS Bits'
+ },
+ 'transportSource' : { 'verbose-name' : 'Src Port',
+ 'formatter' : fmtcnv.decode_src_port
+ },
+ 'transportDestination' : { 'verbose-name' : 'Dst Port',
+ 'formatter' : fmtcnv.decode_dst_port
+ },
+ 'actions' : { 'verbose-name' : 'Actions',
+ 'formatter' : fmtcnv.decode_actions
+ },
+ 'vnsName' : { 'verbose-name' : 'VNS'
+ },
+ 'vnsFlowCnt' : { 'verbose-name' : 'Flows'
+ },
+ 'flowEntryCnt' : { 'verbose-name' : 'Flow-Entries'
+ },
+ }
+ },
+}
+
+REALTIME_TABLE_IP_FLOW_FORMAT = {
+ 'realtime_table_ip_flow' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'Idx', 'cookie',
+ 'byteCount', 'packetCount','priority',
+ 'networkDestination',
+ 'flow-brief','actions'
+ ],
+ 'scoped' : [
+ 'Idx', 'byteCount', 'packetCount', 'durationSeconds',
+ 'cookie','priority',
+ 'networkDestination', 'actions'
+ ],
+ 'brief' : [ 'Idx', 'byteCount', 'packetCount', 'durationSeconds',
+ 'cookie','priority',
+ 'networkDestination', 'actions'
+ ],
+ 'default' : [ 'Idx', 'byteCount', 'packetCount', 'durationSeconds',
+ 'cookie','priority',
+ 'networkDestination', 'actions'
+ ],
+ 'scoped' : [ 'Idx', 'byteCount', 'packetCount', 'durationSeconds',
+ 'cookie','priority',
+ 'networkDestination', 'actions'
+ ],
+ 'details' : [ 'Idx', 'byteCount', 'packetCount', 'durationSeconds',
+ 'cookie','priority'
+ 'networkDestination', 'actions'
+ ],
+ #'vns_flow': [ 'Idx', 'dataLayerSource', 'dataLayerDestination', 'dataLayerVirtualLan', 'dataLayerType'],
+ #'summary' : [ 'Idx', 'vnsName', 'vnsFlowCnt', 'flowEntryCnt'],
+ },
+ 'fields': {
+ 'switch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'flow-brief' : {
+ 'verbose-name' : 'Match',
+ 'formatter' : fmtcnv.realtime_flow_brief,
+ },
+ 'flow-timeout' : {
+ 'verbose-name' : 'H/I',
+ 'formatter' : realtime_flow_timeout,
+ },
+ 'byteCount' : { 'verbose-name': 'Bytes',
+ 'primary_key':True
+ },
+ 'packetCount' : { 'verbose-name' : 'Packets'
+ },
+ 'cookie' : { 'verbose-name' : 'Cookie'#,
+ #'formatter' : fmtcnv.decode_flow_cookie,
+ },
+ 'durationSeconds' : { 'verbose-name' : 'Dur(s)'
+ },
+ 'durationNanoseconds' : { 'verbose-name' : 'Dur(ns)'
+ },
+ 'hardTimeout' : { 'verbose-name' : 'Hard Timeout',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'idleTimeout' : { 'verbose-name' : 'Idle Timeout',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'length' : { 'verbose-name' : 'Length'
+ },
+ 'priority' : { 'verbose-name' : 'Priority',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'tableId' : { 'verbose-name' : 'Table' },
+ 'wildcards' : { 'verbose-name' : 'Wildcards',
+ 'formatter' : fmtcnv.convert_integer_to_bitmask
+ },
+ 'dataLayerSource' : { 'verbose-name' : 'Src MAC',
+ 'formatter' : fmtcnv.replace_host_with_alias
+ },
+ 'dataLayerDestination' : { 'verbose-name' : 'Dst MAC',
+ 'formatter' : fmtcnv.replace_host_with_alias
+ },
+ 'dataLayerType' : { 'verbose-name' : 'Ether Type',
+ 'formatter' : fmtcnv.decode_ether_type
+ },
+ 'dataLayerVirtualLan' : { 'verbose-name' : 'VLAN ID',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'dataLayerVirtualLanPriorityCodePoint' : { 'verbose-name' : 'VLAN PCP'
+ },
+ 'inputPort' : { 'verbose-name' : 'In Port',
+ 'formatter' : fmtcnv.decode_openflow_port
+ },
+ 'networkSource' : { 'verbose-name' : 'Src IP'
+ },
+ 'networkDestination' : { 'verbose-name' : 'Dst IP'
+ },
+ 'networkSourceMaskLen' : { 'verbose-name' : 'Src IP Bits'
+ },
+ 'networkDestinationMaskLen' : { 'verbose-name' : 'Dst IP Bits'
+ },
+ 'networkProtocol' : { 'verbose-name' : 'Protocol',
+ 'formatter' : fmtcnv.decode_network_protocol
+ },
+ 'networkTypeOfService' : { 'verbose-name' : 'TOS Bits'
+ },
+ 'transportSource' : { 'verbose-name' : 'Src Port',
+ 'formatter' : fmtcnv.decode_src_port
+ },
+ 'transportDestination' : { 'verbose-name' : 'Dst Port',
+ 'formatter' : fmtcnv.decode_dst_port
+ },
+ 'actions' : { 'verbose-name' : 'Instructions',
+ },
+ 'vnsName' : { 'verbose-name' : 'VNS'
+ },
+ 'vnsFlowCnt' : { 'verbose-name' : 'Flows'
+ },
+ 'flowEntryCnt' : { 'verbose-name' : 'Flow-Entries'
+ },
+ }
+ },
+}
+
+
+
+REALTIME_TABLE_MPLS_FLOW_FORMAT = {
+ 'realtime_table_mpls_flow' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'Idx', 'priority',
+ 'byteCount', 'packetCount',
+ 'mplsLabel','mplsBos','mplsTc',
+ 'flow-brief', 'actions'
+ ],
+ 'scoped' : [
+ 'Idx', 'byteCount', 'packetCount', 'durationSeconds',
+ 'priority',
+ 'mplsLabel','mplsBos','mplsTc','actions'
+ ],
+ 'brief' : [ 'Idx', 'byteCount', 'packetCount', 'durationSeconds',
+ 'priority',
+ 'mplsLabel','mplsBos','mplsTc','actions'
+ ],
+ 'default' : [ 'Idx', 'byteCount', 'packetCount', 'durationSeconds',
+ 'priority',
+ 'mplsLabel','mplsBos','mplsTc','actions'
+ ],
+ 'scoped' : [ 'Idx', 'byteCount', 'packetCount', 'durationSeconds',
+ 'priority',
+ 'mplsLabel','mplsBos','mplsTc','actions'
+ ],
+ 'details' : [ 'Idx', 'byteCount', 'packetCount', 'durationSeconds',
+ 'priority',
+ 'mplsLabel','mplsBos','mplsTc','actions'
+ ],
+ #'vns_flow': [ 'Idx', 'dataLayerSource', 'dataLayerDestination', 'dataLayerVirtualLan', 'dataLayerType'],
+ #'summary' : [ 'Idx', 'vnsName', 'vnsFlowCnt', 'flowEntryCnt'],
+ },
+ 'fields': {
+ 'switch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'flow-brief' : {
+ 'verbose-name' : 'Match',
+ 'formatter' : fmtcnv.realtime_flow_brief,
+ },
+ 'flow-timeout' : {
+ 'verbose-name' : 'H/I',
+ 'formatter' : realtime_flow_timeout,
+ },
+ 'byteCount' : { 'verbose-name': 'Bytes',
+ 'primary_key':True
+ },
+ 'packetCount' : { 'verbose-name' : 'Packets'
+ },
+ 'cookie' : { 'verbose-name' : 'Cookie',
+ #'formatter' : fmtcnv.decode_flow_cookie,
+ },
+ 'durationSeconds' : { 'verbose-name' : 'Dur(s)'
+ },
+ 'durationNanoseconds' : { 'verbose-name' : 'Dur(ns)'
+ },
+ 'hardTimeout' : { 'verbose-name' : 'Hard Timeout',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'idleTimeout' : { 'verbose-name' : 'Idle Timeout',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'length' : { 'verbose-name' : 'Length'
+ },
+ 'priority' : { 'verbose-name' : 'Priority',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'tableId' : { 'verbose-name' : 'Table' },
+ 'wildcards' : { 'verbose-name' : 'Wildcards',
+ 'formatter' : fmtcnv.convert_integer_to_bitmask
+ },
+ 'dataLayerSource' : { 'verbose-name' : 'Src MAC',
+ 'formatter' : fmtcnv.replace_host_with_alias
+ },
+ 'dataLayerDestination' : { 'verbose-name' : 'Dst MAC',
+ 'formatter' : fmtcnv.replace_host_with_alias
+ },
+ 'dataLayerType' : { 'verbose-name' : 'Ether Type',
+ 'formatter' : fmtcnv.decode_ether_type
+ },
+ 'dataLayerVirtualLan' : { 'verbose-name' : 'VLAN ID',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'dataLayerVirtualLanPriorityCodePoint' : { 'verbose-name' : 'VLAN PCP'
+ },
+ 'inputPort' : { 'verbose-name' : 'In Port',
+ 'formatter' : fmtcnv.decode_openflow_port
+ },
+ 'networkSource' : { 'verbose-name' : 'Src IP'
+ },
+ 'networkDestination' : { 'verbose-name' : 'Dst IP'
+ },
+ 'networkSourceMaskLen' : { 'verbose-name' : 'Src IP Bits'
+ },
+ 'networkDestinationMaskLen' : { 'verbose-name' : 'Dst IP Bits'
+ },
+ 'networkProtocol' : { 'verbose-name' : 'Protocol',
+ 'formatter' : fmtcnv.decode_network_protocol
+ },
+ 'networkTypeOfService' : { 'verbose-name' : 'TOS Bits'
+ },
+ 'transportSource' : { 'verbose-name' : 'Src Port',
+ 'formatter' : fmtcnv.decode_src_port
+ },
+ 'transportDestination' : { 'verbose-name' : 'Dst Port',
+ 'formatter' : fmtcnv.decode_dst_port
+ },
+ 'actions' : { 'verbose-name' : 'Instructions'
+ },
+ 'vnsName' : { 'verbose-name' : 'VNS'
+ },
+ 'vnsFlowCnt' : { 'verbose-name' : 'Flows'
+ },
+ 'flowEntryCnt' : { 'verbose-name' : 'Flow-Entries'
+ },
+ 'mplsTc' : { 'verbose-name' : 'MPLS TC'
+ },
+ 'mplsLabel' : { 'verbose-name' : 'MPLS Label'
+ },
+ 'mplsBos' : { 'verbose-name' : 'MPLS BOS'
+ },
+ }
+ },
+}
+
+
+
+
+REALTIME_TABLE_ACL_FLOW_FORMAT = {
+ 'realtime_table_acl_flow' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx','byteCount', 'packetCount', 'durationSeconds',
+ 'cookie','priority', 'inputPort', 'dataLayerSource', 'dataLayerDestination',
+ 'dataLayerType', 'networkSource', 'networkDestination', 'networkProtocol',
+ 'transportSource', 'transportDestination''mplsLabel','actions'],
+ 'scoped' : [ 'Idx','byteCount', 'packetCount', 'durationSeconds',
+ 'cookie','priority', 'inputPort', 'dataLayerSource', 'dataLayerDestination',
+ 'dataLayerType', 'networkSource', 'networkDestination', 'networkProtocol',
+ 'transportSource', 'transportDestination','actions'],
+ },
+ 'fields': {
+ 'switch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'flow-brief' : {
+ 'verbose-name' : 'Match',
+ 'formatter' : fmtcnv.realtime_flow_brief,
+ },
+ 'flow-timeout' : {
+ 'verbose-name' : 'H/I',
+ 'formatter' : realtime_flow_timeout,
+ },
+ 'byteCount' : { 'verbose-name': 'Bytes',
+ 'primary_key':True
+ },
+ 'packetCount' : { 'verbose-name' : 'Packets'
+ },
+ 'cookie' : { 'verbose-name' : 'Cookie',
+ #'formatter' : fmtcnv.decode_flow_cookie,
+ },
+ 'durationSeconds' : { 'verbose-name' : 'Dur(s)'
+ },
+ 'durationNanoseconds' : { 'verbose-name' : 'Dur(ns)'
+ },
+ 'hardTimeout' : { 'verbose-name' : 'Hard Timeout',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'idleTimeout' : { 'verbose-name' : 'Idle Timeout',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'length' : { 'verbose-name' : 'Length'
+ },
+ 'priority' : { 'verbose-name' : 'Priority',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'tableId' : { 'verbose-name' : 'Table' },
+ 'wildcards' : { 'verbose-name' : 'Wildcards',
+ 'formatter' : fmtcnv.convert_integer_to_bitmask
+ },
+ 'dataLayerSource' : { 'verbose-name' : 'Src MAC',
+ 'formatter' : fmtcnv.replace_host_with_alias
+ },
+ 'dataLayerDestination' : { 'verbose-name' : 'Dst MAC',
+ 'formatter' : fmtcnv.replace_host_with_alias
+ },
+ 'dataLayerType' : { 'verbose-name' : 'EthType',
+ 'formatter' : fmtcnv.decode_ether_type
+ },
+ 'dataLayerVirtualLan' : { 'verbose-name' : 'VLAN ID',
+ 'formatter' : fmtcnv.convert_signed_short_to_unsigned
+ },
+ 'dataLayerVirtualLanPriorityCodePoint' : { 'verbose-name' : 'VLAN PCP'
+ },
+ 'inputPort' : { 'verbose-name' : 'In Port',
+ 'formatter' : fmtcnv.decode_openflow_port
+ },
+ 'networkSource' : { 'verbose-name' : 'Src IP'
+ },
+ 'networkDestination' : { 'verbose-name' : 'Dst IP'
+ },
+ 'networkSourceMaskLen' : { 'verbose-name' : 'Src IP Bits'
+ },
+ 'networkDestinationMaskLen' : { 'verbose-name' : 'Dst IP Bits'
+ },
+ 'networkProtocol' : { 'verbose-name' : 'Protocol',
+ 'formatter' : fmtcnv.decode_network_protocol
+ },
+ 'networkTypeOfService' : { 'verbose-name' : 'TOS Bits'
+ },
+ 'transportSource' : { 'verbose-name' : 'Src Port',
+ 'formatter' : fmtcnv.decode_src_port
+ },
+ 'transportDestination' : { 'verbose-name' : 'Dst Port',
+ 'formatter' : fmtcnv.decode_dst_port
+ },
+ 'actions' : { 'verbose-name' : 'Instructions'
+ },
+ 'vnsName' : { 'verbose-name' : 'VNS'
+ },
+ 'vnsFlowCnt' : { 'verbose-name' : 'Flows'
+ },
+ 'flowEntryCnt' : { 'verbose-name' : 'Flow-Entries'
+ },
+ 'mplsTc' : { 'verbose-name' : 'MPLS TC'
+ },
+ 'mplsLabel' : { 'verbose-name' : 'MPLS LABEL'
+ },
+ 'mplsBos' : { 'verbose-name' : 'MPLS BOS'
+ },
+ }
+ },
+}
+
+
+REALTIME_AGGREGATE_FORMAT = {
+ 'realtime_aggregate' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'switch', 'flowCount', 'byteCount', 'packetCount' ],
+ 'scoped' : [ 'Idx', 'flowCount', 'byteCount', 'packetCount' ],
+ 'brief' : [ 'Idx', 'switch', 'flowCount', 'byteCount', 'packetCount' ],
+ },
+ 'fields': {
+ 'switch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'length' : { 'verbose-name': 'Length'
+ },
+ 'flowCount' : { 'verbose-name' : 'Flows'
+ },
+ 'byteCount' : { 'verbose-name' : 'Bytes'
+ },
+ 'packetCount' : { 'verbose-name' : 'Packets'
+ },
+ }
+ },
+}
+
+
+REALTIME_DESC_FORMAT = {
+ 'realtime_desc' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'switch', 'serialNumber', 'manufacturerDescription',
+ 'hardwareDescription', 'datapathDescription',
+ 'softwareDescription' ],
+ 'scoped' : [ 'Idx', 'serialNumber', 'manufacturerDescription',
+ 'hardwareDescription', 'datapathDescription',
+ 'softwareDescription' ],
+ 'brief' : [ 'Idx', 'switch', 'serialNumber', 'manufacturerDescription',
+ 'hardwareDescription', 'datapathDescription',
+ 'softwareDescription' ],
+ },
+ 'fields': {
+ 'switch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'softwareDescription' : { 'verbose-name': 'SW Version'
+ },
+ 'datapathDescription' : { 'verbose-name' : 'Model'
+ },
+ 'hardwareDescription' : { 'verbose-name' : 'Make'
+ },
+ 'manufacturerDescription' : { 'verbose-name' : 'Vendor'
+ },
+ 'serialNumber' : { 'verbose-name' : 'Serial #'
+ },
+ }
+ },
+}
+
+
+REALTIME_PORT_FORMAT = {
+ 'realtime_port' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'switch', 'portNumber','portStatus', 'receiveBytes',
+ 'receivePackets', 'receiveErrors', 'receiveDropped',
+ 'receiveCRCErrors', 'receiveOverrunErrors',
+ 'receiveFrameErrors', 'transmitBytes',
+ 'transmitPackets', 'transmitErrors',
+ 'transmitDropped', 'collisions' ],
+ 'details' : [ 'Idx', 'switch', 'portNumber','portStatus', 'receiveBytes',
+ 'receivePackets', 'receiveErrors', 'receiveDropped',
+ 'receiveCRCErrors', 'receiveOverrunErrors',
+ 'receiveFrameErrors', 'transmitBytes',
+ 'transmitPackets', 'transmitErrors',
+ 'transmitDropped', 'collisions' ],
+ 'scoped' : [ 'Idx', 'portNumber','portStatus', 'receiveBytes',
+ 'receivePackets', 'receiveErrors', 'receiveDropped',
+ 'receiveCRCErrors', 'receiveOverrunErrors',
+ 'receiveFrameErrors', 'transmitBytes',
+ 'transmitPackets', 'transmitErrors',
+ 'transmitDropped', 'collisions' ],
+ 'brief' : [ 'Idx', 'switch', 'portNumber','portStatus',
+ 'receiveBytes', 'receivePackets', 'receiveErrors',
+ 'transmitBytes', 'transmitPackets', 'transmitErrors',
+ ]
+ },
+ 'fields': {
+ 'switch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'receiveBytes' : { 'verbose-name' : 'Rcv Bytes',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'receivePackets' : { 'verbose-name' : 'Rcv Pkts',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'receiveErrors' : { 'verbose-name' : 'Rcv Errs',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'receiveDropped' : { 'verbose-name' : 'Rcv Dropped',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'receiveCRCErrors' : { 'verbose-name' : 'Rcv CRC',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'receiveOverrunErrors' : { 'verbose-name' : 'Rcv Overruns',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'receiveFrameErrors' : { 'verbose-name' : 'Rcv Frame Errs',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'transmitBytes' : { 'verbose-name' : 'Xmit Bytes',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'transmitPackets' : { 'verbose-name' : 'Xmit Pkts',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'transmitErrors' : { 'verbose-name' : 'Xmit Errs',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'transmitDropped' : { 'verbose-name' : 'Xmit Dropped',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'collisions' : { 'verbose-name' : 'Collisions',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'portNumber' : { 'verbose-name' : 'OF Port #',
+ 'formatter' : fmtcnv.decode_openflow_port
+ },
+ 'length' : { 'verbose-name' : 'Length'
+ },
+ 'portStatus' : { 'verbose-name' : 'Status'
+ },
+ }
+
+ },
+}
+
+
+REALTIME_GROUP_FORMAT = {
+ 'realtime_group' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'grouptype','groupid' , 'totalpktcnt', 'totalbytecnt',
+ 'bucketpktcnt', 'bucketbytecnt',
+ 'setsrcmac', 'setdstmac',
+ 'pushMplslabel', 'setBos',
+ 'COPY_TTL_OUT','DEC_MPLS_TTL','outport','goToGroup',
+ ],
+ 'scoped' : [ 'Idx', 'grouptype','groupid','totalpktcnt', 'totalbytecnt',
+ 'bucketpktcnt', 'bucketbytecnt',
+ 'setsrcmac', 'setdstmac',
+ 'pushMplsLabel','setBos',
+ 'COPY_TTL_OUT','DEC_MPLS_TTL','outport','goToGroup',
+ ],
+ },
+ 'fields': {
+ 'groupid' : { 'verbose-name' : 'Group Id',
+ },
+ 'grouptype' : { 'verbose-name' : 'Group Type',
+ },
+ 'totalpktcnt' : { 'verbose-name' : 'Pkts',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'totalbytecnt' : { 'verbose-name' : 'Bytes',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'bucketpktcnt' : { 'verbose-name' : 'Bucket Pkts',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'bucketbytecnt' : { 'verbose-name' : 'Bucket Bytes',
+ 'formatter' : fmtcnv.decode_port_counter
+ },
+ 'setsrcmac' : { 'verbose-name' : 'Set Src Mac',
+ },
+ 'setdstmac' : { 'verbose-name' : 'Set Dst Mac',
+ },
+ 'pushMplsLabel' : { 'verbose-name' : 'Push Mpls',
+ },
+ 'setBos' : { 'verbose-name' : 'Set Bos',
+ },
+ 'outport' : { 'verbose-name' : 'Outport',
+ },
+ 'goToGroup' : { 'verbose-name' : 'Group',
+ },
+ 'COPY_TTL_OUT' : { 'verbose-name' : 'COPY TTL',
+ },
+ 'DEC_MPLS_TTL' : { 'verbose-name' : 'Dec Mpls TTL',
+ },
+ }
+ },
+}
+
+
+REALTIME_TABLE_FORMAT = {
+ 'realtime_table' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'switch', 'name', 'tableId', 'wildcards',
+ 'maximumEntries', 'lookupCount', 'matchedCount', 'activeCount' ],
+ 'scoped' : [ 'Idx','name', 'tableId', 'wildcards',
+ 'maximumEntries', 'lookupCount', 'matchedCount', 'activeCount' ],
+ 'brief' : [ 'Idx', 'switch', 'name', 'tableId', 'wildcards',
+ 'maximumEntries', 'lookupCount', 'matchedCount', 'activeCount' ],
+ },
+ 'fields': {
+ 'switch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'wildcards' : { 'verbose-name': 'Wildcards'
+ },
+ 'matchedCount' : { 'verbose-name' : '# Matched'
+ },
+ 'maximumEntries' : { 'verbose-name' : 'Maximum Entries'
+ },
+ 'name' : { 'verbose-name' : 'Name'
+ },
+ 'activeCount' : { 'verbose-name' : '# Active'
+ },
+ 'length' : { 'verbose-name' : 'Length'
+ },
+ 'tableId' : { 'verbose-name' : 'Table ID'
+ },
+ 'lookupCount' : { 'verbose-name' : '# Lookups'
+ },
+ }
+ },
+}
+
+SHOW_TUNNEL_FORMAT = {
+ 'show_tunnel' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'tunnelId', 'policies','tunnelPath','labelStack',],
+ 'details' : [ 'Idx', 'tunnelId', 'policies','tunnelPath','labelStack', 'dpidGroup',],
+ },
+ 'fields': {
+ 'tunnelId' : { 'verbose-name' : 'Id',
+ },
+ 'dpidGroup' : { 'verbose-name' : 'Dpid(Node Id)/Group',
+ },
+ 'labelStack' : { 'verbose-name' : 'Label Stack [Outer-->Inner]',
+ },
+ 'tunnelPath' : { 'verbose-name' : 'Tunnel Path [Head-->Tail]',
+ },
+ }
+ },
+}
+
+SHOW_POLICY_FORMAT = {
+ 'show_policy' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'policyId', 'policyType','priority','dstMacAddress','srcMacAddress',
+ 'etherType','dstIpAddress' ,'ipProtocolNumber','srcIpAddress', 'dstTcpPortNumber',
+ 'srcTcpPortNumber','tunnelId'
+ ]
+ },
+ 'fields': {
+ 'policyId' : { 'verbose-name' : 'Policy Id',
+ },
+ 'policyType' : { 'verbose-name': 'Policy Type',
+ },
+ 'dstMacAddress' : { 'verbose-name': 'Dst Mac',
+ },
+ 'srcMacAddress' : { 'verbose-name': 'Src Mac',
+ },
+ 'dstIpAddress' : { 'verbose-name': 'Dst IP',
+ },
+ 'srcIpAddress' : { 'verbose-name': 'Src IP',
+ },
+ 'dstTcpPortNumber' : { 'verbose-name': 'Dst TcpPort',
+ },
+ 'srcTcpPortNumber' : { 'verbose-name': 'Src TcpPort',
+ },
+ 'etherType' : { 'verbose-name': 'Ether Type',
+ },
+
+ 'ipProtocolNumber' : { 'verbose-name': 'IP Protocol',
+ },
+ 'tunnelId' : { 'verbose-name': 'Tunnel Used',
+ },
+
+ }
+ },
+}
+
+
+
+REALTIME_FEATURES_FORMAT = {
+ 'realtime_features' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'switch', 'portNumber', 'name', 'hardwareAddress',
+ 'config', 'state', 'currentFeatures', 'advertisedFeatures',
+ 'supportedFeatures', 'peerFeatures'],
+ 'scoped' : [ 'Idx', 'portNumber', 'name', 'hardwareAddress',
+ 'config', 'state', 'currentFeatures', 'advertisedFeatures',
+ 'supportedFeatures', 'peerFeatures'],
+ 'brief' : [ 'Idx', 'switch', 'portNumber', 'name',
+ 'currentFeatures', 'advertisedFeatures',
+ 'supportedFeatures', 'peerFeatures'],
+ },
+ 'fields': {
+ 'switch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'portNumber' : { 'verbose-name': 'OF Port #',
+ 'formatter' : fmtcnv.decode_openflow_port
+ },
+ 'hardwareAddress' : { 'verbose-name' : 'HW Mac Address'
+ },
+ 'name' : { 'verbose-name' : 'Name'
+ },
+ 'config' : { 'verbose-name' : 'Config',
+ 'formatter' : fmtcnv.decode_port_config
+ },
+ 'state' : { 'verbose-name' : 'State',
+ 'formatter' : fmtcnv.decode_port_up_down
+ },
+ 'stp-state' : { 'verbose-name' : 'STP State',
+ 'formatter' : fmtcnv.decode_port_stp_state
+ },
+ 'currentFeatures' : { 'verbose-name' : 'Current',
+ 'formatter' : fmtcnv.decode_port_features
+ },
+ 'advertisedFeatures' : { 'verbose-name' : 'Advertised',
+ 'formatter' : fmtcnv.decode_port_features
+ },
+ 'supportedFeatures' : { 'verbose-name' : 'Supported',
+ 'formatter' : fmtcnv.decode_port_features
+ },
+ 'peerFeatures' : { 'verbose-name' : 'Peer',
+ 'formatter' : fmtcnv.decode_port_features
+ },
+ }
+ },
+}
+
+
+REALTIME_QUEUE_FORMAT = {
+ 'realtime_queue' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'switch', 'portNumber',
+ 'queueId', 'transmitBytes', 'transmitPackets', 'transmitErrors',
+ ],
+ 'scoped' : [ 'Idx', 'portNumber',
+ 'queueId', 'transmitBytes', 'transmitPackets', 'transmitErrors',
+ ],
+ 'brief' : [ 'Idx', 'switch', 'portNumber',
+ 'queueId', 'transmitBytes', 'transmitPackets', 'transmitErrors',
+ ],
+ },
+
+ 'fields' : {
+ 'switch' : { 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'portNumber' : { 'verbose-name': 'OF Port #',
+ 'formatter' : fmtcnv.decode_openflow_port
+ },
+ 'queueId' : { 'verbose-name' : 'Queue ID',
+ },
+ 'transmitBytes' : { 'verbose-name' : 'Xmit Bytes'
+ },
+ 'transmitPackets' : { 'verbose-name' : 'Xmit Pkts'
+ },
+ 'transmitErrors' : { 'verbose-name' : 'Xmit Errors'
+ },
+ }
+ },
+}
+
+
+
+
+ROUTER_FORMAT = {
+ 'router' : {
+ 'field-orderings' : {
+ 'default' : ['Idx','dpid','name', 'routerIP','routerMac','isEdgeRouter','nodeSId'
+ ],
+ },
+ 'fields': {
+ 'dpid' : { 'verbose-name' : 'Router DPID',
+ #'formatter' : fmtcnv.eprint_switch_and_alias,
+ },
+ 'name' : { 'verbose-name' : 'Router Name',
+ #'formatter' : fmtcnv.decode_port_counter
+ },
+ 'routerIP' : { 'verbose-name' : 'Router IP',
+ },
+ 'routerMac' : { 'verbose-name' : 'Router Mac',
+ #'formatter' : fmtcnv.decode_port_counter
+ },
+ 'isEdgeRouter' : { 'verbose-name' : 'Edge Router',
+ #'formatter' : fmtcnv.decode_port_counter
+ },
+ 'nodeSId' : { 'verbose-name' : 'Node SId',
+ #'formatter' : fmtcnv.decode_port_counter
+ },
+ }
+ },
+}
+
+#adjacency
+ROUTER_ADJACENCY_FORMAT= {
+ 'router_adjacency' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'adjacencySid', 'ports'],
+ 'scoped' : [ 'Idx', 'adjacencySid', 'ports'],
+ },
+ 'fields': {
+ 'adjacencySid' : { 'verbose-name' : 'Adjacency Sid(s)',
+ },
+
+ },
+
+ },
+}
+
+ROUTER_PORT_FORMAT = {
+ 'router_port' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'name', 'portNo', 'subnetIp','adjacency'],
+ 'scoped' : [ 'Idx', 'name', 'portNo', 'subnetIp','adjacency'],
+ },
+ 'fields': {
+ 'adjacency' : { 'verbose-name' : 'Adjacency Sid(s)',
+ },
+ 'portNo' : { 'verbose-name' : 'Port #',
+ },
+ 'subnetIp' : { 'verbose-name' : 'Subnet',
+ },
+
+ },
+ }
+}
+
+"""
+SWITCH_CLUSTER_FORMAT = {
+ 'switch-cluster' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'cluster-id', 'switches', ],
+ },
+ 'fields' : {
+ 'cluster-id' : { 'formatter' : fmtcnv.print_cluster_id,
+ },
+ 'switches' : { 'formatter' : fmtcnv.print_switches
+ },
+ }
+ },
+}
+
+BROADCAST_DOMAIN_FORMAT = {
+ 'external-ports' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'ports', ],
+ },
+ 'fields' : {
+ 'ports' : { 'verbose-name': 'Switch Ports',
+ 'formatter' : fmtcnv.print_switch_port_list,
+ },
+ }
+ },
+}
+
+TECH_SUPPORT_CONFIG_FORMAT = {
+ 'tech-support-config' : {
+ 'field-orderings' : {
+ 'default' : [ 'cmd-type',
+ 'cmd'
+ ],
+ },
+ },
+}
+
+
+VERSION_FORMAT = {
+ 'version' : {
+ 'field-orderings' : {
+ 'details' : [ 'controller' ]
+ },
+
+ 'fields' : {
+ 'controller' : {
+ 'verbose-name' : 'Controller version',
+ }
+ }
+ },
+}
+
+
+SYSTEM_CLOCK_FORMAT = {
+ 'system-clock' : {
+ 'field-orderings' : {
+ 'default' : [ 'time' ],
+ 'details' : [ 'time', 'tz' ]
+ },
+
+ 'fields' : {
+ 'time' : {
+ },
+ 'tz' : { 'verbose-name' : 'Timezone'
+ },
+ },
+ },
+}
+"""
diff --git a/cli/desc/version200/core_model.py b/cli/desc/version200/core_model.py
new file mode 100755
index 0000000..05d2288
--- /dev/null
+++ b/cli/desc/version200/core_model.py
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_disable_submode('tech-support-config')
+command.model_obj_type_disable_submode('image-drop-user')
+command.model_obj_type_disable_submode('vlan-config')
+
+command.model_obj_type_disable_edit('tag', 'name')
+command.model_obj_type_disable_edit('tag', 'namespace')
+command.model_obj_type_disable_edit('tag', 'value')
+command.model_obj_type_disable_edit('tag', 'persist')
+
diff --git a/cli/desc/version200/flow_entry.py b/cli/desc/version200/flow_entry.py
new file mode 100755
index 0000000..13213ab
--- /dev/null
+++ b/cli/desc/version200/flow_entry.py
@@ -0,0 +1,493 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import fmtcnv
+
+"""
+FLOW_ENTRY_SUBMODE_COMMAND_DESCRIPTION = {
+ 'name' : 'flow-entry',
+ 'mode' : 'config-switch*',
+ 'command-type' : 'config-submode',
+ 'short-help' : 'Enter flow-entry submode, configure single static flow entry',
+ 'doc' : 'flow-entry|flow-entry',
+ 'doc-example' : 'flow-entry|flow-entry-example',
+ 'obj-type' : 'flow-entry',
+ 'parent-field' : 'switch',
+ 'submode-name' : 'config-switch-flow-entry',
+ 'args' : {
+ 'field' : 'name',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ 'scoped' : True,
+ 'syntax-help' : 'Enter name for a flow-entry',
+ },
+}
+
+# obj_type flow-entry field hard-timeout
+FLOW_ENTRY_EDIT_HARD_TIMEOUT_COMMAND_DESCRIPTION = {
+ 'name' : 'hard-timeout',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Set hard-timeout for this flow',
+ 'doc' : 'flow-entry|hard-timeout',
+ 'doc-example' : 'flow-entry|hard-timeout-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'hard-timeout',
+ 'base-type' : 'integer',
+ 'range' : (0, 65535),
+ 'doc' : 'flow-entry|hard-timeout-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field idle-timeout
+FLOW_ENTRY_EDIT_IDLE_TIMEOUT_COMMAND_DESCRIPTION = {
+ 'name' : 'idle-timeout',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Set idle-timout for this flow',
+ 'doc' : 'flow-entry|idle-timeout',
+ 'doc-example' : 'flow-entry|idle-timeout-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'idle-timeout',
+ 'base-type' : 'integer',
+ 'range' : (0, 65535),
+ 'doc' : 'flow-entry|idle-timeout-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field actions
+FLOW_ENTRY_EDIT_ACTIONS_COMMAND_DESCRIPTION = {
+ 'name' : 'actions',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Set actions for this flow',
+ 'doc' : 'flow-entry|actions',
+ 'doc-example' : 'flow-entry|actions-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'actions',
+ 'type' : 'string',
+ 'completion' : 'complete-staticflow-actions',
+ 'doc' : 'flow-entry|action-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field active
+FLOW_ENTRY_EDIT_ACTIVE_COMMAND_DESCRIPTION = {
+ 'name' : 'active',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Set flow active',
+ 'doc' : 'flow-entry|active',
+ 'doc-example' : 'flow-entry|active-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ # this should be improved, but this is the old syntax
+ 'field' : 'active',
+ 'type' : 'enum',
+ 'values' : ('True', 'False'),
+ 'doc' : 'flow-entry|active-field-+',
+ # XXX roth -- does not show up in wiki
+ }
+ )
+}
+
+
+# obj_type flow-entry field priority
+FLOW_ENTRY_EDIT_PRIORITY_COMMAND_DESCRIPTION = {
+ 'name' : 'priority',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Set priority of the flow',
+ 'doc' : 'flow-entry|priority',
+ 'doc-example' : 'flow-entry|priority-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'priority',
+ 'base-type' : 'integer',
+ 'range' : (0, 65535),
+ 'doc' : 'flow-entry|priority-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field cookie
+FLOW_ENTRY_EDIT_COOKIE_COMMAND_DESCRIPTION = {
+ 'name' : 'cookie',
+ 'mode' : 'config-switch-flow-entry',
+ 'command-type' : 'config',
+ 'short-help' : 'Associate cookie for flow',
+ 'doc' : 'flow-entry|cookie',
+ 'doc-example' : 'flow-entry|cookie-example',
+ 'args' : (
+ {
+ 'field' : 'cookie',
+ 'type' : 'integer',
+ }
+ )
+}
+
+
+# obj_type flow-entry field wildcards
+FLOW_ENTRY_EDIT_WILDCARDS_COMMAND_DESCRIPTION = {
+ 'name' : 'wildcards',
+ 'mode' : 'config-switch-flow-entry',
+ 'command-type' : 'config',
+ 'short-help' : 'Configure wildcards for flow',
+ 'doc' : 'flow-entry|wildcards',
+ 'doc-example' : 'flow-entry|wildcards-example',
+ 'args' : (
+ {
+ 'field' : 'wildcards',
+ 'base-type' : 'integer',
+ 'range' : (0, 2**32-1),
+ 'doc' : 'flow-entry|wildcards-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field ingress-port
+FLOW_ENTRY_EDIT_INGRESS_PORT_COMMAND_DESCRIPTION = {
+ 'name' : 'ingress-port',
+ 'mode' : 'config-switch-flow-entry',
+ 'command-type' : 'config',
+ 'short-help' : 'Configure wildcards for flow',
+ 'doc' : 'flow-entry|ingress-port',
+ 'doc-example' : 'flow-entry|ingress-port-example',
+ 'args' : (
+ {
+ 'field' : 'ingress-port',
+ 'base-type' : 'integer',
+ 'range' : (0, 2**16-1), # OF V2 uses 2^32 for ports
+ 'doc' : 'flow-entry|ingress-port-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field src-mac
+FLOW_ENTRY_EDIT_SRC_MAC_COMMAND_DESCRIPTION = {
+ 'name' : 'src-mac',
+ 'mode' : 'config-switch-flow-entry',
+ 'command-type' : 'config',
+ 'short-help' : 'Configure src-mac match for flow',
+ 'doc' : 'flow-entry|src-mac',
+ 'doc-example' : 'flow-entry|src-mac-example',
+ 'obj-type' : 'flow-entry',
+ 'args' : (
+ {
+ 'field' : 'src-mac',
+ 'type' : 'host',
+ 'completion' : 'complete-alias-choice',
+ 'other' : 'host|mac',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'flow-entry|src-mac-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field dst-mac
+FLOW_ENTRY_EDIT_DST_MAC_COMMAND_DESCRIPTION = {
+ 'name' : 'dst-mac',
+ 'mode' : 'config-switch-flow-entry',
+ 'command-type' : 'config',
+ 'short-help' : 'Configure dst-mac match for flow',
+ 'doc' : 'flow-entry|dst-mac',
+ 'doc-example' : 'flow-entry|dst-mac-example',
+ 'obj-type' : 'flow-entry',
+ 'args' : (
+ {
+ 'field' : 'dst-mac',
+ 'type' : 'host',
+ 'completion' : 'complete-alias-choice',
+ 'other' : 'host|mac',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'flow-entry|dst-mac-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field vlan-id
+FLOW_ENTRY_EDIT_VLAN_ID_COMMAND_DESCRIPTION = {
+ 'name' : 'vlan-id',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Configure vlan-id match for flow',
+ 'doc' : 'flow-entry|vlan-id',
+ 'doc-example' : 'flow-entry|vlan-id-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'vlan-id',
+ 'base-type' : 'integer',
+ 'range' : (0, 2**12-1),
+ 'doc' : 'flow-entry|vlan-id-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field vlan-priority
+FLOW_ENTRY_EDIT_VLAN_PRIORITY_COMMAND_DESCRIPTION = {
+ 'name' : 'vlan-priority',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Configure vlan-priority match for flow',
+ 'doc' : 'flow-entry|vlan-priority',
+ 'doc-example' : 'flow-entry|vlan-priority-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'vlan-priority',
+ 'base-type' : 'integer',
+ 'range' : (0,7),
+ 'doc' : 'flow-entry|vlan-priority-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field ether-type
+FLOW_ENTRY_EDIT_ETHER_TYPE_COMMAND_DESCRIPTION = {
+ 'name' : 'ether-type',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Configure ether-type match for flow',
+ 'doc' : 'flow-entry|ether-type',
+ 'doc-example' : 'flow-entry|ether-type-example',
+ 'command-type' : 'config',
+ 'args' : {
+ 'choices' : (
+ {
+ 'field' : 'ether-type',
+ 'base-type' : 'hex-or-decimal-integer',
+ 'range' : (1536,65536),
+ 'data-handler' : 'hex-to-integer',
+ 'doc' : 'flow-entry|ether-type-field',
+ },
+ {
+ 'field' : 'ether-type',
+ 'type' : 'enum',
+ 'values' : fmtcnv.ether_type_to_number_dict,
+ },
+ ),
+ },
+}
+
+
+# obj_type flow-entry field tos-bits
+FLOW_ENTRY_EDIT_TOS_BITS_COMMAND_DESCRIPTION = {
+ 'name' : 'tos-bits',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Configure ether-type match for flow',
+ 'doc' : 'flow-entry|tos-bits',
+ 'doc-example' : 'flow-entry|tos-bits-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'tos-bits',
+ 'base-type' : 'integer',
+ 'range' : (0,63),
+ 'doc' : 'flow-entry|tos-bits-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field protocol
+FLOW_ENTRY_EDIT_PROTOCOL_COMMAND_DESCRIPTION = {
+ 'name' : 'protocol',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Configure ether-type match for flow',
+ 'doc' : 'flow-entry|protocol',
+ 'doc-example' : 'flow-entry|protocol-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'protocol',
+ 'base-type' : 'integer',
+ 'range' : (0,255),
+ 'doc' : 'flow-entry|protocol-field',
+ }
+ )
+}
+
+
+# obj_type flow-entry field src-ip
+FLOW_ENTRY_EDIT_SRC_IP_COMMAND_DESCRIPTION = {
+ 'name' : 'src-ip',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Configure src-ip match for flow',
+ 'doc' : 'flow-entry|src-ip',
+ 'doc-example' : 'flow-entry|src-ip-example',
+ 'command-type' : 'config',
+ 'args' : {
+ 'choices' : (
+ {
+ 'field' : 'src-ip',
+ 'help-name' : 'ip-address',
+ 'type' : 'ip-address',
+ 'completion-text' : 'src-ip-address',
+ 'doc' : 'flow-entry|src-ip-field',
+ },
+ {
+ 'field' : 'src-ip',
+ 'help-name' : 'cidr-range',
+ 'type' : 'cidr-range',
+ 'completion-text' : 'src-ip-cidr-range',
+ 'doc' : 'flow-entry|src-ip-field',
+ },
+ )
+ },
+}
+
+
+# obj_type flow-entry field dst-ip
+FLOW_ENTRY_EDIT_DST_IP_COMMAND_DESCRIPTION = {
+ 'name' : 'dst-ip',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Configure dst-ip match for flow',
+ 'doc' : 'flow-entry|dst-ip',
+ 'doc-example' : 'flow-entry|dst-ip-example',
+ 'command-type' : 'config',
+ 'args' : {
+ 'choices' : (
+ {
+ 'field' : 'dst-ip',
+ 'help-name' : 'ip-address',
+ 'type' : 'ip-address',
+ 'completion-text' : 'dst-ip-address',
+ 'doc' : 'flow-entry|dst-ip-field',
+ },
+ {
+ 'field' : 'dst-ip',
+ 'help-name' : 'cidr-range',
+ 'type' : 'cidr-range',
+ 'completion-text' : 'dst-ip-cidr-range',
+ 'doc' : 'flow-entry|dst-ip-field',
+ },
+ )
+ },
+}
+
+
+# obj_type flow-entry field src-port
+FLOW_ENTRY_EDIT_SRC_PORT_COMMAND_DESCRIPTION = {
+ 'name' : 'src-port',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Configure src-port match for flow',
+ 'doc' : 'flow-entry|src-port',
+ 'doc-example' : 'flow-entry|src-port-example',
+ 'command-type' : 'config',
+ 'args' : {
+ 'choices' : (
+ {
+ 'field' : 'src-port',
+ 'base-type' : 'hex-or-decimal-integer',
+ 'range' : (0,65535),
+ 'data-handler' : 'hex-to-integer',
+ 'doc' : 'flow-entry|src-port-field',
+ },
+ {
+ 'field' : 'src-port',
+ 'type' : 'enum',
+ 'values' : fmtcnv.tcp_name_to_number_dict,
+ },
+ )
+ }
+}
+
+
+# obj_type flow-entry field dst-port
+FLOW_ENTRY_EDIT_DST_PORT_COMMAND_DESCRIPTION = {
+ 'name' : 'dst-port',
+ 'mode' : 'config-switch-flow-entry',
+ 'short-help' : 'Configure dst-port match for flow',
+ 'doc' : 'flow-entry|dst-port',
+ 'doc-example' : 'flow-entry|dst-port-example',
+ 'command-type' : 'config',
+ 'args' : {
+ 'choices' : (
+ {
+ 'field' : 'dst-port',
+ 'base-type' : 'hex-or-decimal-integer',
+ 'range' : (0,65535),
+ 'data-handler' : 'hex-to-integer',
+ 'doc' : 'flow-entry|dst-port-field',
+ },
+ {
+ 'field' : 'dst-port',
+ 'type' : 'enum',
+ 'values' : fmtcnv.tcp_name_to_number_dict,
+ },
+ )
+ },
+}
+#
+# FORMATS
+#
+
+import fmtcnv
+
+
+FLOW_ENTRY_FORMAT = {
+ 'flow-entry' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx',
+ 'switch',
+ 'name',
+ 'active',
+ 'idle-timeout',
+ 'hard-timeout',
+ 'cookie',
+ 'priority',
+ 'wildcards',
+ 'ingress-port',
+ 'src-mac',
+ 'dst-mac',
+ 'ether-type',
+ 'vlan-id',
+ 'vlan-priority',
+ 'src-ip',
+ 'dst-ip',
+ 'protocol',
+ 'tos-bits',
+ 'src-port',
+ 'dst-port',
+ 'actions',
+ ]
+ },
+ 'fields' : {
+ 'switch' : { 'formatter' : fmtcnv.replace_switch_with_alias },
+ 'ether-type' : { 'formatter' : fmtcnv.decode_ether_type },
+ 'protocol' : { 'formatter' : fmtcnv.decode_network_protocol },
+ 'src-port' : { 'formatter' : fmtcnv.decode_src_port },
+ 'dst-port' : { 'formatter' : fmtcnv.decode_dst_port },
+ 'ingress-port' : { 'formatter' : fmtcnv.decode_openflow_port },
+ },
+ },
+}
+"""
+
diff --git a/cli/desc/version200/flow_entry_model.py b/cli/desc/version200/flow_entry_model.py
new file mode 100755
index 0000000..897f0a3
--- /dev/null
+++ b/cli/desc/version200/flow_entry_model.py
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_disable_submode('flow-entry')
+
+command.model_obj_type_enable_cascade_delete('flow-entry')
+
+command.model_obj_type_disable_edit('flow-entry', 'hard-timeout')
+command.model_obj_type_disable_edit('flow-entry', 'idle-timeout')
+command.model_obj_type_disable_edit('flow-entry', 'actions')
+command.model_obj_type_disable_edit('flow-entry', 'active')
+command.model_obj_type_disable_edit('flow-entry', 'priority')
+command.model_obj_type_disable_edit('flow-entry', 'cookie')
+command.model_obj_type_disable_edit('flow-entry', 'wildcards')
+command.model_obj_type_disable_edit('flow-entry', 'ingress-port')
+command.model_obj_type_disable_edit('flow-entry', 'src-mac')
+command.model_obj_type_disable_edit('flow-entry', 'dst-mac')
+command.model_obj_type_disable_edit('flow-entry', 'vlan-id')
+command.model_obj_type_disable_edit('flow-entry', 'vlan-priority')
+command.model_obj_type_disable_edit('flow-entry', 'ether-type')
+command.model_obj_type_disable_edit('flow-entry', 'tos-bits')
+command.model_obj_type_disable_edit('flow-entry', 'protocol')
+command.model_obj_type_disable_edit('flow-entry', 'src-ip')
+command.model_obj_type_disable_edit('flow-entry', 'dst-ip')
+command.model_obj_type_disable_edit('flow-entry', 'src-port')
+command.model_obj_type_disable_edit('flow-entry', 'dst-port')
+
+
diff --git a/cli/desc/version200/forwarding.py b/cli/desc/version200/forwarding.py
new file mode 100755
index 0000000..52c5673
--- /dev/null
+++ b/cli/desc/version200/forwarding.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+"""
+# CLI for forwarding configuration
+#
+
+# --------------------------------------------------------------------------------
+# Create new CLI command for forwarding
+#
+
+FORWARDING_CONFIG_COMMAND_DESCRIPTION = {
+ 'name' : 'forwarding',
+ 'mode' : 'config',
+ 'short-help' : 'Configure forwarding service properties',
+ 'doc' : 'forwarding|forwarding',
+ 'doc-example' : 'forwarding|forwarding-example',
+ 'command-type' : 'config-object',
+ 'obj-type' : 'forwarding-config',
+ 'args': (
+ {
+ 'choices' : (
+ {
+ 'args' : (
+ {
+ 'token' : 'access-priority',
+ 'completion-text' : 'access-priority',
+ 'short-help' : 'Set proprity for flows created by the forwarding service on an access switch',
+ 'doc' : 'forwarding|forwarding-access-priority',
+ 'match-for-no' : True,
+ },
+ {
+ 'field' : 'access-priority',
+ 'short-help' : 'Set proprity for flows created by the forwarding service on an access switch',
+ 'doc' : 'forwarding|forwarding-access-priority',
+ 'type' : 'integer',
+ 'range' : (0, 2**15-1),
+ 'completion-text' : '0-32767',
+ 'match-for-no' : True,
+ 'optional-for-no' : True,
+ 'data' : {
+ 'id' : 'forwarding',
+ 'access-priority': '$data',
+ },
+ },
+ ),
+ },
+ {
+ 'args' : (
+ {
+ 'token' : 'core-priority',
+ 'completion-text' : 'core-priority',
+ 'short-help' : 'Set proprity for flows created by the forwarding service on a core switch',
+ 'doc' : 'forwarding|forwarding-core-priority',
+ 'match-for-no' : True,
+ },
+ {
+ 'field' : 'core-priority',
+ 'short-help' : 'Set proprity for flows created by the forwarding service on a core switch',
+ 'doc' : 'forwarding|forwarding-core-priority',
+ 'type' : 'integer',
+ 'range' : (0, 2**15-1),
+ 'completion-text' : '0-32767',
+ 'match-for-no' : True,
+ 'optional-for-no' : True,
+ 'data' : {
+ 'id' : 'forwarding',
+ 'core-priority' : '$data',
+ },
+ },
+ ),
+ },
+ ),
+ },
+ ),
+}
+"""
+# --------------------------------------------------------------------------------
diff --git a/cli/desc/version200/forwarding_model.py b/cli/desc/version200/forwarding_model.py
new file mode 100755
index 0000000..a6946f4
--- /dev/null
+++ b/cli/desc/version200/forwarding_model.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# CLI for forwarding configuration
+#
+
+# --------------------------------------------------------------------------------
+# Disable direct access to forwarding-config, use the new CLI instead
+#
+
+import command
+command.model_obj_type_disable_submode('forwarding-config')
+
+# --------------------------------------------------------------------------------
diff --git a/cli/desc/version200/forwarding_run_config.py b/cli/desc/version200/forwarding_run_config.py
new file mode 100755
index 0000000..4790bef
--- /dev/null
+++ b/cli/desc/version200/forwarding_run_config.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# CLI for forwarding configuration
+#
+
+# --------------------------------------------------------------------------------
+# Update running config
+#
+
+import run_config
+def running_config_forwarding(context, config, words):
+ t_obj_type = 'forwarding-config'
+
+ forwarding_table = context.get_table_from_store(t_obj_type)
+ if len(forwarding_table) > 1:
+ print 'running_config_forwarding: more than one forwarding record'
+ if len(forwarding_table) == 0:
+ return
+
+ forwarding_config = forwarding_table[0]
+ newline_printed = False
+ if run_config.not_default_value(
+ t_obj_type, 'access-priority',
+ forwarding_config.get('access-priority')):
+ if newline_printed is False:
+ newline_printed = True
+ config.append("!\n")
+ config.append(
+ 'forwarding access-priority %s\n' %
+ forwarding_config.get('access-priority'))
+ if run_config.not_default_value(
+ t_obj_type, 'core-priority',
+ forwarding_config.get('core-priority')):
+ if newline_printed is False:
+ newline_printed = True
+ config.append("!\n")
+ config.append(
+ 'forwarding core-priority %s\n' %
+ forwarding_config.get('core-priority'))
+
+forwarding_running_config_tuple = (
+ (
+ {
+ 'optional' : False,
+ 'field' : 'running-config',
+ 'type' : 'enum',
+ 'values' : 'forwarding',
+ 'short-help' : 'Forwarding Configuration',
+ 'doc' : 'running-config|forwarding-show',
+ },
+ ),
+)
+run_config.register_running_config('forwarding', 2200, None,
+ running_config_forwarding,
+ forwarding_running_config_tuple)
+
+# --------------------------------------------------------------------------------
diff --git a/cli/desc/version200/host.py b/cli/desc/version200/host.py
new file mode 100755
index 0000000..b65bb4e
--- /dev/null
+++ b/cli/desc/version200/host.py
@@ -0,0 +1,650 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+"""
+HOST_SUBMODE_COMMAND_DESCRIPTION = {
+ 'name' : 'host',
+ 'obj-type' : 'host-config',
+ 'mode' : 'config*',
+ 'command-type' : 'config-submode',
+ 'parent-field' : None,
+ 'current-mode-obj-id' : None,
+ 'submode-name' : 'config-host',
+ 'short-help' : 'Host submode, configure host details',
+ 'doc' : 'host|host',
+ 'doc-example' : 'host|host-example',
+ 'data' : {
+ 'address-space' : 'default',
+ 'vlan' : '',
+ },
+ 'args' : (
+ {
+ 'field' : 'address-space',
+ 'tag' : 'address-space',
+ 'type' : 'string',
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'completion' : 'complete-from-another',
+ 'other' : 'address-space',
+ 'doc' : 'host|host-address-space',
+ },
+ {
+ 'field' : 'vlan',
+ 'tag' : 'vlan',
+ 'type' : 'integer',
+ 'range' : (0,4095),
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'doc' : 'host|host-vlan',
+ },
+ {
+ 'field' : 'mac',
+ 'type' : 'host',
+ 'completion' : [ 'complete-alias-choice',
+ ],
+ 'other' : 'host',
+ 'scoped' : True,
+ 'data-handler' : 'alias-to-value',
+ }
+ )
+}
+"""
+
+host_show_mac_action = (
+ {
+ 'proc' : 'query-table',
+ 'obj-type' : 'host',
+ },
+ { # add any associated tags
+ 'proc' : 'join-table',
+ 'obj-type' : 'tag-mapping',
+ 'key' : 'mac',
+ 'key-value' : 'tag', # causes list creation for multiple matches
+ 'join-field' : 'mac',
+ 'add-field' : 'tag',
+ },
+ {
+ 'proc' : 'display',
+ 'format' : 'host',
+ },
+)
+
+
+HOST_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show host summaries',
+ 'doc' : 'host|show',
+ 'doc-example' : 'host|show-example',
+ 'no-supported' : False,
+ 'command-type' : 'display-table',
+ 'args' : (
+ {
+ 'token' : 'host',
+ 'action' : host_show_mac_action,
+ }
+ )
+}
+
+HOST_SHOW_MAC_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show host details based on query',
+ 'doc' : 'host|show-host',
+ 'doc-example' : 'host|show-host-example',
+ 'no-supported' : False,
+ 'command-type' : 'display-table',
+ 'obj-type' : 'host',
+ 'action' : host_show_mac_action,
+ 'args' : (
+ 'host',
+ {
+ 'choices' : (
+ {
+ 'field' : 'mac',
+ 'type' : 'host',
+ 'short-help' : 'Show the hosts with the given MAC or alias',
+ 'help-name' : 'host mac or alias',
+ 'completion' : 'complete-alias-choice',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'host|show-host-mac',
+ },
+ {
+ 'field' : 'address-space',
+ 'short-help' : 'Show the hosts with the given IPv4 address',
+ 'tag' : 'address-space',
+ 'type' : 'identifier',
+ 'help-name' : 'address space',
+ 'completion' : 'complete-object-field',
+ 'doc' : 'host|show-host-address-space',
+ },
+ {
+ 'field' : 'ipv4',
+ 'short-help' : 'Show the hosts with the given IPv4 address',
+ 'tag' : 'ip-address',
+ 'type' : 'ip-address',
+ 'help-name' : 'ip address',
+ 'completion' : 'complete-object-field',
+ 'doc' : 'host|show-host-ipv4',
+ },
+ {
+ 'field' : 'dpid',
+ 'short-help' : 'Show the hosts attached to the given switch',
+ 'tag' : 'switch',
+ 'type' : 'dpid',
+ 'help-name' : 'switch dpid or alias',
+ 'completion' : 'complete-object-field',
+ #'completion' : 'complete-alias-choice',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'host|show-host-switch',
+ },
+ {
+ 'field' : 'host',
+ 'short-help': 'Show all hosts',
+ 'type' : 'enum',
+ 'values' : 'all',
+ 'doc' : 'host|show-host-all',
+ },
+ )
+ },
+ {
+ 'optional' : True,
+ 'choices' : (
+ (
+ {
+ 'token' : 'by',
+ 'short-help' : 'Sort displayed hosts',
+ 'doc' : 'reserved|by',
+ },
+ {
+ 'token' : 'last-seen',
+ 'short-help': 'Sort by the last seen time',
+ 'sort' : '-last-seen',
+ 'action' : 'display-table',
+ 'doc' : 'host|show-host-by-last-seen',
+ },
+ ),
+ )
+ },
+ {
+ 'optional' : True,
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'short-help' : 'Display either detailed or brief information',
+ 'values' : ('details','brief'),
+ 'doc' : 'format|+',
+ },
+ )
+}
+
+
+HOST_SHOW_MAC_ITEMS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show various host related details by query',
+ 'doc' : 'host|show-host-items',
+ 'doc-example' : 'host|show-host-items-example',
+ 'no-supported' : False,
+ 'command-type' : 'display-table',
+ 'obj-type' : 'host',
+ 'args' : (
+ 'host',
+ {
+ 'choices' : (
+ {
+ 'field' : 'mac',
+ 'type' : 'host',
+ 'short-help' : 'Show the hosts with the given MAC or alias',
+ 'help-name' : 'host mac or alias',
+ 'completion' : 'complete-alias-choice',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'host|show-host-mac',
+ },
+ {
+ 'field' : 'ipv4',
+ 'tag' : 'ip-address',
+ 'short-help' : 'Show the hosts with the given IPv4 address',
+ 'type' : 'ip-address',
+ 'help-name' : 'ip address',
+ 'completion' : 'complete-object-field',
+ 'doc' : 'host|show-host-ipv4',
+ },
+ {
+ 'field' : 'dpid',
+ 'short-help' : 'Show the hosts attached to the given switch',
+ 'tag' : 'switch',
+ 'type' : 'dpid',
+ 'help-name' : 'switch dpid or alias',
+ 'completion' : 'complete-object-field',
+ #'completion' : 'complete-alias-choice',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'host|show-host-switch',
+ },
+ {
+ 'field' : 'host',
+ 'short-help': 'Show all hosts',
+ 'type' : 'enum',
+ 'values' : 'all',
+ 'doc' : 'host|show-host-all',
+ },
+ )
+ },
+ {
+ 'choices' : (
+ (
+ {
+ 'field' : 'attachment-point',
+ 'type' : 'enum',
+ 'values' : 'attachment-point',
+ 'obj-type' : 'host-attachment-point',
+ 'action' : 'display-table',
+ 'short-help' : 'Show host attachment points',
+ 'doc' : 'host|show-host-item-attachment-point',
+ },
+ {
+ 'optional' : True,
+ 'choices' : (
+ (
+ {
+ 'token' : 'by',
+ 'short-help' : 'Sort displayed hosts',
+ 'doc' : 'reserved|by',
+ },
+ {
+ 'choices' : (
+ {
+ 'token' : 'host-last-seen',
+ 'sort' : 'host,-last-seen',
+ 'obj-type' : 'host-attachment-point',
+ 'action' : 'display-table',
+ 'short-help' : 'Sort by the last seen time for the host',
+ 'doc' : 'host|show-host-by-host-last-seen',
+ },
+ {
+ 'token' : 'last-seen',
+ 'sort' : '-last-seen',
+ 'obj-type' : 'host-attachment-point',
+ 'action' : 'display-table',
+ 'short-help' : 'Sort by the last seen time for the attachment point',
+ 'doc' : 'host|show-host-by-last-seen',
+ },
+ ),
+ },
+ ),
+ ),
+ },
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details', 'brief'),
+ 'optional' : True,
+ 'short-help' : 'Display either detailed or brief information',
+ 'doc' : 'format|+',
+ }
+ ),
+ (
+ {
+ 'field' : 'network-address',
+ 'type' : 'enum',
+ 'values' : 'ip-address',
+ 'obj-type' : 'host-network-address',
+ 'action' : 'display-table',
+ 'doc' : 'host|show-host-item-network-address',
+ },
+ {
+ 'optional' : True,
+ 'choices' : (
+ (
+ {'token': 'by',
+ 'short-help': 'Sort displayed hosts'
+ },
+ {
+
+ 'choices' : (
+ {
+ 'token' : 'host-last-seen',
+ 'sort' : 'host,-last-seen',
+ 'short-help' : 'Sort by the last seen time for the host',
+ 'obj-type' : 'host-network-address',
+ 'action' : 'display-table',
+ 'doc' : 'host|show-host-by-host-last-seen',
+ },
+ {
+ 'token' : 'last-seen',
+ 'sort' : '-last-seen',
+ 'short-help' : 'Sort by the last seen time for the network address',
+ 'obj-type' : 'host-network-address',
+ 'action' : 'display-table',
+ 'doc' : 'host|show-host-by-last-seen',
+ }
+ )
+ },
+ ),
+ ),
+ },
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details', 'brief'),
+ 'optional' : True,
+ 'short-help' : 'Display either detailed or brief information',
+ 'doc' : 'format|+'
+ }
+ ),
+ {
+ 'field' : 'alias',
+ 'type' : 'enum',
+ 'values' : 'alias',
+ 'obj-type' : 'host-alias',
+ 'action' : 'display-table',
+ 'short-help' : 'Display host alias mappings',
+ 'doc' : 'host|show-host-item-alias',
+ },
+ ),
+ },
+ )
+}
+
+"""
+HOST_HOST_ALIAS_COMMAND_DESCRIPTION = {
+ 'name' : 'host-alias',
+ 'mode' : 'config-host',
+ 'short-help' : 'Attach alias to host',
+ 'doc' : 'host|host-alias',
+ 'doc-example' : 'host|host-alias-example',
+ 'command-type' : 'manage-alias',
+ 'obj-type' : 'host-alias',
+ 'scoped' : True,
+ 'reserved' : [ 'switch', 'ip-address' ],
+ 'args' : (
+ {
+ 'field' : 'id',
+ 'base-type' : 'identifier',
+ 'optional-for-no' : False,
+ 'completion' : 'complete-object-field',
+ }
+ )
+}
+
+
+HOST_SECURITY_POLICY_BIND_IP_ADDRESS_COMMAND_DESCRIPTION = {
+ 'name' : 'security',
+ 'mode' : 'config-host',
+ 'short-help' : 'Configure security policies for host',
+ 'doc' : 'host|security',
+ 'doc-example' : 'host|security-example',
+ 'command-type' : 'config-object',
+ 'parent-field' : 'host',
+ 'args' : (
+ {
+ 'token' : 'policy',
+ 'doc' : 'host|security-policy',
+ },
+ {
+ 'token' : 'bind',
+ 'doc' : 'host|security-bind',
+ },
+ {
+ 'choices' : (
+ {
+ 'field' : 'ip-address',
+ 'tag' : 'ip-address',
+ 'base-type' : 'ip-address',
+ 'optional-for-no' : False,
+ # could possibly complete all ip-addresses
+ 'completion' : 'complete-object-field',
+ 'obj-type' : 'host-security-ip-address',
+ 'action' : 'write-object',
+ 'no-action' : 'delete-objects',
+ 'short-help' : 'restrict host access to ip-address',
+ 'doc' : 'host|security-ip-address',
+ },
+ (
+ {
+ 'token' : 'attachment-point',
+ 'short-help' : 'restrict host access to attachment point',
+ 'doc' : 'host|security-attachment-point',
+ },
+ {
+ 'choices' : (
+ {
+ 'token' : 'all'
+ },
+ {
+ 'field' : 'dpid',
+ 'type' : 'dpid',
+ 'completion' : [
+ 'complete-object-field',
+ 'complete-alias-choice',
+ ],
+ 'obj-type' : 'switches',
+ 'other' : 'switches|dpid',
+ 'help-name' : 'switch dpid or alias',
+ 'data-handler' : 'alias-to-value',
+ 'optional-for-no' : False,
+ 'short-help' : 'identify switch for attachment point',
+ 'doc' : 'host|security-attachment-point-switch',
+ },
+ )
+ },
+ {
+ 'field' : 'if-name-regex',
+ 'optional-for-no' : False,
+ 'syntax-help' : 'Regular expression match for interfaces',
+ 'action' : 'write-object',
+ 'no-action' : 'delete-objects',
+ 'obj-type' : 'host-security-attachment-point',
+ 'completion' : [
+ 'complete-object-field',
+ 'complete-from-another',
+ ],
+ 'other' : 'interfaces|portName',
+ 'scoped' : 'switch',
+ 'short-help' : 'identify interface for attachment point',
+ 'doc' : 'host|security-attachment-point-interface',
+ },
+ ),
+ ),
+ },
+ ),
+}
+"""
+
+#
+# FORMATS
+#
+
+import fmtcnv
+
+
+HOST_FORMAT = {
+ 'host': {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'id',
+ 'ips', 'attachment-points' ],
+ 'details' : [ 'Idx', 'id',
+ 'vendor', 'ips', 'attachment-points'
+ ],
+ 'brief' : [ 'Idx', 'id', 'ips'],
+ },
+
+
+ 'fields': {
+ 'id' : {
+ 'verbose-name': 'MAC Address',
+ 'formatter' : fmtcnv.print_host_and_alias,
+ },
+ 'mac' : {
+ 'verbose-name': 'MAC Address',
+ 'formatter' : fmtcnv.print_host_and_alias,
+ },
+ 'address-space' : {
+ 'verbose-name' : 'Address Space',
+ },
+ 'vendor' : {
+ 'formatter' : fmtcnv.sanitize_unicode,
+ },
+ 'vlan' : {
+ 'verbose-name': 'VLAN',
+ 'formatter' : fmtcnv.convert_to_string,
+ },
+ 'ips' : {
+ 'verbose-name' : 'IP Address',
+ 'formatter' : fmtcnv.print_ip_addresses,
+ 'entry-formatter' : fmtcnv.print_all_ip_addresses,
+ },
+ 'attachment-points' : {
+ 'verbose-name' : 'Switch/OF Port (Physical Port)',
+ 'formatter' : fmtcnv.print_host_attachment_point,
+ 'entry-formatter' : fmtcnv.print_all_host_attachment_points,
+ },
+ 'tag' : {
+ 'formatter' : fmtcnv.print_host_tags,
+ 'entry-formatter' : fmtcnv.print_all_host_tags,
+ },
+ 'dhcp-client-name' : {
+ 'verbose-name' : 'DHCP Client Name',
+ },
+ 'last-seen' : {
+ 'verbose-name': 'Last Seen',
+ 'formatter' : fmtcnv.print_time_since_utc,
+ },
+ },
+ },
+}
+
+
+HOST_ATTACHMENT_POINT_FORMAT = {
+ 'host-attachment-point' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'mac', 'vlan', 'address-space', 'switch', 'ingress-port', 'status', ],
+ 'details' : [ 'Idx', 'mac', 'vlan', 'address-space', 'switch', 'ingress-port', 'status', 'last-seen'],
+ },
+
+ 'fields': {
+ 'mac' : {
+ 'verbose-name' : 'MAC Address',
+ 'formatter' : fmtcnv.print_host_and_alias,
+ },
+ 'vlan' : {
+ 'verbose-name': 'VLAN',
+ 'formatter' : fmtcnv.convert_to_string,
+ },
+
+ 'address-space' : {
+ 'verbose-name' : 'Address Space',
+ },
+ 'switch' : {
+ 'verbose-name' : 'Switch ID',
+ 'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'ingress-port' : {
+ 'verbose-name': 'Port',
+ 'formatter' : fmtcnv.decode_openflow_port,
+ },
+ 'status' : {
+ 'verbose-name': 'Error Status (if any)'
+ },
+ 'last-seen' : {
+ 'verbose-name': 'Last Seen',
+ 'formatter' : fmtcnv.timestamp_to_local_timestr,
+ },
+ },
+ },
+}
+
+
+HOST_NETWORK_ADDRESS_FORMAT = {
+ 'host-network-address': {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'mac', 'address-space', 'vlan', 'ip-address', ],
+ 'details' : [ 'Idx', 'mac', 'address-space', 'vlan', 'ip-address', 'last-seen' ],
+ },
+ 'fields': {
+ 'mac' : {
+ 'verbose-name': 'MAC Address',
+ },
+ 'vlan' : {
+ 'verbose-name': 'VLAN',
+ },
+ 'address-space' : {
+ 'verbose-name' : 'Address Space',
+ },
+ 'id' : {
+ },
+ 'ip-address': {
+ 'verbose-name': 'IP Address',
+ },
+ 'last-seen' : {
+ 'verbose-name': 'Last Seen',
+ 'formatter' : fmtcnv.timestamp_to_local_timestr,
+ },
+ },
+ },
+}
+
+
+HOST_ALIAS_FORMAT = {
+ 'host-alias' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'id', 'address-space', 'vlan', 'mac' ]
+ },
+ },
+}
+
+"""
+HOST_CONFIG_FORMAT = {
+ 'host-config' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'mac', 'vlan', 'vendor', 'ips',
+ 'attachment-points', 'tag', 'last-seen' ],
+ 'brief' : [ 'Idx', 'mac', 'vlan', 'ips', 'last-seen'],
+ },
+ 'fields' : {
+ 'mac' : {
+ 'verbose-name': 'MAC Address',
+ 'formatter' : fmtcnv.print_host_and_alias,
+ },
+ 'vendor' : {
+ 'formatter' : fmtcnv.sanitize_unicode,
+ },
+ 'vlan' : {
+ 'verbose-name': 'VLAN',
+ 'formatter' : fmtcnv.convert_to_string,
+ },
+ 'ips' : {
+ 'verbose-name' : 'IP Address',
+ 'formatter' : fmtcnv.print_ip_addresses,
+ 'entry-formatter' : fmtcnv.print_all_ip_addresses,
+ },
+ 'attachment-points' : {
+ 'verbose-name' : 'Switch/OF Port (Physical Port)',
+ 'formatter' : fmtcnv.print_host_attachment_point,
+ 'entry-formatter' : fmtcnv.print_all_host_attachment_points,
+ },
+ 'tag' : {
+ 'formatter' : fmtcnv.print_host_tags,
+ 'entry-formatter' : fmtcnv.print_all_host_tags,
+ },
+ 'host-alias' : {
+ },
+ 'last-seen' : {
+ 'verbose-name': 'Last Seen',
+ 'formatter' : fmtcnv.print_time_since_utc,
+ },
+ },
+ },
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/host_model.py b/cli/desc/version200/host_model.py
new file mode 100755
index 0000000..34f2014
--- /dev/null
+++ b/cli/desc/version200/host_model.py
@@ -0,0 +1,33 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_disable_submode('host-security-ip-address')
+command.model_obj_type_disable_submode('host-security-attachment-point')
+
+command.model_obj_type_disable_edit('host', 'last-seen')
+
+command.model_obj_type_set_case('host', 'mac', 'lower')
+command.model_obj_type_set_case('host-config', 'mac', 'lower')
+
+command.model_obj_type_enable_cascade_delete('host-config')
+command.model_obj_type_enable_cascade_delete('host-alias')
+command.model_obj_type_enable_cascade_delete('host-security-ip-address')
+command.model_obj_type_enable_cascade_delete('host-security-attachment-point')
+
+command.model_obj_type_disable_edit('host-config', 'vlan')
+command.model_obj_type_disable_edit('host-config', 'last-seen')
diff --git a/cli/desc/version200/internal.py b/cli/desc/version200/internal.py
new file mode 100755
index 0000000..5fe7ad2
--- /dev/null
+++ b/cli/desc/version200/internal.py
@@ -0,0 +1,669 @@
+#
+# Copyright (c) 2010,2011,2012,2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+"""
+import command
+
+INTERNAL_SUBMODE_COMMAND_DESCRIPTION = {
+ 'name' : 'internal',
+ 'mode' : 'config',
+ 'no-supported' : False,
+ 'help' : 'Enter Internal CLI debugging mode',
+ 'short-help' : 'Enter CLI internal debugging mode',
+ 'doc' : 'internal|internal',
+ 'doc-example' : 'internal|internal-example',
+ 'command-type' : 'config-submode',
+ 'obj-type' : None,
+ 'current-mode-obj-id' : None,
+ 'parent-field' : None,
+ 'submode-name' : 'config-internal',
+ 'args' : (),
+}
+
+INTERNAL_SHOW_INTERFACES_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'config-internal',
+ 'no-supported' : False,
+ 'short-help' : 'Show system interfaces',
+ 'doc' : 'internal|show-interfaces',
+ 'doc-example' : 'internal|show-interfaces-example',
+ 'args' : (
+ 'system',
+ {
+ 'token' : 'interfaces',
+ 'action' : 'display-rest' ,
+ 'url' : 'system/interfaces/',
+ 'format' : 'system-interfaces',
+ },
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details','brief'),
+ 'optional' : True,
+ 'doc' : 'format|+'
+ }
+ )
+}
+DEBUG_INTERNAL_TOPOLOGY_COMMAND_DESCRIPTION = {
+ 'name' : 'internal',
+ 'mode' : 'config-internal',
+ 'command-type' : 'display-rest',
+ 'url' : [
+ 'internal-debugs/topology-manager/%(dpid)s',
+ 'internal-debugs/topology-manager/',
+ ],
+ 'format' : 'switch',
+ 'short-help' : 'internal topology display',
+ 'doc' : 'internal|internal-topology',
+ 'args' : (
+ 'topology',
+ {
+ 'choices' : (
+ {
+ 'field' : 'dpid',
+ 'type' : 'dpid',
+ 'optional' : 'true',
+ },
+ )
+ }
+ )
+}
+
+DEBUG_INTERNAL_CLUSTER_COMMAND_DESCRIPTION = {
+ 'name' : 'internal',
+ 'mode' : 'config-internal',
+ 'command-type' : 'display-rest',
+ 'url' : 'realtimestatus/network/cluster',
+ 'format' : 'switch',
+ 'short-help' : 'internal switch cluster display',
+ 'args' : (
+ 'cluster',
+ )
+}
+
+
+SHOW_VNS_ACCESS_LIST_ENTRY_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'vns-access-list-entry',
+ 'short-help' : 'Show vns-access-list-entry db table',
+ 'doc' : 'internal|show-vns-access-list-entry',
+ 'mode' : 'config-internal',
+ 'command-type' : 'display-table',
+ 'args' : (
+ 'vns-access-list-entry',
+ {
+ 'optional' : True,
+ 'field' : 'vns',
+ 'type' : 'identifier',
+ 'completion' : 'complete-from-another',
+ 'other' : 'vns-definition',
+ 'help-name' : "<vns-id>",
+ 'detail' : 'default',
+ },
+ {
+ 'optional' : True,
+ 'field' : 'acl',
+ 'tag' : 'acl',
+ },
+ {
+ 'optional' : True,
+ 'field' : 'rule',
+ 'tag' : 'rule',
+ },
+ )
+}
+
+
+SHOW_PORT_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'port',
+ 'short-help' : 'Show port db table',
+ 'doc' : 'internal|show-port',
+ 'mode' : 'config-internal',
+ 'command-type' : 'display-table',
+ 'args' : (
+ 'port',
+ {
+ 'field' : 'id',
+ 'optional' : True,
+ 'type' : 'obj-type',
+ 'completion' : 'complete-object-field',
+ 'parent-id' : None,
+ },
+ {
+ 'field' : 'dpid',
+ 'optional' : True,
+ 'tag' : 'switch',
+ 'completion' : 'complete-from-another',
+ 'other' : 'switches',
+ 'data-handler' : 'alias-to-value',
+ },
+ {
+ 'field' : 'number',
+ 'tag' : 'port',
+ 'optional' : True,
+ 'completion' : 'complete-object-field',
+ },
+ {
+ 'field' : 'detail',
+ 'optional' : True,
+ 'type' : 'enum',
+ 'values' : ('details', 'brief'),
+ }
+ )
+}
+
+
+SHOW_VNS_INTERFACE_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'vns-interface',
+ 'short-help' : 'Show vns-interface db table',
+ 'doc' : 'internal|show-vns-interface',
+ 'mode' : 'config-internal',
+ 'command-type' : 'display-table',
+ 'args' : (
+ 'vns-interface',
+ {
+ 'field' : 'id',
+ 'tag' : 'vns',
+ 'type' : 'string',
+ 'optional' : True,
+ 'parent-id' : 'vns',
+ 'completion' : 'complete-object-field',
+ },
+ {
+ 'field' : 'switch',
+ 'tag' : 'switch',
+ 'type' : 'dpid',
+ 'optional' : True,
+ },
+ {
+ 'field' : 'number',
+ 'tag' : 'number',
+ 'type' : 'integer',
+ 'help-name' : 'OF Port Number',
+ 'optional' : True,
+ },
+ )
+}
+
+
+SHOW_VNS_INTERFACE_RULE_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'vns-interface-rule',
+ 'short-help' : 'Show vns-interface-rule db table',
+ 'doc' : 'internal|show-vns-interface-rule',
+ 'mode' : 'config-internal',
+ 'command-type' : 'display-table',
+ 'args' : (
+ 'vns-interface-rule',
+ {
+ 'field' : 'vns',
+ 'tag' : 'vns',
+ 'optional' : True,
+ 'type' : 'string',
+ 'parent-id' : 'vns',
+ 'completion' : 'complete-object-field',
+ },
+ {
+ 'field' : 'rule',
+ 'tag' : 'rule',
+ 'type' : 'string',
+ 'optional' : True,
+ 'completion' : 'complete-object-field',
+ },
+ )
+}
+
+
+INTERNAL_SHOW_DEVICE_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'config-internal',
+ 'no-supported' : False,
+ 'short-help' : 'Show controller devices',
+ 'doc' : 'internal|show-controller-devices',
+ 'args' : (
+ 'controller',
+ {
+ 'choices' : (
+ {
+ 'token' : 'devices',
+ 'action' : 'display-rest' ,
+ 'url' : 'device',
+ 'format' : 'controller-devices',
+ },
+ (
+ {
+ 'token' : 'vns',
+ 'action' : 'display-rest' ,
+ 'url' : 'vns',
+ 'format' : 'controller-vns',
+ },
+ {
+ 'optional' : True,
+ 'choices' : (
+ {
+ 'token' : 'interfaces',
+ 'optional' : True,
+ 'action' : 'display-rest' ,
+ 'url' : 'vns/interface',
+ 'format' : 'controller-vns-interfaces',
+ },
+ {
+ 'token' : 'device-interfaces',
+ 'optional' : True,
+ 'action' : 'display-rest' ,
+ 'url' : 'vns/device-interface',
+ 'format' : 'controller-vns-device-interface',
+ },
+ )
+ },
+ ),
+ )
+ },
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details','brief'),
+ 'optional' : True,
+ }
+ )
+}
+
+
+def display_schema(data):
+ return command.sdnsh.sdndb.schema_detail(data['path'])
+
+command.add_action('display-schema', display_schema,
+ {'kwargs' : { 'data' : '$data' } } )
+
+INTERNAL_SHOW_SCHEMA_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'config-internal',
+ 'feature' : 'experimental',
+ 'no-supported' : False,
+ 'short-help' : 'Show controller devices',
+ 'action' : 'display-schema',
+ 'args' : (
+ 'schema',
+ {
+ 'field' : 'path',
+ 'type' : 'string',
+ },
+ ),
+}
+
+
+def lint_action(data):
+ words = []
+ if 'command' in data:
+ words.append(data['command'])
+ command.lint_command(words)
+
+command.add_action('lint-action', lint_action,
+ {'kwargs' : { 'data' : '$data' } } )
+
+INTERNAL_LINT_COMMAND_DESCRIPTION = {
+ 'name' : 'lint',
+ 'mode' : 'config-internal',
+ 'no-supported' : False,
+ 'action' : 'lint-action',
+ 'args' : {
+ 'optional' : True,
+ 'field' : 'command',
+ 'type' : 'string',
+ }
+}
+
+
+def permute_action(data):
+ words = []
+ if 'command' in data:
+ words.append(data['command'])
+ return command.permute_command(words, data.get('qualify'))
+
+command.add_action('permute-action', permute_action,
+ {'kwargs' : { 'data' : '$data' } } )
+
+
+INTERNAL_PERMUTE_COMMAND_DESCRIPTION = {
+ 'name' : 'permute',
+ 'mode' : 'config-internal',
+ 'no-supported' : False,
+ 'action' : 'permute-action',
+ 'data' : { 'qualify' : False },
+ 'args' : (
+ {
+ 'optional' : True,
+ 'field' : 'command',
+ 'type' : 'string',
+ },
+ )
+}
+
+
+INTERNAL_QUALIFY_COMMAND_DESCRIPTION = {
+ 'name' : 'qualify', # berate
+ 'mode' : 'config-internal',
+ 'no-supported' : False,
+ 'action' : 'permute-action',
+ 'data' : { 'qualify' : True },
+ 'args' : (
+ {
+ 'optional' : True,
+ 'field' : 'command',
+ 'type' : 'string',
+ },
+ )
+}
+
+
+def clidoc_action(data):
+ words = []
+ if 'command' in data:
+ words.append(data['command'])
+ return command.get_clidoc(words)
+
+command.add_action('clidoc-action', clidoc_action,
+ {'kwargs' : { 'data' : '$data' }, } )
+
+
+INTERNAL_CLIDOC_COMMAND_DESCRIPTION = {
+ 'name' : 'clidoc',
+ 'mode' : 'config-internal',
+ 'no-supported' : False,
+ 'action' : 'clidoc-action',
+ 'args' : {
+ 'optional' : True,
+ 'field' : 'command',
+ 'type' : 'string',
+ }
+}
+
+def cliwiki_action(data):
+ words = []
+ if 'command' in data:
+ words.append(data['command'])
+ return command.get_cliwiki(words)
+
+command.add_action('cliwiki-action', cliwiki_action,
+ {'kwargs' : { 'data' : '$data' }, } )
+INTERNAL_CLIWIKI_COMMAND_DESCRIPTION = {
+ 'name' : 'cliwiki',
+ 'mode' : 'config-internal',
+ 'no-supported' : False,
+ 'action' : 'cliwiki-action',
+ 'args' : {
+ 'optional' : True,
+ 'field' : 'command',
+ 'type' : 'string',
+ }
+}
+
+SHOW_CLI_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'config-internal',
+ 'short-help' : 'Show CLI details',
+ 'doc' : 'internal|show-cli',
+ 'action' : 'display-cli',
+ 'no-supported' : False,
+ 'args' : (
+ 'cli',
+ {
+ 'optional' : True,
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details'),
+ },
+ )
+}
+
+
+#
+# FORMATS
+#
+
+import fmtcnv
+
+
+SYSTEM_INTERFACES_FORMAT = {
+ 'system-interfaces' : {
+ 'field-orderings': {
+ 'default' : [
+ 'Idx',
+ # 'name',
+ 'addr',
+ 'netmask',
+ 'broadcast',
+ # 'peer',
+ ],
+ 'details' : [
+ 'Idx',
+ 'name',
+ 'addr',
+ 'netmask',
+ 'broadcast',
+ 'peer',
+ ],
+ 'brief' : [
+ 'Idx',
+ 'addr',
+ ]
+ },
+ 'fields' : {
+ 'name' : {
+ 'verbose-name' : 'IF Name',
+ },
+ 'addr' : {
+ 'verbose-name' : 'IP Address',
+ },
+ 'peer' : {
+ },
+ 'netmask' : {
+ },
+ 'broadcast' : {
+ },
+ }
+ },
+}
+
+
+PORT_FORMAT = {
+ 'port' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'switch', 'number', 'name', 'hardware-address',
+ 'config', 'state', 'current-features',
+ 'advertised-features', 'supported-features', 'peer-features' ],
+ },
+ 'fields' : {
+ 'switch' : { 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'number' : { 'formatter' : fmtcnv.decode_openflow_port
+ },
+ 'config' : { 'formatter' : fmtcnv.decode_port_config
+ },
+ 'state' : { 'formatter' : fmtcnv.decode_port_state
+ },
+ 'current-features' : { 'formatter' : fmtcnv.decode_port_features
+ },
+ 'advertised-features' : { 'formatter' : fmtcnv.decode_port_features
+ },
+ 'supported-features' : { 'formatter' : fmtcnv.decode_port_features
+ },
+ 'peer-features' : { 'formatter' : fmtcnv.decode_port_features
+ },
+ }
+ },
+}
+
+
+CONTROLLER_VNS_FORMAT = {
+ 'controller-vns' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx',
+ 'name',
+ 'active',
+ 'priority',
+ 'arpManagerMode',
+ 'broadcastMode',
+ 'dhcpManagerMode',
+ 'dhcpIp',
+ ],
+ },
+ 'fields' : {
+ 'name' : {
+ 'verbose-name' : 'Name',
+ },
+ 'active' : {
+ 'verbose-name' : 'Active',
+ },
+ 'priority' : {
+ 'verbose-name' : 'Priority',
+ },
+ 'arpManagerMode' : {
+ 'verbose-name' : 'Arp Mode',
+ },
+ 'broadcastMode' : {
+ 'verbose-name' : 'Broadcast Mode',
+ },
+ 'dhcpManagerMode' : {
+ 'verbose-name' : 'Dhcp Modd',
+ },
+ 'dhcpIp' : {
+ 'verbose-name' : 'dhcpIp',
+ },
+ },
+ },
+}
+
+
+CONTROLLER_VNS_INTERFACES = {
+ 'controller-vns-interfaces' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx',
+ ],
+ },
+ },
+}
+
+
+CONTROLLER_VNS_DEFICE_INTERFACES = {
+ 'controller-vns-device-interfaces' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx',
+ 'device',
+ 'iface',
+ ],
+ },
+ },
+}
+
+
+CONTROLLER_DEVICES_FORMAT = {
+ 'controller-devices' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx',
+ 'mac',
+ 'attachment-point',
+ 'ipv4',
+ 'vlan',
+ ]
+ },
+
+ 'fields' : {
+ 'mac' : {
+ 'verbose-name' : 'MAC Address',
+ 'formatter' : fmtcnv.convert_to_string,
+ },
+ 'ipv4' : {
+ 'verbose-name' : 'IP Address',
+ 'formatter' : fmtcnv.convert_to_string,
+ },
+ 'attachment-point' : {
+ 'verbose-name' : 'Attachment Point',
+ 'formatter' : fmtcnv.convert_to_string,
+ },
+ 'vlan' : {
+ 'verbose-name' : 'Vlans',
+ 'formatter' : fmtcnv.convert_to_string,
+ },
+ },
+ },
+}
+
+DEVICEMANAGER_DEVICE_FORMAT = {
+ 'devicemanager-device' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'Idx',
+ 'host',
+ 'attachment-points',
+ 'network-addresses'
+ ]
+ },
+
+ 'fields' : {
+ 'host' : { 'formatter' : fmtcnv.print_host_and_alias,
+ },
+ 'attachment-points' : {
+ 'verbose-name' : 'Attachment Point',
+ 'formatter' : fmtcnv.print_devicemanager_attachment_points,
+ },
+ 'network-addresses' : {
+ 'verbose-name' : 'IP Address',
+ 'formatter' : fmtcnv.print_devicemanager_ip_addresses,
+ },
+
+ },
+ },
+}
+
+
+CLI_FORMAT = {
+ 'cli' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'version',
+ 'debug',
+ 'desc'
+ 'format',
+ 'modes',
+ ]
+ },
+
+ 'fields' : {
+ 'version' : { 'verbose-name' : 'Syntax Version',
+ },
+ 'debug' : { 'verbose-name' : 'Debug Level',
+ },
+ 'desc' : { 'verbose-name' : 'Desc Modules',
+ },
+ 'format' : { 'verbose-name' : 'Format Modules',
+ },
+ 'modes' : { 'verbose-name' : 'Submodes',
+ },
+ },
+ },
+}
+
+CLI_MODES_FORMAT = {
+ 'cli-modes' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'mode', 'command', 'submode',
+ ]
+ }
+ },
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/link.py b/cli/desc/version200/link.py
new file mode 100755
index 0000000..bddb090
--- /dev/null
+++ b/cli/desc/version200/link.py
@@ -0,0 +1,105 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+LINK_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'link',
+ 'short-help' : 'Show links, controller managed switch to switch interfaces',
+ 'doc' : 'show-link',
+ 'doc-example' : 'show-link-example',
+ 'mode' : 'login',
+ 'command-type' : 'display-rest',
+ 'url' : 'links',
+ 'action' : (
+ {
+ 'proc' : 'query-rest',
+ },
+ {
+ 'proc' : 'display',
+ 'sort' : [ 'src-switch', 'src-port' ],
+ 'format' : 'links',
+ },
+ ),
+ 'args' : (
+ 'link',
+ #{
+ #'field' : 'id',
+ #'optional' : True,
+ #'type' : 'obj-type',
+ #'completion' : 'complete-object-field',
+ #},
+ # These parameters may be re-introduced if the
+ # underlying rest api provides some search parameters
+ #{
+ #'field' : 'src-switch',
+ #'tag' : 'src-switch',
+ #'optional' : True,
+ #'type' : 'string',
+ #'completion' : 'complete-object-field',
+ #},
+ #{
+ #'field' : 'dst-switch',
+ #'tag' : 'dst-switch',
+ #'optional' : True,
+ #'type' : 'string',
+ #'completion' : 'complete-object-field',
+ #}
+ )
+}
+
+import fmtcnv
+
+
+LINKS_FORMAT = {
+ 'links' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx',
+ 'src-switch', 'src-port',
+ 'dst-switch', 'dst-port', 'type' ]
+ },
+ 'fields' : {
+ 'src-switch' : {
+ 'verbose-name' : 'Src Switch DPID',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ # 'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'src-port' : {
+ 'verbose-name' : 'Src Port',
+ 'formatter' : fmtcnv.decode_openflow_port_src_switch
+ },
+ 'src-port-state' : {
+ 'verbose-name' : 'Src Port State',
+ 'formatter' : fmtcnv.decode_port_state
+ },
+ 'dst-switch' : {
+ 'verbose-name' : 'Dst Switch DPID',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ # 'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'dst-port' : {
+ 'verbose-name' : 'Dst Port',
+ 'formatter' : fmtcnv.decode_openflow_port_dst_switch
+ },
+ 'dst-port-state' : {
+ 'verbose-name' : 'Dst Port State',
+ 'formatter' : fmtcnv.decode_port_state
+ },
+ 'link-type' : {
+ 'verbose-name' : 'Link Type',
+ },
+ }
+ },
+}
diff --git a/cli/desc/version200/policy.py b/cli/desc/version200/policy.py
new file mode 100644
index 0000000..eac0209
--- /dev/null
+++ b/cli/desc/version200/policy.py
@@ -0,0 +1,338 @@
+import command
+import json
+import fmtcnv
+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',
+ #'completion' : 'policy-id-completion',
+ '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',
+ },
+ {
+ 'token' : 'policy-type',
+ 'optional-for-no' : True,
+ 'short-help' : 'Set type of policy',
+ 'doc' : 'policy|policy',
+ 'completion' : 'complete-object-field',
+ },
+ {
+ 'field' : 'policy-type',
+ 'optional-for-no' : True,
+ 'type' : 'enum',
+ 'values' : ('tunnel-flow','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/0',
+ },
+ 'doc' : 'vns|vns-access-list-cidr-range',
+ }
+ ),
+ (
+ {
+ 'token' : 'any',
+ 'data' : {
+ 'src_ip' : '0.0.0.0/0',
+ 'dst_ip' : '0.0.0.0/0',
+ },
+ '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/0',
+ },
+ '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',
+ },
+ ),
+ 'completion' : 'tunnelid-completion',
+ '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),
+ }
+}
+
+SHOW_POLICY_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'all-help' : 'Show switch information',
+ 'short-help' : 'Show switch summary',
+ #'obj-type' : 'switches',
+ 'doc' : 'switch|show',
+ 'doc-example' : 'switch|show-example',
+ 'args' : (
+ {
+ 'token' : 'policy',
+ 'field' : 'showpolicy',
+ 'action' : 'display-rest',
+ 'sort' : ['policyId',],
+ 'doc' : 'switch|show',
+ 'url' : [
+ 'showpolicy',
+ ],
+ 'format' : 'show_policy',
+ },
+ )
+}
+
+
+def tunnel_id_completion(prefix, completions):
+ query_url = "http://127.0.0.1:8000/rest/v1/showtunnel"
+ result = command.sdnsh.store.rest_simple_request(query_url)
+ entries = json.loads(result)
+ for entry in entries:
+ if entry['tunnelId'].startswith(prefix):
+ completions[entry['tunnelId']+' '] = entry['tunnelId']
+ return
+
+command.add_completion('tunnel-id-completion', tunnel_id_completion,
+ {'kwargs': { 'prefix' : '$text',
+ 'completions' : '$completions',
+ }})
+
+
+def policy_id_completion(prefix, completions):
+ query_url = "http://127.0.0.1:8000/rest/v1/showpolicy"
+ result = command.sdnsh.store.rest_simple_request(query_url)
+ entries = json.loads(result)
+ for entry in entries:
+ if entry['policyId'].startswith(prefix):
+ completions[entry['policyId']+' '] = entry['policyId']
+ return
+
+command.add_completion('policy-id-completion', policy_id_completion,
+ {'kwargs': { 'prefix' : '$text',
+ 'completions' : '$completions',
+ }})
\ No newline at end of file
diff --git a/cli/desc/version200/router.py b/cli/desc/version200/router.py
new file mode 100644
index 0000000..d0383ca
--- /dev/null
+++ b/cli/desc/version200/router.py
@@ -0,0 +1,103 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+import fmtcnv
+SWITCH_ROUTER_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'all-help' : 'Show switch information',
+ 'short-help' : 'Show switch summary',
+ #'obj-type' : 'switches',
+ 'doc' : 'switch|show',
+ 'doc-example' : 'switch|show-example',
+ 'args' : (
+ {
+ 'token' : 'router',
+ 'field' : 'router',
+ 'action' : 'display-rest',
+ 'sort' : ['dpid',],
+ 'doc' : 'switch|show',
+ 'url' : [
+ 'routers',
+ ],
+ 'format' : 'router',
+ },
+ )
+}
+
+
+
+ROUTER_SHOW_REALTIME_STATS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show router stats via direct query to switch',
+ 'no-supported' : False,
+ 'short-help' : 'Show realtime stats for router',
+ 'parent-field' : None,
+ 'obj-type' : 'switches',
+ 'args' : (
+ {
+ 'token' : 'router',
+ 'obj-type' : 'switches',
+ 'command-type' : 'display-table',
+ # 'command-type' : 'display-rest',
+ },
+ {
+ 'choices' : (
+ {
+ 'field' : 'dpid',
+ 'completion' : 'complete-alias-choice',
+ 'type' : 'dpid',
+ 'help-name' : 'switch dpid or alias',
+ 'data-handler' : 'alias-to-value',
+ 'data' : { 'detail' : 'scoped' },
+ },
+ {
+ 'token' : 'all',
+ 'doc' : 'reserved|all',
+ },
+ ),
+ },
+ {
+ 'choices' : (
+ (
+ {
+ 'field' : 'routerrealtimestats',
+ 'type' : 'enum',
+ 'values' : (
+ 'port', 'adjacency'
+ ),
+ 'action' : 'display-rest',
+ 'sort' : ['portNo'],
+ 'url' : 'router/%(dpid)s/%(routerrealtimestats)s',
+ 'rest-type' : 'dict-of-list-of-switch',
+ 'format' : 'router_%(routerrealtimestats)s',
+ 'short-help' : 'Show requested item by querying router/switch',
+ 'doc' : 'switch|realtime-+',
+ },
+ {
+ 'field' : 'detail',
+ 'optional' : True,
+ 'type' : 'enum',
+ 'values' : ('details','brief'),
+ 'doc' : 'format|+',
+ },
+ ),
+
+ )
+ }
+ )
+}
diff --git a/cli/desc/version200/snmp.py b/cli/desc/version200/snmp.py
new file mode 100755
index 0000000..ad9b31e
--- /dev/null
+++ b/cli/desc/version200/snmp.py
@@ -0,0 +1,214 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# (c) in 2012 by Big Switch Networks - All rights reserved
+#
+# snmp-server commands
+#
+
+import command
+from midw import local_interfaces_firewall_open
+
+def snmp_validate_firewall(data):
+ intfs = local_interfaces_firewall_open( [ 'udp', 'tcp' ], 161)
+ if len(intfs) == 0:
+ # by issueing a warning, running-config doesn't display the
+ # error during replay.
+ command.sdnsh.warning('SNMP server port not open on any controller-node '
+ 'interface. Use firewall rule configuration to open '
+ 'SNMP UDP port 161')
+
+
+
+command.add_action('snmp-validate-firewall', snmp_validate_firewall,
+ {'kwargs': { 'data' : '$data',
+ }})
+
+"""
+#
+# --------------------------------------------------------------------------------
+# SNMP command descriptions
+#
+# [no] snmp-server enable
+# [no] snmp-server community <string>
+# [no] snmp-server location <string>
+# [no] snmp-server contact <string>
+#
+SNMP_SERVER_COMMAND_DESCRIPTION = {
+ 'name' : 'snmp-server',
+ 'mode' : 'config*',
+ 'short-help' : 'SMNP configuration, enable server, configure parameters',
+ 'doc' : 'snmp|snmp-server',
+ 'doc-example' : 'snmp|snmp-server-example',
+ 'command-type' : 'update-config',
+ 'obj-type' : 'snmp-server-config',
+ 'data' : { 'id' : 'snmp' },
+ 'args' : (
+ {
+ 'choices' : (
+ {
+ 'token' : 'enable',
+ 'short-help' : 'Enable SNMP',
+ 'doc' : 'snmp|snmp-server-enable',
+ 'action' : (
+ {
+ 'proc' : 'update-config',
+ 'data' : {
+ 'id' : 'snmp',
+ 'server-enable' : True,
+ },
+ },
+ {
+ 'proc' : 'snmp-validate-firewall'
+ },
+ ),
+ 'no-action' : {
+ 'proc' : 'update-config',
+ 'data' : {
+ 'id' : 'snmp',
+ 'server-enable' : False,
+ },
+ },
+ },
+ (
+ {
+ 'token' : 'community',
+ 'short-help' : 'Set community string and access privs',
+ 'data' : { 'community' : None },
+ 'doc' : 'snmp|snmp-server-community',
+ },
+ {
+ 'token' : 'ro',
+ 'short-help' : 'Read-only access with this community string',
+ 'optional-for-no' : True,
+ },
+ {
+ 'field' : 'community',
+ 'type' : 'string',
+ 'optional-for-no' : True,
+ 'syntax-help' : 'Value for the SNMP commuity string',
+ },
+ ),
+ (
+ {
+ 'token' : 'location',
+ 'short-help' : 'Text for mib object sysLocation',
+ 'data' : { 'location' : None },
+ 'doc' : 'snmp|snmp-server-location',
+ },
+ {
+ 'field' : 'location',
+ 'type' : 'string',
+ 'optional-for-no' : True,
+ 'syntax-help' : 'Value for the SNMP location string',
+ },
+ ),
+ (
+ {
+ 'token' : 'contact',
+ 'short-help' : 'Text for mib object sysContact',
+ 'data' : { 'contact' : None },
+ 'doc' : 'snmp|snmp-server-contact',
+ },
+ {
+ 'field' : 'contact',
+ 'type' : 'string',
+ 'optional-for-no' : True,
+ 'syntax-help' : 'Value for the SNMP contact string',
+ },
+ ),
+ ),
+ },
+ )
+}
+"""
+
+def snmp_firewall_interfaces(data):
+ """
+ There is currently only one row of data in the query,
+ add to that a 'interfaces' entity, which lists the interfaces
+ which have the snmp port open
+ """
+ if not hasattr(command, 'query_result'):
+ return
+ if command.query_result == None:
+ return
+
+ intfs = local_interfaces_firewall_open( [ 'udp', 'tcp' ], 161)
+
+ intfs_text = ', '.join([x['discovered-ip'] if x['discovered-ip'] != ''
+ else x['ip'] for x in intfs])
+
+ for q in command.query_result:
+ q['interfaces'] = intfs_text
+
+
+command.add_action('snmp-firewall-interfaces', snmp_firewall_interfaces,
+ {'kwargs': { 'data' : '$data',
+ }})
+
+"""
+SNMP_SERVER_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show configured snmp details',
+ 'doc' : 'snmp|show',
+ 'doc-example' : 'snmp|show-example',
+ 'command-type' : 'display-table',
+ 'obj-type' : 'snmp-server-config',
+ 'short-help' : 'Show SNMP configuration',
+ 'format' : 'snmp-config-summary',
+ 'args' : (
+ 'snmp',
+ ),
+ 'action' : (
+ {
+ 'proc' : 'query-table',
+ },
+ {
+ 'proc' : 'snmp-firewall-interfaces'
+ },
+ {
+ 'proc' : 'display-table',
+ },
+ ),
+}
+
+import fmtcnv
+
+SNMP_CONFIG_SUMMARY_FORMAT = {
+ 'snmp-config-summary' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'server-enable',
+ 'community',
+ 'location',
+ 'contact',
+ 'interfaces',
+ ],
+ },
+ 'fields' : {
+ 'server-enable' : {
+ 'verbose-name' : 'SNMP server status',
+ 'formatter' : fmtcnv.replace_boolean_with_enable_disable,
+ },
+ 'community' : { 'verbose-name' : 'Community string' },
+ 'location' : { 'verbose-name' : 'System location' },
+ 'contact' : { 'verbose-name' : 'System contact' },
+ },
+ }
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/snmp_model.py b/cli/desc/version200/snmp_model.py
new file mode 100755
index 0000000..60a5aa8
--- /dev/null
+++ b/cli/desc/version200/snmp_model.py
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_disable_submode('snmp-server-config')
diff --git a/cli/desc/version200/snmp_run_config.py b/cli/desc/version200/snmp_run_config.py
new file mode 100755
index 0000000..b36f244
--- /dev/null
+++ b/cli/desc/version200/snmp_run_config.py
@@ -0,0 +1,94 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# snmp.
+#
+
+import run_config
+import utif
+
+
+#
+# --------------------------------------------------------------------------------
+
+def create_obj_type_dict(context, obj_type, field):
+ """
+ Should there be some collections of middeleware functions for use by packages?
+ """
+ entries = context.get_table_from_store(obj_type)
+ result_dict = {}
+ for entry in entries:
+ if entry[field] in result_dict:
+ result_dict[entry[field]].append(entry)
+ else:
+ result_dict[entry[field]] = [entry]
+
+ return result_dict
+
+#
+# --------------------------------------------------------------------------------
+
+def running_config_snmp(context, config, words):
+ s_obj_type = 'snmp-server-config'
+
+ snmp_config = context.get_table_from_store(s_obj_type)
+ if len(snmp_config) > 1:
+ print 'running_config_snmp: more than one snmp record'
+ if len(snmp_config) == 0:
+ return
+
+ snmp_config = snmp_config[0]
+
+
+ s_config = []
+ if run_config.not_default_value(s_obj_type, 'community', snmp_config.get('community')):
+ s_config.append('snmp-server community ro %s\n' %
+ utif.quote_string(snmp_config['community']))
+
+ if run_config.not_default_value(s_obj_type, 'location', snmp_config.get('location')):
+ s_config.append('snmp-server location %s\n' %
+ utif.quote_string(snmp_config['location']))
+
+ if run_config.not_default_value(s_obj_type, 'contact', snmp_config.get('contact')):
+ s_config.append('snmp-server contact %s\n' %
+ utif.quote_string(snmp_config['contact']))
+ if run_config.not_default_value(s_obj_type, 'server-enable', snmp_config['server-enable']):
+ s_config.append('snmp-server enable\n')
+
+ if len(s_config):
+ config.append('!\n')
+ config += s_config
+
+
+#
+# --------------------------------------------------------------------------------
+
+snmp_running_config_tuple = (
+ (
+ {
+ 'optional' : False,
+ 'field' : 'running-config',
+ 'type' : 'enum',
+ 'values' : 'snmp',
+ 'short-help' : 'Configuration for SNMP',
+ 'doc' : 'running-config|show-snmp',
+ },
+ ),
+)
+
+run_config.register_running_config('snmp', 2300, None,
+ running_config_snmp,
+ snmp_running_config_tuple)
diff --git a/cli/desc/version200/snmp_techsupport.py b/cli/desc/version200/snmp_techsupport.py
new file mode 100755
index 0000000..3bec818
--- /dev/null
+++ b/cli/desc/version200/snmp_techsupport.py
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2012,2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+from tech_support import add_to_show_tech_support
+
+# SNMP commands to be included in 'show tech-support' output
+snmp_show_tech_support_commands = [
+ ['cli', 'show snmp'],
+ ['shell', 'pgrep snmpd'],
+ ['shell', 'cat /etc/snmp/snmpd.conf'],
+ ['shell', 'cat /etc/default/snmpd'],
+]
+
+# add commands to central command table used for 'show tech-support'
+for entry in snmp_show_tech_support_commands:
+ add_to_show_tech_support(str(entry[0]), str(entry[1]))
diff --git a/cli/desc/version200/switch.py b/cli/desc/version200/switch.py
new file mode 100755
index 0000000..a78b184
--- /dev/null
+++ b/cli/desc/version200/switch.py
@@ -0,0 +1,1213 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+import command
+import json
+import fmtcnv
+
+"""
+SWITCH_SUBMODE_COMMAND_DESCRIPTION = {
+ 'name' : 'switch',
+ 'short-help' : 'Enter switch submode, configure switch details',
+ 'mode' : 'config*',
+ 'obj-type' : 'switch-config',
+ 'command-type' : 'config-submode',
+ 'parent-field' : None,
+ 'submode-name' : 'config-switch',
+ 'doc' : 'switch|switch',
+ 'doc-example' : 'switch|switch-example',
+ 'args' : (
+ {
+ 'field' : 'dpid',
+ 'type' : 'dpid',
+ 'other' : 'switches|dpid',
+ 'completion' : [
+ 'complete-alias-choice',
+ 'complete-from-another',
+ ],
+ 'data-handler' : 'alias-to-value',
+ 'syntax-help' : 'Configure a new switch with dpid',
+ }
+ )
+}
+"""
+#
+# ------------------------------------------------------------------------------
+# show switch
+#
+
+show_switch_pipeline = (
+ {
+ 'proc' : 'query-table',
+ 'obj-type' : 'switches', # synthetic, supported by rest_to_model
+ 'key' : 'dpid',
+ },
+ {
+ 'proc' : 'join-table',
+ 'obj-type' : 'switch-alias',
+ 'key' : 'switch',
+ 'join-field' : '@',
+ 'add-field' : 'switch-alias|id',
+ },
+ {
+ 'proc' : 'join-rest',
+ 'url' : 'tunnel-manager/all',
+ 'rest-type' : 'dict-of-dict-of-switch',
+ 'key' : 'switch',
+ 'join-field' : '@',
+ },
+ {
+ 'proc' : 'display',
+ 'format' : 'switch',
+ },
+)
+
+SWITCH_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'all-help' : 'Show switch information',
+ 'short-help' : 'Show switch summary',
+ 'obj-type' : 'switches',
+ 'doc' : 'switch|show',
+ 'doc-example' : 'switch|show-example',
+ 'args' : (
+ {
+ 'token' : 'switch',
+ 'action' : show_switch_pipeline,
+ 'doc' : 'switch|show',
+ },
+ )
+}
+
+SWITCH_SHOW_WITH_DPID_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show switch details via query',
+ 'no-supported' : False,
+ 'parent-field' : None,
+ 'obj-type' : 'switches',
+ 'args' : (
+ {
+ 'token' : 'switch',
+ 'obj-type' : 'switches',
+ 'command-type' : 'display-table',
+ # 'command-type' : 'display-rest',
+ 'action' : show_switch_pipeline,
+ },
+ {
+ 'choices' : (
+ {
+ 'field' : 'dpid',
+ 'completion' : 'complete-alias-choice',
+ 'type' : 'dpid',
+ 'help-name' : 'switch dpid or alias',
+ 'data-handler' : 'alias-to-value',
+ },
+ {
+ 'token' : 'all',
+ },
+ ),
+ },
+ {
+ 'optional' : True,
+ 'choices' : (
+ (
+ {
+ 'token' : 'by',
+ 'doc' : 'switch|show-switch-order',
+ },
+ {
+ 'choices' : (
+ {
+ 'token' : 'ip-address',
+ 'sort' : 'ip-address',
+ 'action' : 'display-table',
+ 'short-help' : 'Sort by ip-address',
+ },
+ {
+ 'token' : 'connect-time',
+ 'sort' : '-connected-since',
+ 'action' : 'display-table',
+ 'short-help' : 'Sort by connect time',
+ },
+ )
+ }
+ ),
+ )
+ },
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details','brief'),
+ 'optional' : True,
+ 'doc' : 'switch|show-switch-format-+',
+ },
+ )
+}
+SWITCH_SHOW_REALTIME_STATS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show switch stats via direct query to switch',
+ 'no-supported' : False,
+ 'short-help' : 'Show realtime stats for switch',
+ 'parent-field' : None,
+ 'obj-type' : 'switches',
+ 'args' : (
+ {
+ 'token' : 'switch',
+ 'obj-type' : 'switches',
+ 'command-type' : 'display-table',
+ # 'command-type' : 'display-rest',
+ },
+ {
+ 'choices' : (
+ {
+ 'field' : 'dpid',
+ 'completion' : 'complete-alias-choice',
+ 'type' : 'dpid',
+ 'help-name' : 'switch dpid or alias',
+ 'data-handler' : 'alias-to-value',
+ 'data' : { 'detail' : 'scoped' },
+ },
+ {
+ 'token' : 'all',
+ 'doc' : 'reserved|all',
+ },
+ ),
+ },
+ {
+ 'choices' : (
+ (
+ {
+ 'field' : 'realtimestats',
+ 'type' : 'enum',
+ 'values' : ('aggregate',
+ 'port',
+ 'desc',
+ 'queue',
+ 'group'
+ ),
+ 'action' : 'display-rest',
+ 'sort' : ['groupid',],
+ 'url' : [
+ 'realtimestats/%(realtimestats)s/%(dpid)s/',
+ 'realtimestats/%(realtimestats)s/all/',
+ ],
+ 'rest-type' : 'dict-of-list-of-switch',
+ 'format' : 'realtime_%(realtimestats)s',
+ 'short-help' : 'Show requested item by querying switch',
+ 'doc' : 'switch|realtime-+',
+ },
+ ),
+ (
+ {
+ 'field' : 'realtimestats',
+ 'type' : 'enum',
+ 'values' : 'features',
+ 'action' : 'display-rest',
+ 'url' : [
+ 'realtimestats/%(realtimestats)s/%(dpid)s/',
+ 'realtimestats/%(realtimestats)s/all/',
+ ],
+ 'rest-type' : 'dict-of-dict-of-switch|ports',
+ 'format' : 'realtime_%(realtimestats)s',
+ 'doc' : 'switch|realtime_features',
+ },
+ {
+ 'field' : 'detail',
+ 'optional' : True,
+ 'type' : 'enum',
+ 'values' : ('details','brief'),
+ 'doc' : 'format|+',
+ },
+ ),
+ (
+ {
+ 'field' : 'realtimestats',
+ 'type' : 'enum',
+ 'values' : 'table',
+ },
+ {
+ 'field' : 'tabletype',
+ 'type' : 'enum',
+ 'values' : ('ip',
+ 'acl',
+ 'mpls'
+ ),
+ 'sort' : ['mplsLabel','priority',],
+ 'action' : 'display-rest',
+ 'url' : 'realtimestats/%(realtimestats)s/%(tabletype)s/flow/%(dpid)s/',
+ 'rest-type' : 'dict-of-list-of-switch',
+ 'format' : 'realtime_%(realtimestats)s_%(tabletype)s_flow',
+ 'doc' : 'format|+',
+ },
+ ),
+ (
+ {
+ 'field' : 'realtimestats',
+ 'type' : 'enum',
+ 'values' : 'group',
+ },
+ {
+ 'field' : 'groupId',
+ #'data' : {
+ # 'dpid' : '$dpid',
+ # },
+ #'type' : 'groupId',
+ 'completion' : 'group-id-completion',
+ #'sort' : ['mplsLabel','priority',],
+ 'action' : 'display-rest',
+ 'url' : 'realtimestats/%(realtimestats)s/%(groupId)s/%(dpid)s/',
+ 'rest-type' : 'dict-of-list-of-switch',
+ 'format' : 'realtime_group',
+ 'doc' : 'format|+',
+ },
+ ),
+ )
+ }
+ )
+}
+
+SWITCH_SHOW_STATS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show switch stats',
+ 'short-help' : 'show stats for selected switch',
+ 'no-supported' : False,
+ 'parent-field' : None,
+ 'obj-type' : 'switches',
+ 'args' : (
+ {
+ 'token' : 'switch',
+ # 'command-type' : 'display-rest',
+ },
+ {
+ 'field' : 'dpid',
+ 'completion' : 'complete-alias-choice',
+ 'type' : 'dpid',
+ 'help-name' : 'switch dpid or alias',
+ 'data-handler' : 'alias-to-value',
+ },
+ {
+ 'token' : 'stats',
+ 'action' : 'legacy-cli',
+ 'obj-type' : 'switch-stats',
+ },
+ )
+}
+
+SWITCH_SHOW_STATS_OBJECT_DETAILS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show statistics for a given switch',
+ 'no-supported' : False,
+ 'parent-field' : None,
+ 'obj-type' : 'switches',
+ 'args' : (
+ {
+ 'token' : 'switch',
+ # 'command-type' : 'display-rest',
+ },
+ {
+ 'field' : 'dpid',
+ 'completion' : 'complete-alias-choice',
+ 'type' : 'dpid',
+ 'help-name' : 'switch dpid or alias',
+ 'data-handler' : 'alias-to-value',
+ },
+ {
+ 'token' : 'stats',
+ 'action' : 'legacy-cli',
+ 'obj-type' : 'switch-stats',
+ },
+ {
+ 'field' : 'stats-type',
+ 'type' : 'enum',
+ 'values' : (
+ 'OFActiveFlow',
+ 'OFFlowMod',
+ 'OFPacketIn',
+ ),
+ },
+ {
+ 'field' : 'start-time',
+ 'tag' : 'start-time',
+ 'type' : 'date',
+ 'data-handler' : 'date-to-integer',
+ 'short-help' : 'Start time for displaying the stats',
+ 'optional' : True,
+ },
+ {
+ 'field' : 'end-time',
+ 'tag' : 'end-time',
+ 'type' : 'date',
+ 'data-handler' : 'date-to-integer',
+ 'short-help' : 'End time for displaying the stats',
+ 'optional' : True,
+ },
+ {
+ 'field' : 'duration',
+ 'tag' : 'duration',
+ 'type' : 'duration',
+ 'short-help' : 'Duration from the start or end for displaying the stats',
+ 'optional' : True,
+ },
+ {
+ 'field' : 'sample-interval',
+ 'tag' : 'sample-interval',
+ 'type' : 'integer',
+ 'short-help' : 'Spacing between sampling windows',
+ 'optional' : True,
+ },
+ {
+ 'field' : 'sample-count',
+ 'tag' : 'sample-count',
+ 'type' : 'integer',
+ 'short-help' : 'Number of samples in each window',
+ 'optional' : True,
+ },
+ {
+ 'field' : 'sample-window',
+ 'tag' : 'sample-window',
+ 'type' : 'integer',
+ 'short-help' : 'Window length for sampling',
+ 'optional' : True,
+ },
+ {
+ 'field' : 'data-format',
+ 'tag' : 'data-format',
+ 'type' : 'enum',
+ 'values' : ('value', 'rate',),
+ 'short-help' : 'Whether to display as a raw value or rate',
+ 'optional' : True,
+ },
+ {
+ 'field' : 'display',
+ 'tag' : 'display',
+ 'type' : 'enum',
+ 'values' : ('latest-value', 'graph', 'table'),
+ 'short-help' : 'Display the latest value, a graph, or a table',
+ 'optional' : True,
+ },
+ ),
+}
+
+
+show_switch_interfaces_pipeline = (
+ {
+ 'proc' : 'query-table',
+ 'obj-type' : 'interfaces',
+ 'key' : 'id',
+ },
+ {
+ 'proc' : 'query-table-append',
+ 'obj-type' : 'switch-interface-config',
+ 'key' : 'id',
+ },
+ {
+ 'proc' : 'join-rest',
+ 'url' : [
+ # this is using 'switch' from previous results,
+ # not from the data items
+ 'realtimestats/port/%(switch)s/',
+ ],
+ 'rest-type' : 'dict-of-list-of-switch|portNumber',
+ 'key' : 'switch|portNumber',
+ 'join-field' : 'switch|portNumber'
+ },
+ {
+ 'proc' : 'display',
+ 'sort' : ['switch', 'portName'],
+ 'format' : 'switch-interfaces',
+ },
+)
+
+SWITCH_SHOW_SWITCH_DPID_INTERFACES_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'no-supported' : False,
+ 'short-help' : 'Show interfaces for selected switch',
+ 'parent-field' : None,
+ 'obj-type' : 'switches',
+ 'args' : (
+ {
+ 'token' : 'switch',
+ 'command-type' : 'display-table',
+ },
+ {
+ 'choices' : (
+ {
+ 'field' : 'dpid',
+ 'completion' : 'complete-alias-choice',
+ 'type' : 'dpid',
+ 'help-name' : 'switch dpid or alias',
+ 'data-handler' : 'alias-to-value',
+ },
+ {
+ 'field' : 'dpid',
+ 'type' : 'enum',
+ 'values' : 'all',
+ 'short-help' : 'Show interfaces for all switches',
+ },
+ ),
+ },
+ {
+ 'choices' : (
+ (
+ {
+ 'token' : 'interfaces',
+ 'action' : 'legacy-cli',
+ 'obj-type' : 'switch-interfaces',
+ 'action' : show_switch_interfaces_pipeline,
+ 'short-help' : 'Show interfaces for switches',
+ 'doc' : 'switch|show-interfaces',
+ },
+ {
+ 'token' : 'stats',
+ 'action' : 'display-rest',
+ 'url' : 'realtimestats/port/%(dpid)s/',
+ 'rest-type' : 'dict-of-list-of-switch',
+ 'format' : 'realtime_port',
+ 'rest-type' : 'dict-of-list-of-switch',
+ 'optional' : True,
+ 'short-help' : 'Show interfaces stats for switches',
+ },
+ {
+ 'token' : 'alias',
+ 'action' : 'display-table',
+ 'obj-type' : 'switch-interface-alias',
+ 'optional' : True,
+ 'short-help' : 'Show interface aliases for switches',
+ 'scoped' : True,
+ 'doc' : 'switch|show-interfaces-alias',
+ }
+ ),
+ #{
+ # 'field' : 'vns',
+ # 'type' : 'enum',
+ # 'values' : 'vns',
+ # 'action' : 'legacy-cli',
+ # 'obj-type' : 'switch-ports-vns'
+ #},
+ {
+ 'field' : 'alias',
+ 'type' : 'enum',
+ 'values' : 'alias',
+ 'obj-type' : 'switch-alias',
+ 'action' : 'display-table',
+ 'doc' : 'switch|show-switch-alias',
+ },
+ )
+ },
+ {
+ 'optional' : True,
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details', 'brief',),
+ 'short-help' : 'Show switch output format level',
+ }
+ )
+}
+"""
+SWITCH_SUBMODE_SHOW_INTERFACE_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'config-switch*',
+ 'command-type' : 'display-table',
+ 'obj-type' : 'switch-interfaces',
+ 'short-help' : 'Show interfaces for switch associated with current submode',
+ 'args' : (
+ {
+ 'token' : 'interfaces',
+ 'action' : 'legacy-cli',
+ 'scoped' : True,
+ 'action' : show_switch_interfaces_pipeline,
+ },
+ )
+}
+
+
+SWITCH_SHOW_TCPDUMP_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show switch tcpdump via controller',
+ 'no-supported' : False,
+ 'parent-field' : None,
+ 'current-mode-obj-id' : None,
+ 'obj-type' : 'switches',
+ 'args' : (
+ {
+ 'token' : 'switch',
+ 'obj-type' : 'switches',
+ },
+ {
+ 'field' : 'dpid',
+ 'optional' : False,
+ 'completion' : 'complete-alias-choice',
+ 'type' : 'dpid',
+ 'help-name' : 'switch dpid or alias',
+ 'data-handler' : 'alias-to-value',
+ },
+ {
+ 'field' : 'tcpdump',
+ 'optional' : False,
+ 'type' : 'enum',
+ 'values' : 'trace',
+ 'obj-type' : 'switch-tcpdump',
+ 'action' : 'legacy-cli',
+ },
+ {
+ 'field' : 'oneline',
+ 'type' : 'enum',
+ 'values' : 'oneline',
+ 'optional' : True,
+ },
+ {
+ 'field' : 'single_session',
+ 'type' : 'enum',
+ 'values' : 'single-session',
+ 'optional' : True,
+ },
+ {
+ 'field' : 'echo_reply',
+ 'type' : 'enum',
+ 'values' : 'echo-reply',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'echo_request',
+ 'type' : 'enum',
+ 'values' : 'echo-request',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'features_rep',
+ 'type' : 'enum',
+ 'values' : 'features-rep',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'flow_mod',
+ 'type' : 'enum',
+ 'values' : 'flow-mod',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'flow_removed',
+ 'type' : 'enum',
+ 'values' : 'flow-removed',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'get_config_rep',
+ 'type' : 'enum',
+ 'values' : 'get-config-rep',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'hello',
+ 'type' : 'enum',
+ 'values' : 'hello',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'packet_in',
+ 'type' : 'enum',
+ 'values' : 'packet-in',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'packet_out',
+ 'type' : 'enum',
+ 'values' : 'packet-out',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'port_status',
+ 'type' : 'enum',
+ 'values' : 'port-status',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'set_config',
+ 'type' : 'enum',
+ 'values' : 'set-config',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'stats_reply',
+ 'type' : 'enum',
+ 'values' : 'stats-reply',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'stats_request',
+ 'type' : 'enum',
+ 'values' : 'stats-request',
+ 'optional' : True,
+ 'permute' : 'skip',
+ },
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : 'detail',
+ 'optional' : True,
+ },
+ )
+}
+
+#
+# ------------------------------------------------------------------------------
+# SWITCH_TUNNEL_SHOW_COMMAND_DESCRIPTION
+#
+
+show_tunnel_pipeline = (
+ {
+ 'proc' : 'query-rest',
+ 'url' : [
+ 'tunnel-manager/%(dpid)s',
+ 'tunnel-manager/all',
+ ],
+ 'rest-type' : 'dict-of-dict-of-dpid',
+ },
+ {
+ 'proc' : 'join-table',
+ 'obj-type' : 'interfaces',
+ 'key' : 'switch|portName',
+ 'join-field' : 'hexDpid|tunnelEndPointIntfName',
+ 'add-field' : 'portNumber|portNumber',
+ },
+ {
+ 'proc' : 'join-rest',
+ 'url' : 'realtimestats/port/%(dpid)s/',
+ 'rest-type' : 'dict-of-list-of-switch|portNumber',
+ 'key' : 'switch|portNumber',
+ 'join-field' : 'hexDpid|portNumber',
+ },
+ {
+ 'proc' : 'display',
+ 'format' : 'tunnel-pipeline',
+ }
+)
+"""
+import fmtcnv
+"""
+TUNNEL_PIPELINE_FORMAT = {
+ 'tunnel-pipeline' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx',
+ 'dpid',
+ 'tunnelCapable',
+ 'tunnelEnabled',
+ 'tunnelEndPointIntfName',
+ 'tunnelIPAddr',
+ 'tunnelState',
+ 'receivePackets',
+ 'receiveBytes',
+ 'transmitPackets',
+ 'transmitBytes',
+ ]
+ },
+
+ 'fields' : {
+ 'dpid' : {
+ 'verbose-name' : 'Switch DPID',
+ 'primary_key': True,
+ 'formatter' : fmtcnv.replace_switch_with_alias,
+ },
+ 'tunnelCapable' : {
+ 'verbose-name' : 'Capable',
+ },
+ 'tunnelEnabled' : {
+ 'verbose-name' : 'Enabled',
+ },
+ 'tunnelEndPointIntfName' : {
+ 'verbose-name' : 'IF Name',
+ },
+ 'tunnelIPAddr' : {
+ 'verbose-name' : 'IP Address',
+ },
+ 'tunnelState' : {
+ 'verbose-name' : 'State',
+ },
+ 'receivePackets' : {
+ 'verbose-name' : 'Rx Pkts',
+ },
+ 'receiveBytes' : {
+ 'verbose-name' : 'Rx Bytes',
+ },
+ 'transmitPackets' : {
+ 'verbose-name' : 'Tx Pkts',
+ },
+ 'transmitBytes' : {
+ 'verbose-name' : 'Tx Bytes',
+ },
+ },
+ },
+}
+
+
+
+SWITCH_TUNNEL_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'feature' : 'vns',
+ 'short-help' : 'Show tunnels for all switches',
+ 'command-type' : 'display-rest',
+ 'url' : 'tunnel-manager/all',
+ 'obj-type' : 'switch',
+ 'action' : show_tunnel_pipeline,
+ 'args' : (
+ 'tunnel',
+ ),
+}
+
+
+SWITCH_TUNNEL_SHOW_WITH_DPID_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'feature' : 'vns',
+ 'short-help' : 'Show tunnels for selected switches',
+ 'command-type' : 'display-rest',
+ 'obj-type' : 'switch',
+ 'url' : 'tunnel-manager/%(dpid)s',
+ 'format' : 'tunnel-details',
+ 'action' : show_tunnel_pipeline,
+ 'args' : (
+ 'tunnel',
+ {
+ 'choices' : (
+ {
+ 'field' : 'dpid',
+ 'type' : 'enum',
+ 'values' : 'all',
+ },
+ {
+ 'field' : 'dpid',
+ 'completion' : 'complete-object-field',
+ 'type' : 'dpid',
+ },
+ ),
+ },
+ ),
+}
+#
+# ------------------------------------------------------------------------------
+# SWITCH_CORE_SWITCH_TERMINATION_COMMAND_DESCRIPTION
+#
+
+SWITCH_CORE_SWITCH_COMMAND_DESCRIPTION = {
+ 'name' : 'core-switch',
+ 'short-help' : 'Enable core-switch property for this switch',
+ 'mode' : 'config-switch',
+ 'parent-field' : 'dpid',
+ 'obj-type' : 'switch-config',
+ 'doc' : 'switch|core-switch',
+ 'doc-example' : 'switch|core-switch-example',
+ 'args' : (),
+ 'action': (
+ {
+ 'proc' : 'update-config',
+ 'data' : {'core-switch' : True}
+ },
+ ),
+ 'no-action': (
+ {
+ 'proc' : 'update-config',
+ 'data' : {'core-switch' : False},
+ }
+ )
+}
+#
+# ------------------------------------------------------------------------------
+# SWITCH_TUNNEL_TERMINATION_COMMAND_DESCRIPTION
+#
+
+SWITCH_TUNNEL_TERMINATION_COMMAND_DESCRIPTION = {
+ 'name' : 'tunnel',
+ 'short-help' : 'Enable/Disable tunnel creation for this switch',
+ 'mode' : 'config-switch',
+ 'command-type' : 'update-config',
+ 'parent-field' : 'dpid',
+ 'obj-type' : 'switch-config',
+ 'doc' : 'switch|tunnel',
+ 'doc-example' : 'switch|tunnel-example',
+ 'data' : { 'tunnel-termination' : 'default' }, # for no command
+ 'args' : (
+ 'termination',
+ {
+ 'field' : 'tunnel-termination',
+ 'type' : 'enum',
+ 'values' : ( "enabled", "disabled" ),
+ 'optional-for-no' : True,
+ }
+ )
+}
+#
+# ------------------------------------------------------------------------------
+# SWITCH_ALIAS_COMMAND_DESCRIPTION
+#
+
+SWITCH_SWITCH_ALIAS_COMMAND_DESCRIPTION = {
+ 'name' : 'switch-alias',
+ 'mode' : 'config-switch',
+ 'short-help' : 'Attach alias to switch',
+ 'doc' : 'switch|alias',
+ 'doc-example' : 'switch|alias-example',
+ 'command-type' : 'manage-alias',
+ 'obj-type' : 'switch-alias',
+ 'scoped' : True,
+ 'args' : (
+ {
+ 'field' : 'id',
+ 'optional-for-no' : False,
+ 'completion' : 'complete-object-field',
+ }
+ )
+}
+
+#
+# ------------------------------------------------------------------------------
+# SWITCH_INTERFACE_COMMAND_DESCRIPTION
+# enter config-switch-if submode
+#
+
+SWITCH_INTERFACE_COMMAND_DESCRIPTION = {
+ 'name' : 'interface',
+ 'mode' : 'config-switch*',
+ 'short-help' : 'Enter switch-if submode, configure switch interface',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'switch-interface-config',
+ 'parent-field' : 'switch',
+ 'current-mode-obj-id' : 'switch',
+ 'submode-name' : 'config-switch-if',
+ 'syntax-help' : 'Enter an interface name',
+ 'doc' : 'switch|interface',
+ 'doc-example' : 'switch|interface-example',
+ 'args' : (
+ {
+ 'field' : 'name',
+ 'completion' : [ 'complete-object-field',
+ 'complete-from-another',
+ ],
+ 'other' : 'interfaces|portName',
+ 'scoped' : 'dpid',
+ 'data-handler' : 'warn-missing-interface',
+ }
+ )
+}
+
+#
+# ------------------------------------------------------------------------------
+# SWITCHPORT_COMMAND_DESCRIPTION
+# 'switchport mode external'
+# 'no switchport mode external'
+#
+
+SWITCHPORT_COMMAND_DESCRIPTION = {
+ 'name' : 'switchport',
+ 'short-help' : 'Configure interface as connected to an external network',
+ 'mode' : 'config-switch-if',
+ 'command-type' : 'config',
+ 'obj-type' : 'switch-interface-config',
+ 'fields' : ('broadcast', 'mode',),
+ 'action' : 'write-fields',
+ 'no-action' : 'reset-fields',
+ 'doc' : 'switch|switchport',
+ 'doc-example' : 'switch|switchport-example',
+ 'args' : (
+ 'mode',
+ {
+ 'field' : 'mode',
+ 'type' : 'enum',
+ 'values' : 'external',
+ 'help-name' : 'interface connects to external network',
+ 'short-help' : 'interface connects to external network',
+ 'syntax-help' : 'external'
+ },
+ )
+}
+
+#
+# ------------------------------------------------------------------------------
+#
+
+
+SWITCH_INTERFACE_INTERFACE_ALIAS_COMMAND_DESCRIPTION = {
+ 'name' : 'interface-alias',
+ 'mode' : 'config-switch-if',
+ 'short-help' : 'Attach alias to switch interface',
+ 'command-type' : 'manage-alias',
+ 'obj-type' : 'switch-interface-alias',
+ 'scoped' : True,
+ 'doc' : 'switch|interface-alias',
+ 'doc-example' : 'switch|interface-alias-example',
+ 'args' : (
+ {
+ 'field' : 'id',
+ 'optional-for-no' : False,
+ 'completion' : 'complete-object-field',
+ 'short-help' : 'Alias string',
+ }
+ )
+}
+"""
+#
+# FORMATS
+#
+
+
+SWITCH_FORMAT = {
+ 'switch' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', '@', 'switch-alias', 'connected-since',
+ 'ip-address', 'type', 'controller'],
+ 'details' : [ 'Idx','@', 'switch-alias', 'connected-since',
+ 'ip-address', 'type', 'controller'],
+ 'brief' : [ 'Idx', '@', 'switch-alias', 'controller'],
+ },
+ 'fields' : {
+ '@' : {
+ 'verbose-name' : 'Switch DPID',
+ },
+ 'active' : {
+ },
+ 'core-switch' : {
+ 'verbose-name' : 'Core Switch',
+ 'validate' : 'validate_switch_core_switch',
+ },
+ 'connected-since' : {
+ 'verbose-name' : 'Connected Since',
+ #'formatter' : fmtcnv.timestamp_to_local_timestr,
+ },
+ 'capabilities' : {
+ 'formatter' : fmtcnv.decode_switch_capabilities,
+ },
+ 'actions' : {
+ 'formatter' : fmtcnv.decode_switch_actions,
+ },
+ 'ip-address' : {
+ 'verbose-name' : 'Connected At',
+ },
+ 'socket-address' : {
+ },
+ 'buffers' : {
+ },
+ 'controller' : {
+ 'verbose-name' : 'Controller',
+ },
+ 'tables' : {
+ },
+ 'switch-alias' : {
+
+ 'verbose-name' : 'Alias'
+ },
+ 'tunnelCapable' : {
+ 'verbose-name' : 'Tun Capable',
+ },
+ 'tunnelEnabled' : {
+ 'verbose-name' : '-Enabled',
+ },
+ 'tunnelState' : {
+ 'verbose-name' : '-State',
+ },
+ 'dp-desc' : {
+ },
+ 'hw-desc' : {
+ },
+ 'sw-desc' : {
+ },
+ 'serial-num' : {
+ },
+ 'type' : {
+ },
+ }
+ },
+}
+"""
+SWITCH_CONFIG_FORMAT = {
+ 'switch-config' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'Idx',
+ 'dpid',
+ 'tunnel-termination',
+ 'core-switch',
+ ],
+ },
+ },
+}
+
+
+SWITCH_ALIAS_FORMAT = {
+ 'switch-alias' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'id', 'switch' ],
+ 'brief' : [ 'Idx', 'id', 'switch' ],
+ },
+ },
+}
+
+
+SWITCH_INTERFACE_CONFIG_FORMAT = {
+ 'switch-interface-config' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'if-name', 'mode' ]
+ },
+ 'fields' : {
+ 'broadcast' : {
+ },
+ 'name' : {
+ },
+ 'mode' : {
+ 'verbose-name' : 'Switchport Mode',
+ },
+ },
+ },
+}
+
+
+SWITCH_INTERFACE_ALIAS_FORMAT = {
+ 'switch-interface-alias' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'id', 'switch', 'name' ]
+ },
+ 'fields' : {
+ 'id' : { 'verbose-name' : 'Alias',
+ }
+ }
+ },
+}
+
+SWITCH_INTERFACES_FORMAT = {
+ 'switch-interfaces' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'switch', 'portName', 'state', 'config',
+ 'receiveBytes', 'receivePackets', 'receiveErrors',
+ 'transmitBytes', 'transmitPackets', 'transmitErrors',
+ 'mode', 'broadcast',
+ ],
+ 'details' : [ 'Idx', 'switch', 'portName', 'hardwareAddress',
+ 'config', 'stp-state', 'state', 'currentFeatures',
+ 'advertisedFeatures', 'supportedFeatures',
+ 'peer-features', 'mode', 'broadcast',
+ ],
+ 'brief' : [ 'Idx', 'switch', 'portName', 'state', 'config' ],
+ },
+
+ 'fields' : {
+ 'id' : {
+ },
+ 'switch' : { 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'portName' : { 'verbose-name' : 'IF',
+ },
+ 'hardwareAddress' : { 'verbose-name' : 'MAC Address'
+ },
+ 'config' : {
+ 'formatter' : fmtcnv.decode_port_config
+ },
+ 'state' : { 'verbose-name' : 'Link',
+ 'formatter' : fmtcnv.decode_port_up_down,
+ },
+ 'stp-state' : {
+ 'formatter' : lambda i, data :
+ fmtcnv.decode_port_stp_state(data['state'],
+ data),
+ },
+ 'currentFeatures' : { 'verbose-name' : 'Curr Features',
+ 'formatter' : fmtcnv.decode_port_features
+ },
+ 'advertisedFeatures' : { 'verbose-name' : 'Adv Features',
+ 'formatter' : fmtcnv.decode_port_features
+ },
+ 'supportedFeatures' : { 'verbose-name' : 'Supp Features',
+ 'formatter' : fmtcnv.decode_port_features
+ },
+ 'peer-features' : { 'verbose-name' : 'Peer Features',
+ 'formatter' : fmtcnv.decode_port_features
+ },
+ 'receiveBytes' : { 'verbose-name' : 'Rcv Bytes',
+ 'formatter' : fmtcnv.decode_port_counter},
+ 'receivePackets' : { 'verbose-name' : 'Rcv Pkts',
+ 'formatter' : fmtcnv.decode_port_counter},
+ 'receiveErrors' : { 'verbose-name' : 'Rcv Errs',
+ 'formatter' : fmtcnv.decode_port_counter},
+ 'transmitBytes' : { 'verbose-name' : 'Xmit Bytes',
+ 'formatter' : fmtcnv.decode_port_counter},
+ 'transmitPackets' : { 'verbose-name' : 'Xmit Pkts',
+ 'formatter' : fmtcnv.decode_port_counter},
+ 'transmitErrors' : { 'verbose-name' : 'Xmit Errs',
+ 'formatter' : fmtcnv.decode_port_counter},
+ },
+ },
+}
+
+TUNNEL_DETAILS_FORMAT = {
+ 'tunnel-details' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'dpid', 'localTunnelIPAddr',
+ 'tunnelPorts',
+ ]
+ },
+
+ 'fields' : {
+ 'dpid' : {
+ 'verbose-name' : 'Switch DPID',
+ 'primary_key': True,
+ 'formatter' : fmtcnv.replace_switch_with_alias,
+ },
+ 'localTunnelIPAddr' : {
+ 'verbose-name' : 'Local tunnel IP',
+ },
+ 'tunnelPorts' : {
+ 'verbose-name' : 'Remote tunnel IP',
+ },
+ },
+ },
+}
+"""
+
+def group_id_completion(prefix, data, completions):
+ dpid = data.get('dpid')
+ #print dpid
+ query_url = "http://127.0.0.1:8000/rest/v1/realtimestats/group/%s/" %(dpid)
+ result = command.sdnsh.store.rest_simple_request(query_url)
+ entries = json.loads(result)
+ entries = entries[dpid]
+ #print "result", entries
+ for entry in entries:
+ #print entry['groupId']
+ if str(entry['groupId']).startswith(prefix):
+ completions[str(entry['groupId'])+' '] = entry['groupId']
+ return
+
+command.add_completion('group-id-completion', group_id_completion,
+ {'kwargs': { 'prefix' : '$text',
+ 'data' : '$data',
+ 'completions' : '$completions',
+ }})
diff --git a/cli/desc/version200/switch_model.py b/cli/desc/version200/switch_model.py
new file mode 100755
index 0000000..3478748
--- /dev/null
+++ b/cli/desc/version200/switch_model.py
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_disable_edit('switch-config', 'tunnel-termination')
+command.model_obj_type_disable_edit('switch-config', 'core-switch')
+command.model_obj_type_disable_edit('switch-config', 'dpid')
+
+command.model_obj_type_disable_submode('switch')
+
+command.model_obj_type_set_case('switch', 'dpid', 'lower')
+command.model_obj_type_set_case('switch-config', 'dpid', 'lower')
+
+command.model_obj_type_set_case('switch-interface-config', 'name', 'lower')
+
+
+
+# rest-to-model model-like results from the switches/devices rest api
+command.model_obj_type_set_case('switches', 'id', 'lower')
+command.model_obj_type_set_case('switches', 'dpid', 'lower')
+
+command.model_obj_type_set_case('interfaces', 'id', 'lower')
+command.model_obj_type_set_case('interfaces', 'name', 'lower')
diff --git a/cli/desc/version200/tacacs.py b/cli/desc/version200/tacacs.py
new file mode 100755
index 0000000..31efcf2
--- /dev/null
+++ b/cli/desc/version200/tacacs.py
@@ -0,0 +1,391 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+"""
+TACACS_SERVER_HOST_COMMAND_DESCRIPTION = {
+ 'name' : 'tacacs',
+ 'mode' : 'config*',
+ 'short-help' : 'TACACS timeout, ip server address',
+ 'doc' : 'tacacs|tacacs',
+ 'doc-example' : 'tacacs|tacacs-example',
+ 'command-type' : 'config-object',
+ 'obj-type' : 'tacacs-plus-host',
+ 'parent-field' : None,
+ 'args' : (
+ 'server',
+ {
+ 'choices' : (
+ (
+ {
+ 'token' : 'timeout',
+ 'data' : {
+ 'id' : 'tacacs',
+ 'timeout' : 0
+ },
+ 'obj-type' : 'tacacs-plus-config',
+ 'no-action' : 'write-object',
+ 'short-help' : 'configure timeout',
+ 'doc' : 'tacacs|tacacs-timeout',
+ },
+ {
+ 'field' : 'timeout',
+ 'type' : 'integer',
+ 'data' : {
+ 'id' : 'tacacs'
+ },
+ 'obj-type' : 'tacacs-plus-config',
+ 'action' : 'write-object',
+ 'optional-for-no' : True,
+ },
+ ),
+ (
+ {
+ 'token' : 'key',
+ 'data' : {
+ 'id' : 'tacacs',
+ 'key' : '',
+ },
+ 'no-action' : 'write-object',
+ 'obj-type' : 'tacacs-plus-config',
+ 'short-help' : 'set shared TACACS server key',
+ 'doc' : 'tacacs|tacacs-key',
+ },
+ {
+ 'field' : 'key',
+ 'type' : 'string',
+ 'data' : { 'id' : 'tacacs' },
+ 'obj-type' : 'tacacs-plus-config',
+ 'action' : 'write-object',
+ 'optional-for-no' : True,
+ },
+ ),
+ (
+ {
+ 'field' : 'ip',
+ 'tag' : 'host',
+ 'type' : 'ip-address-not-mask',
+ 'completion' : 'complete-object-field',
+ 'short-help' : 'set specific TACACS host properties',
+ 'doc' : 'tacacs|tacacs-host',
+ },
+ {
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'args' : (
+ {
+ 'token' : 'key',
+ 'no-action' : 'reset-fields-explicit',
+ 'data' : { 'key' : '' },
+ 'obj-type' : 'tacacs-plus-host',
+ 'short-help' : 'set shared TACACS server key',
+ 'doc' : 'tacacs|tacacs-host-key',
+ },
+ {
+ 'optional-for-no' : True,
+ 'args' : {
+ 'field' : 'key',
+ 'type' : 'string',
+ 'obj-type' : 'tacacs-plus-host',
+ },
+ }
+ ),
+ },
+ ),
+ ),
+ },
+ )
+}
+
+TACACS_AAA_AUTHORIZATION_EXEC_COMMAND_DESCRIPTION = {
+ 'name' : 'aaa',
+ 'mode' : 'config*',
+ 'short-help' : 'Configure authorization parameters',
+ 'command-type' : 'config',
+ 'doc' : 'aaa|aaa-authorization',
+ 'doc-example' : 'aaa|aaa-authorization-example',
+ 'obj-type' : 'tacacs-plus-config',
+ 'no-action' : 'reset-fields-explicit',
+ 'fields' : [ 'tacacs-plus-authz', 'local-authz' ],
+ 'args' : (
+ 'authorization',
+ {
+ 'token' : 'exec',
+ 'short-help' : 'Configure authorization for starting a shell',
+ 'doc' : 'aaa|aaa-authorization-exec',
+ },
+ {
+ 'token' : 'default',
+ 'short-help' : 'Configure authorization for the default channel',
+ 'doc' : 'aaa|aaa-authorization-exec-use-default',
+ },
+ {
+ 'optional-for-no' : True,
+ 'choices' : (
+ {
+ 'token' : 'local',
+ 'short-help' : 'Use local database for authorization',
+ 'doc' : 'aaa|aaa-authorization-exec-use-local',
+ 'action' : {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'tacacs',
+ 'local-authz' : True,
+ 'tacacs-plus-authz' : False,
+ },
+ },
+ },
+ (
+ {
+ 'token' : 'group',
+ 'short-help' : 'Use a server-group',
+ },
+ {
+ 'token' : 'tacacs+',
+ 'short-help' : 'Use list of all defined TACACS+ hosts',
+ 'doc' : 'aaa|aaa-authorization-exec-use-tacacs',
+ 'action' : {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'tacacs',
+ 'local-authz' : False,
+ 'tacacs-plus-authz' : True,
+ },
+ },
+ },
+ {
+ 'token' : 'local',
+ 'short-help' : 'Use local database for authorization',
+ 'doc' : 'aaa|aaa-authorization-exec-use-local',
+ 'optional' : True,
+ 'action' : {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'tacacs',
+ 'local-authz' : True,
+ 'tacacs-plus-authz' : True,
+ },
+ },
+ },
+ ),
+ ),
+ },
+ ),
+}
+
+TACACS_AAA_AUTHENTICATION_LOGIN_COMMAND_DESCRIPTION = {
+ 'name' : 'aaa',
+ 'mode' : 'config*',
+ 'short-help' : 'Configure authentication parameters',
+ 'doc' : 'aaa|aaa-authentication',
+ 'doc-example' : 'aaa|aaa-authentication-example',
+ 'command-type' : 'config',
+ 'no-action' : 'reset-fields-explicit',
+ 'obj-type' : 'tacacs-plus-config',
+ 'fields' : [ 'tacacs-plus-authn', 'local-authn' ],
+ 'args' : (
+ 'authentication',
+ {
+ 'token' : 'login',
+ 'short-help' : 'Configure authentication for starting a shell',
+ 'doc' : 'aaa|aaa-authentication-login',
+ },
+ {
+ 'token' : 'default',
+ 'short-help' : 'Configure authentication via the default channel',
+ 'doc' : 'aaa|aaa-authentication-login-use-default',
+ },
+ {
+ 'optional-for-no' : True,
+ 'choices' : (
+ (
+ {
+ 'token' : 'local',
+ 'short-help' : 'Use local database for authentication',
+ 'doc' : 'aaa|aaa-authentication-login-use-local',
+ 'action' : {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'tacacs',
+ 'local-authn' : True,
+ 'tacacs-plus-authn' : False,
+ },
+ },
+ },
+ ),
+ (
+ 'group',
+ {
+ 'token' : 'tacacs+',
+ 'short-help' : 'Use list of all defined TACACS+ hosts',
+ 'doc' : 'aaa|aaa-authentication-login-use-tacacs',
+ 'action' : {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'tacacs',
+ 'local-authn' : False,
+ 'tacacs-plus-authn' : True,
+ },
+ },
+ },
+ {
+ 'token' : 'local',
+ 'optional' : True,
+ 'short-help' : 'Use local database for authentication',
+ 'doc' : 'aaa|aaa-authentication-login-use-local',
+ 'action' : {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'tacacs',
+ 'local-authn' : True,
+ 'tacacs-plus-authn' : True,
+ },
+ },
+ },
+ ),
+ ),
+ },
+ ),
+}
+
+TACACS_AAA_ACCOUNTING_EXEC_COMMAND_DESCRIPTION = {
+ 'name' : 'aaa',
+ 'mode' : 'config*',
+ 'short-help' : 'Configure accounting parameters',
+ 'doc' : 'aaa|aaa-accounting',
+ 'doc-example' : 'aaa|aaa-accounting-example',
+ 'all-help' : 'Authentication, Authorization, and Accounting',
+ 'command-type' : 'config',
+ 'obj-type' : 'tacacs-plus-config',
+ 'no-action' : 'reset-fields-explicit',
+ 'fields' : [ 'tacacs-plus-acct' ],
+ 'args' : (
+ 'accounting',
+ {
+ 'token' : 'exec',
+ 'short-help' : 'Configure accounting for starting a shell',
+ 'doc' : 'aaa|aaa-accounting-exec',
+ },
+ {
+ 'token' : 'default',
+ 'short-help' : 'Configure accounting for the default channel',
+ 'doc' : 'aaa|aaa-authorization-exec-use-default',
+ },
+ {
+ 'optional-for-no' : True,
+ 'choices' : (
+ (
+ {
+ 'token' : 'none',
+ 'short-help' : 'No accounting',
+ 'doc' : 'aaa|aaa-accounting-exec-use-none',
+ 'action' : {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'tacacs',
+ 'tacacs-plus-acct' : False,
+ },
+ },
+ },
+ ),
+ (
+ {
+ 'token' : 'start-stop',
+ 'short-help' : 'Record start and stop',
+ 'doc' : 'aaa|aaa-accounting-exec-use-start-stop',
+ },
+ {
+ 'token' : 'group',
+ 'short-help' : 'Use a server-group',
+ 'doc' : 'aaa|aaa-accounting-exec-use-server-group',
+ },
+ {
+ 'token' : 'tacacs+',
+ 'short-help' : 'Use list of all defined TACACS+ hosts',
+ 'doc' : 'aaa|aaa-accounting-exec-use-tacacs',
+ 'action' : {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'tacacs',
+ 'tacacs-plus-acct' : True,
+ },
+ },
+ },
+ ),
+ ),
+ },
+ ),
+ }
+
+SHOW_TACACS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show TACACS operational state',
+ 'doc' : 'tacacs|show',
+ 'doc-example' : 'tacacs|show-example',
+ 'command-type' : 'display-table',
+ 'obj-type' : 'tacacs-plus-config',
+ 'parent-field' : None,
+ 'args' : (
+ 'tacacs',
+ ),
+ 'action' : (
+ {
+ 'proc' : 'display-table',
+ },
+ {
+ 'proc' : 'display-table',
+ 'title' : '\nTACACS Server Hosts\n',
+ 'sort' : 'timestamp',
+ 'obj-type' : 'tacacs-plus-host',
+ },
+ ),
+}
+
+SHOW_TACACS_PLUS_CONFIG_FORMAT = {
+ 'tacacs-plus-config' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx',
+ 'tacacs-plus-authn',
+ 'tacacs-plus-authz',
+ 'tacacs-plus-acct',
+ 'local-authn',
+ 'local-authz',
+ 'timeout',
+ 'key',
+ ],
+ },
+ },
+}
+
+SHOW_TACACS_PLUS_HOST_FORMAT = {
+ 'tacacs-plus-host' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'ip', 'key',
+ ],
+ },
+ 'fields' : {
+ 'Idx' : {
+ 'verbose-name' : '#',
+ },
+ 'ip' : {
+ 'verbose-name' : 'Ip Address',
+ },
+ 'key' : {
+ },
+
+ }
+ }
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/tacacs_model.py b/cli/desc/version200/tacacs_model.py
new file mode 100755
index 0000000..cc7cdb6
--- /dev/null
+++ b/cli/desc/version200/tacacs_model.py
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_disable_submode('tacacs-plus-config')
+command.model_obj_type_disable_submode('tacacs-plus-host')
+
+command.model_obj_type_disable_edit('tacacs-plus-config', 'tacacs-plus-authn')
+command.model_obj_type_disable_edit('tacacs-plus-config', 'tacacs-plus-authz')
+command.model_obj_type_disable_edit('tacacs-plus-config', 'tacacs-plus-acct')
+command.model_obj_type_disable_edit('tacacs-plus-config', 'local-authn')
+command.model_obj_type_disable_edit('tacacs-plus-config', 'local-authz')
+command.model_obj_type_disable_edit('tacacs-plus-config', 'timeout')
+command.model_obj_type_disable_edit('tacacs-plus-config', 'key')
+
+command.model_obj_type_disable_edit('tacacs-plus-host', 'ip')
+command.model_obj_type_disable_edit('tacacs-plus-host', 'key')
diff --git a/cli/desc/version200/tacacs_run_config.py b/cli/desc/version200/tacacs_run_config.py
new file mode 100755
index 0000000..88dd6a5
--- /dev/null
+++ b/cli/desc/version200/tacacs_run_config.py
@@ -0,0 +1,113 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# tacacs.
+#
+
+import run_config
+import utif
+
+
+#
+# --------------------------------------------------------------------------------
+
+def create_obj_type_dict(context, obj_type, field):
+ """
+ Should there be some collections of middeleware functions for use by packages?
+ """
+ entries = context.get_table_from_store(obj_type)
+ result_dict = {}
+ for entry in entries:
+ if entry[field] in result_dict:
+ result_dict[entry[field]].append(entry)
+ else:
+ result_dict[entry[field]] = [entry]
+
+ return result_dict
+
+#
+# --------------------------------------------------------------------------------
+
+def running_config_tacacs(context, config, words):
+ t_obj_type = 'tacacs-plus-config'
+ th_obj_type = 'tacacs-plus-host'
+
+ tacacs = context.get_table_from_store(t_obj_type)
+ if len(tacacs) > 1:
+ print 'running_config_tacacs: more than one tacacs record'
+
+ tacacs_host = context.rest_query_objects(th_obj_type,
+ {'orderby' : 'timestamp'})
+
+
+ t_config = []
+
+ if tacacs:
+ tacacs = tacacs[0]
+
+ if run_config.not_default_value(t_obj_type, 'tacacs-plus-authn', tacacs['tacacs-plus-authn']) and \
+ run_config.not_default_value(t_obj_type, 'local-authn', tacacs['local-authn']):
+ t_config.append('aaa authentication login default group tacacs+\n')
+ elif run_config.not_default_value(t_obj_type, 'tacacs-plus-authn', tacacs['tacacs-plus-authn']):
+ t_config.append('aaa authentication login default group tacacs+ local\n')
+
+ if run_config.not_default_value(t_obj_type, 'tacacs-plus-authz', tacacs['tacacs-plus-authz']) and \
+ run_config.not_default_value(t_obj_type, 'local-authz', tacacs['local-authz']):
+ t_config.append('aaa authorization exec default group tacacs+\n')
+ elif run_config.not_default_value(t_obj_type, 'tacacs-plus-authz', tacacs['tacacs-plus-authz']):
+ t_config.append('aaa authorization exec default group tacacs+ local\n')
+
+ if run_config.not_default_value(t_obj_type, 'tacacs-plus-acct', tacacs['tacacs-plus-acct']):
+ t_config.append('aaa accounting exec default start-stop group tacacs+\n')
+
+ if run_config.not_default_value(t_obj_type, 'key', tacacs['key']):
+ t_config.append('tacacs server key %s\n' % tacacs['key'])
+
+ if run_config.not_default_value(t_obj_type, 'timeout', tacacs['timeout']):
+ t_config.append('tacacs server timeout %s\n' % tacacs['timeout'])
+
+ for h in tacacs_host:
+ if run_config.not_default_value(th_obj_type, 'key', h['key']):
+ key = ' key %s' % utif.quote_string(h['key'])
+ else:
+ key = ''
+
+ t_config.append('tacacs server host %s%s\n' % (h['ip'], key))
+
+ if len(t_config):
+ config.append('!\n')
+ config += t_config
+
+
+#
+# --------------------------------------------------------------------------------
+
+tacacs_running_config_tuple = (
+ (
+ {
+ 'optional' : False,
+ 'field' : 'running-config',
+ 'type' : 'enum',
+ 'values' : 'tacacs',
+ 'doc' : 'running-config|show-tacacs',
+ 'short-help': 'Configuration for TACACS authentication'
+ },
+ ),
+)
+
+run_config.register_running_config('tacacs', 2000, None,
+ running_config_tacacs,
+ tacacs_running_config_tuple)
diff --git a/cli/desc/version200/tacacs_techsupport.py b/cli/desc/version200/tacacs_techsupport.py
new file mode 100755
index 0000000..27e5498
--- /dev/null
+++ b/cli/desc/version200/tacacs_techsupport.py
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 2012,2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+from tech_support import add_to_show_tech_support
+
+# SNMP commands to be included in 'show tech-support' output
+tacacs_show_tech_support_commands = [
+ ['cli', 'show tacacs'],
+ ['shell', 'cat /etc/nsswitch.conf'],
+ ['shell', 'cat /etc/pam.d/sshd'],
+]
+
+# add commands to central command table used for 'show tech-support'
+for entry in tacacs_show_tech_support_commands:
+ add_to_show_tech_support(str(entry[0]), str(entry[1]))
diff --git a/cli/desc/version200/tag-model.py b/cli/desc/version200/tag-model.py
new file mode 100755
index 0000000..23eb435
--- /dev/null
+++ b/cli/desc/version200/tag-model.py
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_enable_cascade_delete('tag-mapping')
diff --git a/cli/desc/version200/tag.py b/cli/desc/version200/tag.py
new file mode 100755
index 0000000..309eb97
--- /dev/null
+++ b/cli/desc/version200/tag.py
@@ -0,0 +1,173 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+"""
+#
+#
+
+TAG_SUBMODE_COMMAND_DESCRIPTION = {
+ 'name' : 'tag',
+ 'short-help' : 'Enter tag, configure switch details',
+ 'doc' : 'tag|tag',
+ 'doc-example' : 'tag|tag-example',
+ 'mode' : 'config*',
+ 'obj-type' : 'tag',
+ 'command-type' : 'config-submode',
+ 'submode-name' : 'config-tag',
+ 'doc' : 'tag|tag',
+ 'args' : (
+ {
+ 'field' : 'id',
+ 'type' : 'string',
+ #'completion' : 'complete-object-field',
+ 'completion' : 'complete-tag-mapping',
+ 'data-handler' : 'convert-tag-to-parts',
+ 'namespace-key' : 'namespace',
+ 'name-key' : 'name',
+ 'value-key' : 'value',
+ 'syntax-help' : 'Enter tag: [namespace].name=value',
+ }
+ )
+}
+
+TAG_MATCH_COMMAND_DESCRIPTION = {
+ 'name' : 'match',
+ 'mode' : 'config-tag',
+ 'command-type' : 'config-object',
+ 'parent-field' : 'tag',
+ 'obj-type' : 'tag-mapping',
+ 'short-help' : 'Set the match rule for this tag',
+ 'doc' : 'tag|match',
+ 'doc-example' : 'tag|match-example',
+ 'args' : (
+ {
+ 'field' : 'mac',
+ 'tag' : 'mac',
+ 'type' : 'host',
+ 'completion' : [ 'complete-alias-choice',
+ ],
+ 'other' : 'host',
+ 'data-handler' : 'alias-to-value',
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'short-help' : 'Match on MAC address',
+ },
+ {
+ 'field' : 'vlan',
+ 'tag' : 'vlan',
+ 'type' : 'integer',
+ 'range' : (0,4095),
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'short-help' : 'Match on VLAN tag',
+ },
+ {
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'args' : (
+ {
+ 'field' : 'dpid',
+ 'tag' : 'switch',
+ 'type' : 'dpid',
+ 'short-help' : 'Match on switch DPID',
+ 'completion' : [
+ 'complete-object-field',
+ 'complete-alias-choice',
+ ],
+ 'other' : 'switches',
+ 'data-handler' : 'alias-to-value',
+ 'syntax-help' : 'Enter a switch dpid or alias',
+ },
+ {
+ 'field' : 'ifname',
+ 'short-help' : 'Match on switch interface name',
+ 'optional' : True,
+ 'completion' : [ 'complete-object-field',
+ 'complete-from-another',
+ ],
+ 'other' : 'port|name',
+ 'scoped' : 'dpid',
+ 'data-handler' : 'warn-missing-interface',
+ 'optional' : True,
+ 'optional-for-no' : True,
+ },
+ )
+ },
+ ),
+}
+
+
+SHOW_TAG_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show configured tags',
+ 'no-supported' : False,
+ 'command-type' : 'display-table',
+ 'obj-type' : 'tag',
+ 'doc' : 'tag|show-tag',
+ 'args' : (
+ 'tag',
+ {
+ 'field' : 'namespace',
+ 'short-help' : 'Show tags in a given namespace',
+ 'tag' : 'namespace',
+ 'optional' : True,
+ 'completion' : 'complete-object-field',
+ 'parent-field' : 'tag',
+ 'other' : 'tag',
+ 'action' : 'display-table',
+ },
+ {
+ 'field' : 'name',
+ 'tag' : 'name',
+ 'short-help' : 'Show tags with a given name',
+ 'optional' : True,
+ 'completion' : 'complete-object-field',
+ 'parent-field' : 'tag',
+ 'other' : 'tag',
+ 'action' : 'display-table',
+ },
+ {
+ 'field' : 'value',
+ 'tag' : 'value',
+ 'short-help' : 'Show tags with a given value',
+ 'optional' : True,
+ 'completion' : 'complete-object-field',
+ 'parent-field' : 'tag',
+ 'other' : 'tag',
+ 'action' : 'display-table',
+ },
+ ),
+}
+
+TAG_FORMAT = {
+ 'tag' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'namespace', 'name', 'value', 'persist' ]
+ },
+ 'fields' : {
+ 'namespace' : {
+ 'verbose-name': 'Namespace',
+ },
+ 'name' : {
+ 'verbose-name': 'Name',
+ },
+ 'value' : {
+ 'verbose-name': 'Value',
+ },
+ },
+ },
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/tag_model.py b/cli/desc/version200/tag_model.py
new file mode 100755
index 0000000..23eb435
--- /dev/null
+++ b/cli/desc/version200/tag_model.py
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_enable_cascade_delete('tag-mapping')
diff --git a/cli/desc/version200/tag_run_config.py b/cli/desc/version200/tag_run_config.py
new file mode 100755
index 0000000..5ee73e4
--- /dev/null
+++ b/cli/desc/version200/tag_run_config.py
@@ -0,0 +1,108 @@
+#
+# Copyright (c) 2012,2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# show running tag [as]
+#
+
+import run_config
+import utif
+
+#
+# --------------------------------------------------------------------------------
+
+def create_obj_type_dict(context, obj_type, field):
+ """
+ Should there be some collections of middeleware functions for use by packages?
+ """
+ entries = context.get_table_from_store(obj_type)
+ result_dict = {}
+ for entry in entries:
+ if entry[field] in result_dict:
+ result_dict[entry[field]].append(entry)
+ else:
+ result_dict[entry[field]] = [entry]
+
+ return result_dict
+
+#
+# --------------------------------------------------------------------------------
+
+
+def running_config_tag(context, config, words):
+ # waiting for new tag-mapping to arrive to rewrite
+ try:
+ tag_mapping = create_obj_type_dict(context,
+ 'tag-mapping',
+ 'tag')
+ except Exception, e:
+ tag_mapping = {}
+
+
+ t_config = []
+
+ for tag in context.get_table_from_store('tag'):
+ tag_name = '%s.%s=%s' % (tag['namespace'],
+ tag['name'],
+ utif.quote_string(tag['value']))
+ if len(words) == 1 and tag_name != words[0]:
+ continue
+ if tag.get('persist', False):
+ t_config.append('tag ' + tag_name + '\n')
+ tms = tag_mapping.get(tag['id'], [])
+ for tm in tms:
+ m = ' match'
+ if tm.get('mac', '') != '':
+ m += ' mac %s' % tm['mac']
+ if tm.get('vlan', '') != '':
+ m += ' vlan %s' % tm['vlan']
+ if tm.get('dpid', '') != '':
+ m += ' switch %s %s' % (tm['dpid'], tm.get('ifname', ''))
+ t_config.append(m + '\n')
+
+ if len(t_config):
+ config.append('!\n')
+ config += t_config
+
+
+tag_running_config_tuple = (
+ (
+ {
+ 'optional' : False,
+ 'field' : 'running-config',
+ 'type' : 'enum',
+ 'values' : 'tag',
+ 'short-help' : 'Configuration for controller object metadata',
+ 'doc' : 'running-config|show-tag',
+ },
+ {
+ 'field' : 'word',
+ 'type' : 'string',
+ 'completion' : 'complete-from-another',
+ 'other' : 'tag|id',
+ 'action' : 'legacy-cli',
+ 'optional' : True,
+ },
+ ),
+)
+
+#
+# Register with run_config module, our callback to process running configs for
+# address-space configuration items
+#
+run_config.register_running_config('tag', 4000, None,
+ running_config_tag,
+ tag_running_config_tuple)
+
diff --git a/cli/desc/version200/tech_support_run_config.py b/cli/desc/version200/tech_support_run_config.py
new file mode 100755
index 0000000..ee07e0c
--- /dev/null
+++ b/cli/desc/version200/tech_support_run_config.py
@@ -0,0 +1,57 @@
+#
+# Copyright (c) 2012,2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# show running tech_support_config [as]
+#
+
+import run_config
+import utif
+
+def running_config_tech_support(context, config, words):
+ # waiting for new tag-mapping to arrive to rewrite
+ try:
+ tech_support_entries = context.get_table_from_store('tech-support-config')
+ except Exception, e:
+ tech_support_entries = []
+ t_config = []
+ for ts_entry in tech_support_entries:
+ t_config.append("tech-support-config %s '%s'\n" % (ts_entry['cmd-type'], utif.quote_string(ts_entry['cmd'])))
+ if len(t_config) > 0:
+ config.append('!\n')
+ config += t_config
+
+
+tag_running_config_tuple = (
+ (
+ {
+ 'optional' : False,
+ 'field' : 'running-config',
+ 'type' : 'enum',
+ 'values' : 'tech-support',
+ 'short-help' : 'Configuration for tech support',
+ 'doc' : 'running-config|show-tech-support',
+ },
+ ),
+ )
+
+#
+# Register with run_config module, our callback to process running configs for
+# address-space configuration items
+#
+run_config.register_running_config('tech-support', 20000, None,
+ running_config_tech_support,
+ tag_running_config_tuple)
+
diff --git a/cli/desc/version200/techsupport.py b/cli/desc/version200/techsupport.py
new file mode 100755
index 0000000..7110f36
--- /dev/null
+++ b/cli/desc/version200/techsupport.py
@@ -0,0 +1,82 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# (c) in 2012 by Big Switch Networks - All rights reserved
+#
+# tech-support commands
+#
+
+#
+# --------------------------------------------------------------------------------
+# TECH_SUPPORT_COMMAND_DESCRIPTION
+#
+# tech-support-config type command
+# no tech-support-config type command
+#
+"""
+TECH_SUPPORT_COMMAND_DESCRIPTION = {
+ 'name' : 'tech-support-config',
+ 'mode' : 'config',
+ 'short-help' : 'Manage command output for show tech-support',
+ 'doc' : 'tech-support|tech-support-config',
+ 'doc-example' : 'tech-support|tech-support-config-example',
+ 'command-type' : 'config-object',
+ 'obj-type' : 'tech-support-config',
+ 'new-style' : True,
+ 'args' : (
+ {
+ 'field' : 'cmd-type',
+ 'type' : 'enum',
+ 'values' : ('cli', 'shell'),
+ 'syntax-help' : 'Enter command type (cli or shell)',
+ 'doc' : 'tech-support|tech-support-config-+',
+ },
+ {
+ 'field' : 'cmd',
+ 'type' : 'string',
+ 'syntax-help' : 'Enter command string'
+ },
+ )
+}
+
+TECH_SUPPORT_CONF_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'short-help' : 'Show tech-support configuration',
+ 'doc' : 'tech-support|show-tech-support-config',
+ 'doc-example' : 'tech-support|show-tech-support-config-example',
+ 'obj-type' : 'tech-support-config',
+ 'command-type' : 'display-table',
+ 'args' : (
+ 'tech-support-config',
+ {
+ 'field' : 'cmd-type',
+ 'optional' : True,
+ 'completion' : 'complete-object-field',
+ 'type' : 'enum',
+ 'values' : ('cli', 'shell'),
+ 'syntax-help' : 'Enter command type (cli or shell)',
+ 'action' : 'display-table',
+ },
+ {
+ 'field' : 'cmd',
+ 'tag' : 'cmd',
+ 'type' : 'string',
+ 'optional' : True,
+ },
+ )
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/techsupport_model.py b/cli/desc/version200/techsupport_model.py
new file mode 100755
index 0000000..d447173
--- /dev/null
+++ b/cli/desc/version200/techsupport_model.py
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_disable_submode('tech-support-config')
+
diff --git a/cli/desc/version200/tenant.py b/cli/desc/version200/tenant.py
new file mode 100755
index 0000000..857c917
--- /dev/null
+++ b/cli/desc/version200/tenant.py
@@ -0,0 +1,541 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+#
+#
+
+import command
+def tenant_origin_external(data):
+ #Return origin-name when the tenant wasn't created by the cli,
+ #return None otherwise.
+ pk = command.mi.pk('tenant')
+ if not pk in data:
+ return None;
+
+ tenant = command.sdnsh.get_table_from_store('tenant',
+ pk,
+ data[pk])
+ if len(tenant) == 0:
+ return None
+
+ local = ['cli', 'rest']
+ if 'origin' in tenant[0] and not tenant[0]['origin'] in local:
+ return tenant[0]['origin']
+ return None
+
+def tenant_warn_external_config(data):
+ """
+ From the named tenant, look up the entry, if it exists in the
+ database, validate the 'origin' is either null, or 'cli',
+ otherwise provide a warning about this particular tenant
+ (along with the originator name)
+ """
+ external_origin = tenant_origin_external(data)
+ if external_origin:
+ command.sdnsh.warning('tenant %s may not be intended for cli update, '
+ 'origin/creator "%s" ' % (data['name'], external_origin))
+
+def tenant_show_preprocess(obj_type, data,scoped=None):
+ data['tenant']='default'
+ settingscope=True
+ if 'name' in data:
+ data['tenant']= data['name']
+ del data['name']
+ else:
+ current_mode=command.sdnsh.current_mode()
+ if not current_mode.startswith('config-tenant'):
+ data['tenant']='default'
+ if current_mode.startswith('config-tenant'):
+ settingscope=False
+ for x in command.sdnsh.mode_stack:
+ if x['mode_name'] == 'config-tenant':
+ data['tenant'] = x['obj']
+ if obj_type=='vns-definition' and data['tenant']=='default' and scoped=='True' and settingscope:
+ data['scoped']=False
+ if 'vnsname' in data and data['vnsname']!='all':
+ if (obj_type!='vns-definition'):
+ data['vns']=data['tenant'] +'|'+data['vnsname']
+ if 'vnsname' in data and data['vnsname']=='all':
+ data['vns']='all'
+ del data['vnsname']
+ if 'vns' in data and data['vns']=='all':
+ if scoped=='True':
+ data['scoped']=False
+ del data['tenant']
+ if 'vrname' in data:
+ if (obj_type!='virtualrouter'):
+ data['virtual-router']=data['tenant'] +'|'+data['vrname']
+ if 'vriname' in data:
+ if (obj_type!='virtualrouter-interface'):
+ data['virtual-router-interface']=data['tenant'] +'|'+data['vrname'] +'|' + data['vriname']
+ if 'vrgwname' in data:
+ if (obj_type!='virtualrouter-gwpool'):
+ data['virtual-router-gwpool']=data['tenant'] +'|'+data['vrname'] +'|' + data['vrgwname']
+
+"""
+command.add_action('tenant-show-preprocess', tenant_show_preprocess,
+ {'kwargs': {'obj_type': '$obj-type',
+ 'data' : '$data',
+ 'scoped' : '$scoped',}})
+command.add_action('tenant-warn-external-config', tenant_warn_external_config,
+ {'kwargs': {'data' : '$data',}})
+
+def complete_tenant_preprocess(data):
+ if 'name' in data:
+ data['tenant'] =data['name']
+
+command.add_completion('complete-tenant-preprocess', complete_tenant_preprocess,
+ {'kwargs': {'data': '$data',
+ }})
+#
+# ----------------------------------------------------------------------
+# tenant submode commands
+#
+TENANT_COMMAND_DESCRIPTION = {
+ 'name' : 'tenant',
+ 'help' : 'Enter tenant definition submode',
+ 'mode' : 'config*',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'tenant',
+ 'parent-field' : None,
+ 'current-mode-obj-id' : None,
+ 'submode-name' : 'config-tenant',
+ 'feature' : 'vns',
+ 'short-help' : 'Enter tenant definition submode',
+ 'doc' : 'vns|tenant',
+ 'doc-example' : 'vns|tenant-example',
+ 'args' : (
+ {
+ 'field' : 'name',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ 'syntax-help' : 'Enter a tenant name',
+ 'doc' : 'tenant|tenant-id',
+ 'doc-example' : 'tenant|tenant-id-example',
+ 'doc-include' : [ 'type-doc' ],
+ 'action' : (
+ {
+ 'proc' : 'tenant-warn-external-config',
+ },
+ {
+ 'proc' : 'push-mode-stack',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'tenant-warn-external-config',
+ },
+ {
+ 'proc' : 'delete-objects',
+ },
+ )
+ }
+ ),
+}
+
+
+tenant_show_action = (
+ {
+ 'proc' : 'query-table',
+ },
+ {
+ 'proc' : 'join-table',
+ 'obj-type' : 'virtualrouter',
+ 'key' : 'tenant',
+ 'join-field' : 'name',
+ 'add-field' : 'virtualrouter|vrname',
+ },
+ {
+ 'proc' : 'display',
+ 'format' : 'tenant',
+ },
+)
+
+TENANT_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'all-help' : 'Show tenant details',
+ 'short-help' : 'Show defined tenants',
+ 'command-type' : 'display-table',
+ 'obj-type' : 'tenant',
+ 'action' : tenant_show_action,
+ 'args' : (
+ 'tenant',
+ )
+}
+
+TENANT_SHOW_ID_INFO_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'tenant',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'action' : tenant_show_action,
+ 'short-help' : 'Show specific tenant, identified by name',
+ 'doc' : 'vns|show-tenant',
+ 'doc-example' : 'vns|show-tenant-example',
+ 'args' : (
+ 'tenant',
+ {
+ 'choices' : (
+ {
+ 'field' : 'name',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ 'help-name' : "tenant-id",
+ },
+ {
+ 'field' : 'name',
+ 'type' : 'enum',
+ 'values' : 'all',
+ }
+ ),
+ },
+ )
+}
+
+TENANT_SHOW_ID_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'tenant',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'action' : tenant_show_action,
+ 'short-help' : 'Show specific tenant, identified by name',
+ 'doc' : 'vns|show-tenant',
+ 'args' : (
+ 'tenant',
+ {
+ 'field' : 'name',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ 'help-name' : "tenant-id",
+ },
+ {
+ 'choices' : (
+ (
+ {
+ 'field' : 'vns-field',
+ 'type' : 'enum',
+ 'values' : 'vns',
+ 'action' : ({ 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'display-table'},
+ ),
+ 'obj-type' : 'vns-definition',
+ 'short-help' : 'Show VNS belonged to this tenant',
+ 'doc' : 'vns|show-tenant-id-vns',
+ },
+ { 'optional' : True,
+ 'args' : (
+ {
+ 'field' : 'vnsname',
+ 'type' : 'identifier',
+ 'scoped' : 'tenant',
+ 'explicit' : True,
+ 'completion' : ['complete-tenant-preprocess',
+ 'complete-from-another'],
+ 'other' : 'vns-definition|vnsname',
+ 'help-name' : "vns-id",
+ },
+ { 'optional' : True,
+ 'choices' : (
+ {
+ 'field' : 'vns-interface',
+ 'type' : 'enum',
+ 'values' : 'interfaces',
+ 'obj-type' : 'vns-interface',
+ 'action' : (
+ {'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ 'short-help' : 'Show VNS associated interfaces',
+ },
+ {
+ 'field' : 'mac-address-table',
+ 'type' : 'enum',
+ 'values' : 'mac-address-table',
+ 'obj-type' : 'host-vns-interface-vns',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ 'short-help' : 'Show VNS associated mac addresses',
+ },
+ {
+ 'field' : 'interface-rules',
+ 'type' : 'enum',
+ 'values' : 'interface-rules',
+ 'action' : (
+ {
+ 'proc' : 'tenant-show-preprocess',
+ },
+ 'display-table',
+ ),
+ 'obj-type' : 'vns-interface-rule',
+ 'short-help' : 'Show VNS configured interfaces-rules',
+ 'doc' : 'vns|show-id-interface-rules',
+ },
+ {
+ 'field' : 'access-lists',
+ 'type' : 'enum',
+ 'values' : 'access-lists',
+ 'action' : (
+ {
+ 'proc' : 'tenant-show-preprocess',
+ },
+ 'display-table',
+ ),
+ 'obj-type' : 'vns-access-list',
+ 'detail' : 'acl-brief',
+ 'short-help' : 'Show VNS configured access-lists',
+ 'doc' : 'vns|show-id-access-lists',
+ },
+ {
+ 'field' : 'running-config',
+ 'type' : 'enum',
+ 'values' : 'running-config',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ 'short-help' : 'Show VNS running-config',
+ },
+ {
+ 'field' : 'legacy-cli',
+ 'type' : 'enum',
+ 'values' : 'switch',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ 'obj-type' : 'vns-switch-ports',
+ 'short-help' : 'Show VNS associated switches',
+ },
+ (
+ {
+ 'field' : 'legacy-cli',
+ 'type' : 'enum',
+ 'values' : 'flow',
+ 'obj-type' : 'vns-flow',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ 'short-help' : 'Show VNS associated flows',
+ 'doc' : 'vns|show-id-flow',
+ },
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('brief',
+ 'full-detail',
+ 'details',
+ 'summary',
+ ),
+ 'optional' : True,
+ 'short-help' : 'Detail level',
+ 'doc' : 'format|+'
+ }
+ )
+ )
+ }
+ )
+ }
+ ),
+ (
+ {
+ 'field' : 'router',
+ 'type' : 'enum',
+ 'values' : 'router',
+ 'doc' : 'vns|show-tenant-id-router',
+ },
+ { 'optional' : True,
+ 'args' : (
+ {
+ 'field' : 'vrname',
+ 'type' : 'identifier',
+ 'scoped' : 'tenant',
+ 'explicit' : True,
+ 'completion' : ['complete-tenant-preprocess',
+ 'complete-from-another'],
+ 'other' : 'virtualrouter|vrname',
+ 'help-name' : "virtualrouter-id",
+ },
+ {'optional' : True,
+ 'choices' : (
+ {
+ 'token' : 'ip-address-pool',
+ 'obj-type' : 'interface-address-pool',
+ 'doc' : 'vns|show-tenant-id-router-ippool',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'interface-address-pool'},
+ ),
+ },
+ {
+ 'field' : 'route',
+ 'type' : 'enum',
+ 'values' : 'route',
+ 'obj-type' : 'virtualrouter-routingrule',
+ 'doc' : 'vns|show-tenant-id-router-route',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table',},
+ {
+ 'proc' : 'display',
+ 'format' : 'virtualrouter-routingrule'},
+ ),
+ },
+ {
+ 'field' : 'interfaces',
+ 'type' : 'enum',
+ 'values' : 'interfaces',
+ 'obj-type' : 'virtualrouter-interface',
+ 'doc' : 'vns|show-tenant-id-router-interfaces',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'virtualrouter-interface'},
+ ),
+ },
+ {
+ 'field' : 'gateway-pools',
+ 'type' : 'enum',
+ 'values' : 'gateway-pools',
+ 'obj-type' : 'virtualrouter-gwpool',
+ 'doc' : 'vns|show-tenant-id-router-gwpools',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'virtualrouter-gwpool'},
+ ),
+ },
+ {
+ 'token' : 'gw-address-pool',
+ 'obj-type' : 'gateway-address-pool',
+ 'doc' : 'vns|show-tenant-id-router-gwippool',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'gateway-address-pool'},
+ ),
+ },
+ ),
+ },
+ ),
+ },
+ ),
+ (
+ { 'field' :'running-config',
+ 'type' : 'enum',
+ 'values' : 'running-config',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ }
+ ),
+ (
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('details', 'brief'),
+ 'doc' : 'format|+',
+ }
+ )
+ )
+ }
+ )
+}
+
+TENANT_DEF_DESCRIPTION_COMMAND_DESCRIPTION = {
+ 'name' : 'description',
+ 'mode' : 'config-tenant',
+ 'command-type' : 'config',
+ 'short-help' : 'Provide description for a tenant instance',
+ 'doc' : 'vns|tenant-description',
+ 'doc-example' : 'vns|tenant-description-example',
+ 'args' : (
+ {
+ 'field' : 'description',
+ 'type' : 'string',
+ }
+ ),
+}
+
+
+TENANT_DEF_ACTIVE_COMMAND_DESCRIPTION = {
+ 'name' : 'active',
+ 'mode' : 'config-tenant',
+ 'short-help' : 'Set tenant active',
+ 'doc' : 'vns|tenant-active',
+ 'doc-example' : 'vns|tenant-active-example',
+ 'doc-include' : [ 'default' ],
+ 'args' : (),
+ 'action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : True },
+ 'syntax-help' : 'mark the tenant as active',
+ }
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : False },
+ 'syntax-help' : 'mark the tenant as inactive',
+ }
+ )
+}
+
+TENANT_DEF_ORIGIN_COMMAND_DESCRIPTION = {
+ 'name' : 'origin',
+ 'mode' : 'config-tenant',
+ 'command-type' : 'config',
+ 'short-help' : 'Describe tenant origin',
+ 'doc' : 'tenant|origin',
+ 'doc-example' : 'tenant|origin-example',
+ 'args' : (
+ {
+ 'field' : 'origin',
+ 'type' : 'string',
+ 'action' : (
+ {
+ 'proc' : 'tenant-warn-external-config',
+ },
+ {
+ 'proc' : 'write-fields',
+ },
+ ),
+ },
+ ),
+}
+
+#
+# FORMATS
+TENANT_FORMAT = {
+ 'tenant' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'name', 'active', 'description', 'virtualrouter'],
+ 'details' : [ 'Idx', 'name', 'active', 'description', 'virtualrouter'],
+ 'brief' : [ 'Idx', 'name', 'active'],
+ },
+ 'fields' : {
+ 'name' : { 'verbose-name' : 'Tenant ID',
+ },
+ 'active' : {
+ },
+ 'description' : {
+ },
+ 'virtualrouter' : {'verbose-name' : 'Router ID',
+ }
+
+ }
+ },
+}
+"""
diff --git a/cli/desc/version200/tenant_model.py b/cli/desc/version200/tenant_model.py
new file mode 100755
index 0000000..c5f6a30
--- /dev/null
+++ b/cli/desc/version200/tenant_model.py
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+command.model_obj_type_enable_cascade_delete('tenant')
+command.model_obj_type_enable_cascade_delete('virtualrouter')
+command.model_obj_type_weak_with_cascade_delete('virtualrouter-interface')
+command.model_obj_type_weak_with_cascade_delete('virtualrouter-routingrule')
+command.model_obj_type_enable_cascade_delete('interface-address-pool')
+command.model_obj_type_weak_with_cascade_delete('virtualrouter-gwpool')
+command.model_obj_type_enable_cascade_delete('gateway-address-pool')
+
+command.model_obj_type_disable_submode('virtualrouter')
+command.model_obj_type_disable_submode('virtualrouter-interface')
+command.model_obj_type_disable_submode('virtualrouter-gwpool')
+command.model_obj_type_disable_submode('virtualrouter-routingrule')
+command.model_obj_type_disable_submode('interface-address-pool')
+command.model_obj_type_disable_submode('gateway-address-pool')
+command.model_obj_type_disable_submode('static-arp')
+command.model_obj_type_disable_submode('tenant')
+
+command.model_obj_type_disable_edit('tenant', 'active')
+command.model_obj_type_disable_edit('tenant', 'description')
+command.model_obj_type_disable_edit('tenant', 'origin')
+
diff --git a/cli/desc/version200/test.py b/cli/desc/version200/test.py
new file mode 100755
index 0000000..c4a1cbf
--- /dev/null
+++ b/cli/desc/version200/test.py
@@ -0,0 +1,332 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import fmtcnv
+
+TEST_PACKET_IN_COMMAND_DESCRIPTION = {
+ 'name' : 'test',
+ 'mode' : 'login',
+ 'no-supported' : False,
+ 'obj-type' : 'test-command', # fake obj-type, legacy-cli descriminator
+ 'short-help' : 'Perform various tests on the network',
+ 'doc' : 'test|test',
+ 'doc-example' : 'test|test-packet-in-example',
+ 'action' : 'legacy-cli',
+ 'args' : (
+ {
+ 'field' : 'test-type',
+ 'type' : 'enum',
+ 'values' : 'packet-in',
+ 'doc' : 'test|test-packet-in',
+ },
+ {
+ # src-host
+ 'field' : 'src-host',
+ 'tag' : 'src-host',
+ 'type' : 'host',
+ 'completion' : 'complete-from-another',
+ 'other' : 'host|mac',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'test|test-packet-in-mac',
+ },
+ {
+ # dst-host
+ 'field' : 'dst-host',
+ 'tag' : 'dst-host',
+ 'type' : 'host',
+ 'completion' : 'complete-from-another',
+ 'other' : 'host|mac',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'test|test-packet-in-mac',
+ },
+ {
+ # src-switch
+ 'optional' : True,
+ 'args' : (
+ {
+ 'field' : 'src-switch',
+ 'tag' : 'src-switch',
+ 'type' : 'dpid',
+ 'completion' : 'complete-from-another',
+ 'other' : 'switches|dpid', # field isn't dpid
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'test|test-packet-in-dpid',
+ },
+ {
+ 'field' : 'src-switch-port',
+ 'type' : 'string',
+ 'completion' : 'complete-from-another',
+ 'other' : 'interfaces|portName',
+ 'scoped' : 'src-switch',
+ 'data-handler' : 'convert-interface-to-port',
+ 'doc' : 'test|test-packet-in-if',
+ },
+ ),
+ },
+ {
+ 'field' : 'vlan',
+ 'tag' : 'vlan',
+ 'base-type' : 'integer',
+ 'range' : (0,4095),
+ 'optional' : True,
+ 'doc' : 'test|test-packet-in-vlan',
+ },
+ # currently ether-type isn't implemented
+ #{
+ #'optional' : True,
+ #'choices' : (
+ #{
+ #'field' : 'ether-type',
+ #'tag' : 'ether-type',
+ #'base-type' : 'hex-or-decimal-integer',
+ #'range' : (1536,65536),
+ #'data-handler' : 'hex-to-integer',
+ #},
+ #{
+ #'field' : 'ether-type',
+ #'tag' : 'ether-type',
+ #'type' : 'enum',
+ #'values' : fmtcnv.ether_type_to_number_dict,
+ #},
+ #),
+ #},
+ {
+ 'field' : 'priority',
+ 'tag' : 'priority',
+ 'base-type' : 'integer',
+ 'range' : (0,7),
+ 'optional' : True,
+ 'doc' : 'test|test-packet-in-priority',
+ },
+ {
+ 'field' : 'src-ip-address',
+ 'tag' : 'src-ip-address',
+ 'type' : 'ip-address-not-mask',
+ 'optional' : True,
+ 'doc' : 'test|test-packet-in-ip',
+ },
+ {
+ 'field' : 'dst-ip-address',
+ 'tag' : 'dst-ip-address',
+ 'type' : 'ip-address-not-mask',
+ 'optional' : True,
+ 'doc' : 'test|test-packet-in-ip',
+ },
+ {
+ 'field' : 'protocol',
+ 'tag' : 'protocol',
+ 'base-type' : 'integer',
+ 'range' : (1,255),
+ 'optional' : True,
+ 'doc' : 'test|test-packet-in-proto',
+ },
+ {
+ 'field' : 'tos',
+ 'tag' : 'tos',
+ 'base-type' : 'integer',
+ 'range' : (1,255),
+ 'optional' : True,
+ 'doc' : 'test|test-packet-in-tos',
+ },
+ {
+ 'field' : 'src-port',
+ 'tag' : 'src-port',
+ 'base-type' : 'integer',
+ 'range' : (0,65535),
+ 'optional' : True,
+ 'doc' : 'test|test-packet-in-port',
+ },
+ {
+ 'field' : 'dst-port',
+ 'tag' : 'dst-port',
+ 'base-type' : 'integer',
+ 'range' : (0,65535),
+ 'optional' : True,
+ 'doc' : 'test|test-packet-in-port',
+ },
+ ),
+}
+
+TEST_PATH_COMMAND_DESCRIPTION = {
+ 'name' : 'test',
+ 'mode' : 'login',
+ 'no-supported' : False,
+ 'obj-type' : 'test-command', # fake obj-type, legacy-cli descriminator
+ 'short-help' : 'Perform various tests on the network',
+ 'doc' : 'test|test',
+ 'doc-example' : 'test|test-path-example',
+ 'action' : (
+ # collect the entries
+ {
+ 'proc' : 'legacy-cli',
+ },
+ # join the interface names, possibly add stats?
+ {
+ 'proc' : 'join-table',
+ 'obj-type' : 'interfaces',
+ 'key' : 'switch|portNumber',
+ 'join-field' : 'switch|port',
+ 'add-field' : 'portName|portName',
+ },
+ # add basic interface's stats
+ {
+ 'proc' : 'join-rest',
+ 'url' : 'realtimestats/port/%(switch)s/',
+ 'rest-type' : 'dict-of-list-of-switch|portNumber',
+ 'key' : 'switch|portNumber',
+ 'join-field' : 'switch|port'
+ },
+ # display the result
+ {
+ 'proc' : 'display',
+ 'format' : 'test-path',
+ }
+ ),
+ 'args' : (
+ {
+ 'field' : 'test-type',
+ 'type' : 'enum',
+ 'values' : 'path',
+ 'doc' : 'test|test-path',
+ },
+ {
+ 'choices' : (
+ # source device (need address space, vlan)
+ {
+ 'field' : 'src-host',
+ 'tag' : 'src-host',
+ 'type' : 'host',
+ 'completion' : 'complete-from-another',
+ 'other' : 'host|mac',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'test|test-path-host',
+ },
+ # source ip
+ {
+ 'field' : 'src-ip',
+ 'tag' : 'src-ip',
+ 'type' : 'ip-address',
+ 'completion' : 'complete-from-another',
+ 'other' : 'host-network-address|ip-address',
+ 'doc' : 'test|test-path-ip',
+ },
+ # source attachment point
+ (
+ {
+ 'field' : 'src-switch',
+ 'tag' : 'src-switch',
+ 'type' : 'dpid',
+ 'completion' : 'complete-from-another',
+ 'other' : 'switches|dpid', # field isn't dpid
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'test|test-path-switch',
+ },
+ {
+ 'field' : 'src-switch-port',
+ 'type' : 'string',
+ 'completion' : 'complete-from-another',
+ 'other' : 'interfaces|portName',
+ 'scoped' : 'src-switch',
+ 'data-handler' : 'convert-interface-to-port',
+ 'doc' : 'test|test-path-if',
+ },
+ ),
+ )
+ },
+ {
+ 'choices' : (
+ # dest mac (need address space, vlan)
+ {
+ 'field' : 'dst-host',
+ 'tag' : 'dst-host',
+ 'type' : 'host',
+ 'completion' : 'complete-from-another',
+ 'other' : 'host|mac',
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'test|test-path-host',
+ },
+ # dest ip (need address space, vlan)
+ {
+ 'field' : 'dst-ip',
+ 'tag' : 'dst-ip',
+ 'type' : 'ip-address',
+ 'completion' : 'complete-from-another',
+ 'other' : 'host-network-address|ip-address',
+ 'doc' : 'test|test-path-ip',
+ },
+ # dest attachment point
+ (
+ {
+ 'field' : 'dst-switch',
+ 'tag' : 'dst-switch',
+ 'type' : 'dpid',
+ 'completion' : 'complete-from-another',
+ 'other' : 'switches|dpid', # field isn't dpid
+ 'data-handler' : 'alias-to-value',
+ 'doc' : 'test|test-path-switch',
+ },
+ {
+ 'field' : 'dst-switch-port',
+ 'type' : 'string',
+ 'completion' : 'complete-from-another',
+ 'other' : 'interfaces|portName',
+ 'scoped' : 'dst-switch',
+ 'data-handler' : 'convert-interface-to-port',
+ 'doc' : 'test|test-path-if',
+ },
+ ),
+ )
+ },
+ ),
+}
+
+TEST_PATH_FORMAT = {
+ 'test-path' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'switch', 'portName',
+ 'receiveBytes', 'receivePackets', 'receiveErrors',
+ 'transmitBytes', 'transmitPackets', 'transmitErrors',
+ ]
+ },
+ 'fields' : {
+ 'switch' : {
+ 'verbose-name' : 'Switch',
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'portName' : {
+ 'verbose-name' : 'IF',
+ },
+ 'receiveBytes' : {
+ 'verbose-name' : 'Rx Bytes',
+ },
+ 'receivePackets' : {
+ 'verbose-name' : 'Rx Pkts',
+ },
+ 'receiveErrors' : {
+ 'verbose-name' : 'Rx Errs',
+ },
+ 'transmitBytes' : {
+ 'verbose-name' : 'Tx Bytes',
+ },
+ 'transmitPackets' : {
+ 'verbose-name' : 'Tx Pkts',
+ },
+ 'transmitErrors' : {
+ 'verbose-name' : 'Tx Errs',
+ },
+ },
+ },
+}
diff --git a/cli/desc/version200/topology.py b/cli/desc/version200/topology.py
new file mode 100755
index 0000000..4bb51a4
--- /dev/null
+++ b/cli/desc/version200/topology.py
@@ -0,0 +1,59 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+"""
+
+TOPOLOGY_COMMAND_DESCRIPTION = {
+ 'name' : 'topology',
+ 'mode' : 'config',
+ 'short-help' : 'Enable features for controller',
+ 'doc' : 'topology|topology',
+ 'doc-example' : 'topology|topology-example',
+ 'command-type' : 'config',
+ 'obj-type' : 'topology-config',
+ 'args': {
+ 'choices': (
+ {
+ 'token' : 'autoportfast',
+ 'short-help' : 'Enable the auto PortFast feature',
+ 'doc' : 'topology|topology-autoportfast',
+ 'action' : (
+ {
+ 'proc' : 'write-object',
+ 'data' : {
+ # The primary key ('id') must be present to
+ # read the old row value, and update items,
+ # otherwise a 'new' row is written with default
+ # values
+
+ 'id' : 'topology',
+ 'autoportfast' : True,
+ },
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'write-object',
+ 'data' : {
+ 'id' : 'topology',
+ 'autoportfast' : False ,
+ },
+ },
+ )
+ },
+ )
+ }
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/topology_model.py b/cli/desc/version200/topology_model.py
new file mode 100755
index 0000000..f06f0c8
--- /dev/null
+++ b/cli/desc/version200/topology_model.py
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_disable_submode('topology-config')
diff --git a/cli/desc/version200/topology_run_config.py b/cli/desc/version200/topology_run_config.py
new file mode 100755
index 0000000..438ad6e
--- /dev/null
+++ b/cli/desc/version200/topology_run_config.py
@@ -0,0 +1,58 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# topology config.
+#
+
+import run_config
+
+#
+# --------------------------------------------------------------------------------
+
+def running_config_topology(context, config, words):
+ t_obj_type = 'topology-config'
+
+ topology_config = context.get_table_from_store(t_obj_type)
+ if len(topology_config) > 1:
+ print 'running_config_topology: more than one topology record'
+ if len(topology_config) == 0:
+ return
+
+ topology_config = topology_config[0]
+
+ if run_config.not_default_value(t_obj_type, 'autoportfast',
+ topology_config.get('autoportfast')):
+ config.append('\nno topology autoportfast\n')
+
+#
+# --------------------------------------------------------------------------------
+
+topology_running_config_tuple = (
+ (
+ {
+ 'optional' : False,
+ 'field' : 'running-config',
+ 'type' : 'enum',
+ 'values' : 'topology',
+ 'short-help' : 'Topology Configuration',
+ 'doc' : 'running-config|show-topology',
+ },
+ ),
+)
+
+run_config.register_running_config('topology', 2100, None,
+ running_config_topology,
+ topology_running_config_tuple)
diff --git a/cli/desc/version200/tunnel.py b/cli/desc/version200/tunnel.py
new file mode 100644
index 0000000..d79b012
--- /dev/null
+++ b/cli/desc/version200/tunnel.py
@@ -0,0 +1,196 @@
+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' ],
+ 'completion' : 'tunnel-id-completion',
+ '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_url1 = "http://127.0.0.1:8000/rest/v1/switches"
+ result1 = command.sdnsh.store.rest_simple_request(query_url1)
+ entries1 = json.loads(result1)
+ node_dpid = None
+ for entry in entries1:
+ if (int (entry['stringAttributes']['nodeSid']) == int(data['node-label'])):
+ node_dpid = entry['dpid']
+ if (node_dpid != None):
+ query_url2 = "http://127.0.0.1:8000/rest/v1/router/"+node_dpid+"/adjacency"
+ result2 = command.sdnsh.store.rest_simple_request(query_url2)
+ entries2 = json.loads(result2)
+ for entry in entries2:
+ if str(entry.get("adjacencySid")).startswith(prefix):
+ completions[str(entry.get("adjacencySid"))+' '] = entry.get("adjacencySid")
+ 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',
+ 'command-type' : 'display-table',
+ 'all-help' : 'Show switch information',
+ 'short-help' : 'Show switch summary',
+ #'obj-type' : 'switches',
+ 'doc' : 'switch|show',
+ 'doc-example' : 'switch|show-example',
+ 'args' : (
+ {
+ 'token' : 'tunnel',
+ 'field' : 'showtunnel',
+ 'sort' : ['tunnelId',],
+ 'action' : 'display-rest',
+ 'doc' : 'switch|show',
+ 'url' : [
+ 'showtunnel',
+ ],
+ 'format' : 'show_tunnel',
+ },
+ {
+ 'optional' : True,
+ 'choices' : (
+ {
+ 'field' : 'showtunnel',
+ 'type' : 'enum',
+ 'values' : ('details',),
+ 'optional' : True,
+ 'format' : 'show_tunnel',
+ 'data' : { 'detail' : 'details' },
+ },
+ ),
+ }
+ )
+}
+
+
+def tunnel_id_completion(prefix, completions):
+ query_url = "http://127.0.0.1:8000/rest/v1/showtunnel"
+ result = command.sdnsh.store.rest_simple_request(query_url)
+ entries = json.loads(result)
+ for entry in entries:
+ if entry['tunnelId'].startswith(prefix):
+ completions[entry['tunnelId']+' '] = entry['tunnelId']
+ return
+
+command.add_completion('tunnel-id-completion', tunnel_id_completion,
+ {'kwargs': { 'prefix' : '$text',
+ 'completions' : '$completions',
+ }})
\ No newline at end of file
diff --git a/cli/desc/version200/tunnelOld.py b/cli/desc/version200/tunnelOld.py
new file mode 100755
index 0000000..0a3f5ba
--- /dev/null
+++ b/cli/desc/version200/tunnelOld.py
@@ -0,0 +1,108 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import fmtcnv
+"""
+TUNNEL_COMMAND_DESCRIPTION = {
+ 'name' : 'tunnel-link',
+ 'feature' : 'vns',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'doc' : 'tunnel-link|verify-example',
+ 'obj-type' : None,
+ 'args' : {
+ 'choices': (
+ (
+ {
+ 'token' : 'verify',
+ 'short-help' : 'Verify status of tunnel between two switches',
+ 'action' : 'display-rest',
+ 'format' : 'tunnel-event',
+ 'url' : [
+ 'realtimestatus/network/tunnelverify/%(src-dpid)s/%(dst-dpid)s/',
+ ],
+ },
+ {
+ 'field' : 'src-dpid',
+ 'type' : 'dpid',
+ 'completion' : 'complete-from-another',
+ 'other' : 'switches|dpid',
+ 'data-handler' : 'alias-to-value',
+ 'help-name' : 'switch dpid or alias',
+ },
+ {
+ 'field' : 'dst-dpid',
+ 'type' : 'dpid',
+ 'completion' : 'complete-from-another',
+ 'other' : 'switches|dpid',
+ 'data-handler' : 'alias-to-value',
+ 'help-name' : 'switch dpid or alias',
+ }
+ ),
+ )
+ }
+}
+
+TUNNEL_LINK_FAILURES_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'feature' : 'vns',
+ 'short-help' : 'Show tunnel link failures',
+ 'command-type' : 'display-table',
+ 'url' : 'realtimestatus/network/tunnelstatus/all/all',
+ 'obj-type' : None,
+ 'format' : 'tunnel-event',
+ 'action' : 'display-rest',
+ 'args' : (
+ 'tunnel-link-failures',
+ ),
+}
+
+TUNNEL_EVENT_FORMAT = {
+ 'tunnel-event' : {
+ 'source' : 'controller',
+ 'url' : 'tunnel-event',
+ 'field-orderings': {
+ 'default' : [ 'Idx', 'src-dpid', 'dst-dpid', 'status', 'last-verified' ],
+ },
+ 'fields' : {
+ 'Idx' : {
+ 'verbose-name': '#',
+ 'edit' : False,
+ 'type' : 'CharField',
+ 'primary-key': True,
+ },
+ 'src-dpid':{
+ 'verbose-name': 'Src DPID',
+ 'json_serialize_string': True,
+ 'type': 'CharField',
+ },
+ 'dst-dpid': {'json_serialize_string': True,
+ 'verbose-name': 'Dst DPID',
+ 'type': 'CharField',
+ },
+ 'status': {
+ 'json_serialize_string': True,
+ 'type': 'CharField',
+ },
+ 'last-verified': {
+ 'verbose-name': 'Last Verified',
+ 'formatter' : fmtcnv.print_time_since_utc,
+ }
+ }
+ },
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/vcenter.py b/cli/desc/version200/vcenter.py
new file mode 100755
index 0000000..f71eafd
--- /dev/null
+++ b/cli/desc/version200/vcenter.py
@@ -0,0 +1,549 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+# (c) in 2012 by Big Switch Networks - All rights reserved
+#
+# vCenter commands
+#
+"""
+import os
+VCENTER_COMMAND_DESCRIPTION = {
+ 'name' : 'vcenter',
+ #'no-help' : 'Remove vcenter configuration',
+ 'mode' : 'config*',
+ 'feature' : 'experimental',
+ 'command-type' : 'config-submode',
+ 'short-help' : 'Enter vcenter submode, configure vcenter details',
+ 'doc' : 'vcenter|vcenter',
+ 'doc-example' : 'vcenter|vcenter-example',
+ 'obj-type' : 'vcenter',
+ 'parent-field' : None,
+ 'current-mode-obj-id' : None,
+ 'submode-name' : 'config-vcenter',
+ # 'parent-id' : 'vcenter-name',
+ 'args' : (
+ { 'field' : 'vcenter-name',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ 'syntax-help' : 'Enter a vcenter name',
+ }
+ ),
+ 'action': 'push-mode-stack',
+ 'no-action': (
+ {
+ 'proc' : 'confirm',
+ 'prompt' : "Deleting a vcenter will cause vcenter" \
+ " DVS's to also be deleted, continue (y or yes)? "
+ },
+ {
+ 'proc' : 'delete-objects',
+ }
+ )
+}
+
+
+SHOW_VCENTER_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'feature' : 'experimental',
+ 'short-help' : 'Show vcenter configurations',
+ 'doc' : 'vcenter|show',
+ 'doc-example' : 'vcenter|show-example',
+ 'obj-type' : 'vcenter',
+ 'command-type' : 'display-table',
+
+ 'args' : (
+ 'vcenter',
+ )
+}
+
+
+SHOW_VCENTER_NAME_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'feature' : 'experimental',
+ 'short-help' : 'Show vcenter description by name',
+ 'doc' : 'vcenter|show-name',
+ 'doc-example' : 'vcenter|show-name-example',
+ 'obj-type' : 'vcenter',
+ 'command-type' : 'display-table',
+ 'args' : (
+ 'vcenter',
+ {
+ 'choices' : (
+ {
+ 'field' : 'vcenter-name',
+ 'type' : 'identifier',
+ },
+ {
+ 'field' : 'vcenter-name',
+ 'type' : 'enum',
+ 'values' : 'all',
+ 'completion' : 'complete-object-field',
+ },
+ )
+ },
+ {
+ 'optional' : True,
+ 'choices' : (
+ {
+ 'field' : 'dvs',
+ 'type' : 'enum',
+ 'values' : 'dvs',
+ 'obj-type' : 'dvs',
+ 'action' : 'display-table',
+ 'short-help' : 'Select dvs for display',
+ 'doc' : 'vcenter|show-name-dvs',
+ },
+ {
+ 'field' : 'dvs-port-group',
+ 'type' : 'enum',
+ 'values' : 'dvs-port-group',
+ 'obj-type' : 'dvs-port-group',
+ 'action' : 'display-table',
+ 'short-help' : 'Select dvs-port-group for display',
+ 'doc' : 'vcenter|show-name-dvs-port-group',
+ },
+ {
+ 'field' : 'status',
+ 'type' : 'enum',
+ 'values' : 'status',
+ 'action' : 'display-rest',
+ 'url' : 'vcenter/status/%(vcenter-name)s/',
+ 'format' : 'vcenter-status',
+ 'detail' : 'details',
+ 'short-help' : 'Display vcenter active state',
+ 'doc' : 'vcenter|show-vcenter-status',
+ },
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : 'details',
+ }
+ )
+ }
+ )
+}
+
+
+SHOW_VCENTER_NAME_STATUS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'feature' : 'experimental',
+ 'short-help' : 'Show vcenter operational status by name',
+ 'doc' : 'vcenter|show-vcenter-dvs-status',
+ 'doc-example' : 'vcenter|show-vcenter-dvs-status-example',
+ 'obj-type' : 'vcenter',
+ 'command-type' : 'display-rest',
+ 'args' : (
+ 'vcenter',
+ {
+ 'field' : 'vcenter-name',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ },
+ {
+ 'field' : 'dvs-name',
+ 'tag' : 'dvs',
+ 'obj-type' : 'dvs',
+ 'completion' : 'complete-object-field',
+ },
+ {
+ 'field' : 'status',
+ 'type' : 'enum',
+ 'values' : 'status',
+ 'url' : 'vcenter/status/%(vcenter-name)s/%(dvs-name)s',
+ 'format' : 'vcenter-dvs-status',
+ 'detail' : 'details',
+ 'action' : 'display-rest',
+
+ },
+ )
+}
+
+VCENTER_IP_ADDRESS_COMMAND_DESCRIPTION = {
+ 'name' : 'ip',
+ 'mode' : 'config-vcenter',
+ 'short-help' : 'Associate ip address for vcenter connection',
+ 'doc' : 'vcenter|ip',
+ 'doc-example' : 'vcenter|ip-example',
+ 'command-type' : 'config',
+ 'no-supported' : True,
+ 'fields' : [ 'ip' ], # for field reset
+ 'args' : {
+ 'choices' : (
+ (
+ 'address',
+ {
+ 'field' : 'ip',
+ 'type' : 'ip-address-not-mask',
+ 'optional-for-no' : True,
+ 'syntax-help' : 'Enter an IP Address',
+ },
+ ),
+ )
+ }
+}
+
+VCENTER_PORT_COMMAND_DESCRIPTION = {
+ 'name' : 'port',
+ 'short-help' : 'Associate http port for vcenter connection',
+ 'doc' : 'vcenter|port',
+ 'doc-example' : 'vcenter|port-example',
+ 'command-type' : 'config',
+ 'mode' : 'config-vcenter',
+ 'no-supported' : False,
+ 'args' : (
+ {
+ 'field' : 'port',
+ 'type' : 'integer',
+ 'syntax-help' : 'Enter an http port number',
+ 'optional-for-no' : True,
+ }
+ )
+}
+
+VCENTER_DVS_COMMAND_DESCRIPTION = {
+ 'name' : 'dvs',
+ 'mode' : 'config-vcenter*',
+ 'command-type' : 'config-submode',
+ 'parent-field' : 'vcenter-name',
+ 'obj-type' : 'dvs',
+ 'no-supported' : True,
+ 'submode-name' : 'config-vcenter-dvs',
+ 'short-help' : 'Enter vcenter-dvs submode, describe port groups',
+ 'doc' : 'vcenter|dvs',
+ 'doc-example' : 'vcenter|dvs-example',
+ 'args' : (
+ {
+ 'field' : 'datacenter',
+ 'tag' : 'datacenter-name',
+ 'type' : 'string',
+ 'completion' : 'complete-object-field',
+ 'syntax-help' : 'Enter the vcenter datacenter name',
+ },
+ {
+ 'field' : 'dvs-name',
+ 'tag' : 'dvs-name',
+ 'type' : 'string',
+ 'completion' : 'complete-object-field',
+ 'syntax-help' : 'Enter the vcenter dvs name',
+ },
+ {
+ 'field' : 'switch-class',
+ 'tag' : 'switch-class',
+ 'type' : 'string',
+ 'optional' : True,
+ 'optional-for-no': True,
+ 'completion' : 'complete-object-field',
+ 'syntax-help' : 'Enter vmware',
+ },
+ ),
+}
+
+SHOW_DVS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'feature' : 'experimental',
+ 'mode' : 'login',
+ 'short-help' : 'Show vcenter dvs details',
+ 'doc' : 'vcenter|show-dvs',
+ 'doc-example' : 'vcenter|show-dvs-example',
+ 'obj-type' : 'dvs',
+ 'command-type' : 'display-table',
+ 'args' : (
+ 'dvs',
+ {
+ 'field' : 'vcenter',
+ 'tag' : 'vcenter',
+ 'optional' : True,
+ 'type' : 'string',
+ },
+ {
+ 'field' : 'datacenter',
+ 'tag' : 'datacenter',
+ 'optional' : True,
+ 'type' : 'string',
+ },
+ {
+ 'field' : 'dvs',
+ 'tag' : 'dvs',
+ 'optional' : True,
+ 'type' : 'string',
+ },
+ )
+}
+
+VCENTER_PORTGROUP_COMMAND_DESCRIPTION = {
+ 'name' : 'portgroup',
+ 'mode' : 'config-vcenter-dvs',
+ 'short-help' : 'Describe dvs portgroup',
+ 'doc' : 'vcenter|dvs-portgroup',
+ 'doc-example' : 'vcenter|dvs-portgroup-example',
+ 'command-type' : 'config-object',
+ 'parent-field' : 'dvs-name',
+ 'obj-type' : 'dvs-port-group',
+ 'no-supported' : True,
+ 'args' : (
+ {
+ 'field' : 'portgroup-name',
+ 'syntax-help' : 'Enter the vcenter portgroup name for the associated dvs',
+ 'optional-for-no' : True
+ }
+ )
+}
+
+
+SHOW_DVS_PORT_GROUP_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'feature' : 'experimental',
+ 'mode' : 'login',
+ 'short-help' : 'Show vcenter dvs port-group details',
+ 'doc' : 'vcenter|show-dvs-port-group',
+ 'doc-example' : 'vcenter|show-dvs-port-group-example',
+ 'obj-type' : 'dvs-port-group',
+ 'command-type' : 'display-table',
+ 'no-supported' : True,
+ 'args' : (
+ 'dvs-port-group',
+ {
+ 'field' : 'vcenter',
+ 'tag' : 'vcenter',
+ 'optional' : True,
+ 'type' : 'string',
+ },
+ {
+ 'field' : 'datacenter',
+ 'tag' : 'datacenter',
+ 'optional' : True,
+ 'type' : 'string',
+ },
+ {
+ 'field' : 'dvs',
+ 'tag' : 'dvs',
+ 'optional' : True,
+ 'type' : 'string',
+ },
+ {
+ 'field' : 'portgroup',
+ 'tag' : 'portgroup',
+ 'optional' : True,
+ 'type' : 'string',
+ },
+ )
+}
+
+VCENTER_USERNAME_COMMAND_DESCRIPTION = {
+ 'name' : 'username',
+ 'mode' : 'config-vcenter',
+ 'short-help' : 'Configure vcenter username for login',
+ 'doc' : 'vcenter|username',
+ 'doc-example' : 'vcenter|username-example',
+ 'command-type' : 'config',
+ 'fields' : [ 'username' ], # for field reset
+ 'no-supported' : True,
+ 'args' : (
+ {
+ 'field' : 'username',
+ 'type' : 'string',
+ 'syntax-help' : 'Enter the vcenter login username',
+ 'optional-for-no' : True,
+ }
+ )
+}
+
+VCENTER_PASSWORD_COMMAND_DESCRIPTION = {
+ 'name' : 'password',
+ 'mode' : 'config-vcenter',
+ 'command-type' : 'config',
+ 'short-help' : 'Configure vcenter password for login',
+ 'doc' : 'vcenter|password',
+ 'doc-example' : 'vcenter|password-example',
+ 'fields' : [ 'password' ], # for field reset
+ 'no-supported' : True,
+ 'args' : (
+ {
+ 'field' : 'password',
+ 'type' : 'string',
+ 'syntax-help' : 'Enter the vcenter login password',
+ 'optional-for-no' : True,
+ }
+ )
+}
+
+VCENTER_CONNECT_COMMAND_DESCRIPTION = {
+ 'name' : 'connect',
+ 'mode' : 'config-vcenter',
+ 'short-help' : 'Enable vcenter connect',
+ 'doc' : 'vcenter|connect',
+ 'doc-example' : 'vcenter|connect-example',
+ 'command-type' : 'config',
+ 'syntax-help' : 'Enter to attempt a vcenter connect',
+ # 'data' : {'connect' : True },
+ 'args' : (),
+ 'action': (
+ {
+ 'proc' : 'write-fields',
+ 'data' : {'connect' : True}
+ },
+ ),
+ 'no-action': (
+ {
+ 'proc' : 'reset-fields',
+ 'fields' : [ 'connect' ]
+ }
+ )
+}
+
+
+#
+# FORMATS
+#
+
+import fmtcnv
+
+
+VCENTER_FORMAT = {
+ 'vcenter' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'Idx',
+ 'vcenter-name',
+ 'ip', 'port',
+ 'username', 'password',
+ 'connect',
+ ]
+ },
+ 'fields' : {
+ 'ip' : {
+ },
+ 'port' : {
+ },
+ 'username' : {
+ },
+ 'password' : {
+ },
+ 'connect' : {
+ },
+ }
+ },
+}
+
+
+VCENTER_STATUS_FORMAT = {
+ 'vcenter-status' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'Idx',
+ 'vcenter',
+ 'Status',
+ 'DvsList',
+ ],
+ 'details' : [
+ 'vcenter',
+ 'Status',
+ 'VCenterError',
+ 'DvsList',
+ ]
+ },
+
+ 'fields' : {
+ 'vcenter' : { 'verbose-name' : 'VCenter'
+ },
+ 'Status' : { 'verbose-name' : 'Status'
+ },
+ 'VCenterError' : { 'verbose-name' : 'VCenter error'
+ },
+ 'DvsList' : { 'verbose-name' : 'Dvses',
+ }
+ },
+ },
+}
+
+
+VCENTER_DVS_STATUS_FORMAT = {
+ 'vcenter-dvs-status' : {
+ 'field-orderings' : {
+ 'default' : [
+ 'Idx',
+ 'vcenter',
+ 'dataCenter',
+ 'dvs',
+ 'portgroups',
+ ],
+ },
+
+ 'fields' : {
+ 'vcenter' : { 'verbose-name' : 'VCenter'
+ },
+ 'dvs' : { 'verbose-name' : 'Dvs Name',
+ },
+ 'dataCenter' : { 'verbose-name' : 'Data Center',
+ },
+ 'portgroups' : { 'verbose-name' : 'Port Groups Active',
+ },
+ }
+ },
+}
+
+VCENTER_DVS_FORMAT = {
+ 'dvs' : {
+ 'show-this' : [
+ [ 'dvs', 'default' ],
+ [ 'dvs-port-group', 'scoped' ]
+ ],
+
+ 'field-orderings' : {
+ 'default' : [ 'vcenter-name',
+ 'datacenter',
+ 'dvs-name',
+ 'switch-class',
+ ]
+ },
+ 'fields' : {
+ 'vcenter-name' : {
+ },
+ 'datacenter' : {
+ },
+ 'dvs-name' : {
+ },
+ 'switch-class' : {
+ },
+ }
+ },
+}
+
+
+VCENTER_DVS_PORT_GROUP_FORMAT = {
+ 'dvs-port-group' : {
+ 'field-orderings' : {
+ 'default' : [ 'vcenter-name',
+ 'datacenter',
+ 'dvs-name',
+ 'portgroup-name'
+ ],
+ 'scoped' : [ 'portgroup-name'
+ ],
+ },
+ 'fields' : {
+ 'dvs-name' : {
+ },
+ 'portgroup-name' : {
+ },
+ },
+
+ },
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/virtualrouter.py b/cli/desc/version200/virtualrouter.py
new file mode 100755
index 0000000..19722db
--- /dev/null
+++ b/cli/desc/version200/virtualrouter.py
@@ -0,0 +1,1117 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+#
+#
+
+import command
+import fmtcnv
+import error
+
+def virtualrouter_origin_external(data):
+ """
+ Return origin-name when the virtualrouter wasn't created by the cli,
+ return None otherwise.
+ """
+ pk = command.mi.pk('virtualrouter')
+ if not pk in data:
+ return None;
+
+ virtualrouter = command.sdnsh.get_table_from_store('virtualrouter',
+ pk,
+ data[pk])
+ if len(virtualrouter) == 0:
+ return None
+
+ local = ['cli', 'rest']
+ if 'origin' in virtualrouter[0] and not virtualrouter[0]['origin'] in local:
+ return virtualrouter[0]['origin']
+ return None
+
+def virtualrouter_warn_external_config(data):
+ """
+ From the named virtualrouter, look up the entry, if it exists in the
+ database, validate the 'origin' is either null, or 'cli',
+ otherwise provide a warning about this particular virtualrouter
+ (along with the originator name)
+ """
+ external_origin = virtualrouter_origin_external(data)
+ if external_origin:
+ command.sdnsh.warning('router %s may not be intended for cli update, '
+ 'origin/creator "%s" ' % (data['id'], external_origin))
+def verify_router_intf_ip(data):
+ if data['ip-address']=='0.0.0.0':
+ raise error.ArgumentValidationError("0.0.0.0 is not a valid router interface ip address")
+ if data['subnet-mask']=='255.255.255.255':
+ raise error.ArgumentValidationError("0.0.0.0 is not a valid router interface ip subnet mask")
+
+def verify_router_gw_ip(data):
+ if data['ip-address']=='0.0.0.0':
+ raise error.ArgumentValidationError("0.0.0.0 is not a valid router interface ip address")
+
+def virtualrouter_preprocess(data):
+ current_mode=command.sdnsh.current_mode()
+ if current_mode.startswith('config-tenant'):
+ for x in command.sdnsh.mode_stack:
+ if x['mode_name'] == 'config-tenant':
+ tenant = x['obj']
+ if current_mode.startswith('config-tenant-router'):
+ for x in command.sdnsh.mode_stack:
+ if x['mode_name'] == 'config-tenant-router':
+ data['virtual-router'] = x['obj']
+ if 'outgoing-intf' in data:
+ current_obj=command.sdnsh.get_current_mode_obj()
+ if current_mode.startswith('config-tenant-router-intf') or current_mode.startswith('config-tenant-router-gw'):
+ for x in command.sdnsh.mode_stack:
+ if x['mode_name'] == 'config-tenant-router':
+ current_obj = x['obj']
+ data['outgoing-intf']=current_obj+'|'+data['outgoing-intf']
+ if 'gateway-pool' in data:
+ current_obj=command.sdnsh.get_current_mode_obj()
+ if current_mode.startswith('config-tenant-router-intf') or current_mode.startswith('config-tenant-router-gw'):
+ for x in command.sdnsh.mode_stack:
+ if x['mode_name'] == 'config-tenant-router':
+ current_obj = x['obj']
+ data['gateway-pool']=current_obj+'|'+data['gateway-pool']
+ if 'src-vns' in data:
+ if not'src-tenant' in data:
+ data['src-tenant']=tenant
+ data['src-vns']= data['src-tenant'] + '|' + data ['src-vns']
+ if 'dst-vns' in data:
+ if not 'dst-tenant' in data:
+ data['dst-tenant']=tenant
+ data['dst-vns']= data['dst-tenant'] + '|' + data ['dst-vns']
+ if 'vns-connected' in data:
+ data['vns-connected']=tenant+'|'+data['vns-connected']
+ if 'router-connected-tenant' in data:
+ if tenant !='system' and data['router-connected-tenant']!='system':
+ command.sdnsh.warning('Tenant router interface can only connected to system tenant router\n')
+ data['router-connected']= data['router-connected-tenant'] +'|'+ data['router-connected']
+ del data['router-connected-tenant']
+
+command.add_action('virtualrouter-warn-external-config', virtualrouter_warn_external_config,
+ {'kwargs': {'data' : '$data',}})
+command.add_action('virtualrouter-preprocess', virtualrouter_preprocess,
+ {'kwargs': {'data' : '$data',}})
+command.add_action('verify-router-intf-ip', verify_router_intf_ip,
+ {'kwargs': {'data' : '$data',}})
+command.add_action('verify-router-gw-ip', verify_router_gw_ip,
+ {'kwargs': {'data' : '$data',}})
+
+
+def complete_virtualrouter_preprocess(data):
+ obj_id = command.sdnsh.get_current_mode_obj()
+ if '|' in obj_id:
+ parts=obj_id.split('|')
+ data['tenant']=parts[0]
+ data['virtual-router']=parts[0]+'|' + parts[1]
+ else:
+ data['tenant']=obj_id
+ if 'vrname' in data:
+ data['virtual-router']=obj_id+'|'+data['vrname']
+ if 'router-connected-tenant' in data:
+ data['tenant'] = data['router-connected-tenant']
+ if 'src-tenant' in data:
+ data['tenant']=data['src-tenant']
+ if 'dst-tenant' in data:
+ data['tenant']=data['dst-tenant']
+
+def complete_virtualrouter_postprocess(data,completions):
+ obj_id = command.sdnsh.get_current_mode_obj()
+ parts=obj_id.split('|')
+ tenant=parts[0]
+ if tenant !='system': #non-system virtual router can only connected to system virtual router
+ completions.clear()
+ completions['system ']='Tenant Selection'
+ else: # system virtual router can't connect to itself
+ if 'system ' in completions:
+ del completions['system ']
+
+command.add_completion('complete-virtualrouter-postprocess', complete_virtualrouter_postprocess,
+ {'kwargs': {'data': '$data',
+ 'completions' : '$completions',}})
+command.add_completion('complete-virtualrouter-preprocess', complete_virtualrouter_preprocess,
+ {'kwargs': {'data': '$data',
+ }})
+
+def virtualrouter_confirm_external_delete(data):
+ """
+ From the named virtualrouter, look up the entry, if it exists in the
+ database, validate the 'origin' is either null, or 'cli',
+ otherwise provide a warning about this particular virtualrouter
+ (along with the originator name)
+ """
+ external_origin = virtualrouter_origin_external(data)
+ if external_origin:
+ confirm = command.action_registry['confirm'][0] # XXX accessor?
+ confirm('virtual router %s may not be intended for cli delete, '
+ 'origin/creator "%s"\nEnter y or yes to continue delete: '
+ % (data['id'], external_origin))
+
+command.add_action('virtualrouter-confirm-external-delete', virtualrouter_confirm_external_delete,
+ {'kwargs': {'data' : '$data',}})
+
+"""
+#
+# ----------------------------------------------------------------------
+# router submode commands
+#
+VROUTER_COMMAND_DESCRIPTION = {
+ 'name' : 'router',
+ 'help' : 'Enter virtual router definition submode',
+ 'mode' : 'config-tenant*',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'virtualrouter',
+ 'submode-name' : 'config-tenant-router',
+ 'feature' : 'vns',
+ 'short-help' : 'Enter virtual router definition submode',
+ 'doc' : 'vns|tenant-vrouter',
+ 'doc-example' : 'vns|tenant-vrouter-example',
+ 'args' : (
+ {
+ 'field' : 'vrname',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ 'scoped' : True,
+ 'syntax-help' : 'Enter a router name',
+ 'action' : (
+ {
+ 'proc' : 'virtualrouter-warn-external-config',
+ },
+ { 'proc' : 'tenant-show-preprocess'
+ },
+ {
+ 'proc' : 'push-mode-stack',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'virtualrouter-confirm-external-delete',
+ },
+ { 'proc' : 'tenant-show-preprocess'
+ },
+ {
+ 'proc' : 'delete-objects',
+ },
+ )
+ }
+ ),
+}
+
+virtualrouter_show_action = (
+ { 'proc' : 'tenant-show-preprocess'},
+ {
+ 'proc' : 'query-table',
+ },
+ {
+ 'proc' : 'display',
+ 'format' : 'virtualrouter',
+ },
+)
+
+VIRTUALROUTER_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'virtualrouter',
+ 'mode' : 'config-tenant*',
+ 'command-type' : 'display-table',
+ 'action' : virtualrouter_show_action,
+ 'short-help' : 'Show specific virtual router, identified by name',
+ 'doc' : 'vns|show-tenant-id-router',
+ 'doc-example' : 'vns|show-tenant-id-router-example',
+ 'args' : (
+ 'router',
+ )
+}
+
+VIRTUALROUTER_SHOW_ID_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'virtualrouter',
+ 'mode' : 'config-tenant*',
+ 'command-type' : 'display-table',
+ 'action' : virtualrouter_show_action,
+ 'short-help' : 'Show specific virtual router, identified by name',
+ 'doc' : 'vns|show-tenant-vrouter-id',
+ 'doc-example' : 'vns|show-tenant-vrouter-id-example',
+ 'args' : (
+ 'router',
+ {
+ 'field' : 'vrname',
+ 'type' : 'identifier',
+ 'completion' : 'complete-object-field',
+ 'help-name' : "virtualrouter-id",
+ 'scoped' : True,
+ },
+ {
+ 'optional' : True,
+ 'choices' : (
+ {
+ 'token' : 'ip-address-pool',
+ 'obj-type' : 'interface-address-pool',
+ 'doc' : 'vns|show-tenant-id-router-ippool',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'interface-address-pool'},
+ ),
+ },
+ {
+ 'field' : 'route',
+ 'type' : 'enum',
+ 'values' : 'route',
+ 'obj-type' : 'virtualrouter-routingrule',
+ 'doc' : 'vns|show-tenant-id-router-route',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table',},
+ {
+ 'proc' : 'display',
+ 'format' : 'virtualrouter-routingrule'},
+ ),
+ },
+ (
+ {
+ 'field' : 'interfaces',
+ 'type' : 'enum',
+ 'values' : 'interfaces',
+ 'obj-type' : 'virtualrouter-interface',
+ 'doc' : 'vns|show-tenant-id-router-interfaces',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'virtualrouter-interface'},
+ ),
+ },
+ {
+ 'optional' : True,
+ 'args' : (
+ {
+ 'field' : 'vriname',
+ 'obj-type' : 'virtualrouter-interface',
+ 'completion' : ['complete-virtualrouter-preprocess',
+ 'complete-from-another'],
+ 'other' : 'virtualrouter-interface|vriname',
+ 'scoped' : 'virtual-router',
+ 'explicit' : True,
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'virtualrouter-interface'},
+ ),
+ },
+ {'optional' : True,
+ 'token' : 'ip-address-pool',
+ 'obj-type' : 'interface-address-pool',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'interface-address-pool'},
+ ),
+ },
+ ),
+ },
+ ),
+ (
+ {
+ 'field' : 'gateway-pools',
+ 'type' : 'enum',
+ 'values' : 'gateway-pools',
+ 'obj-type' : 'virtualrouter-gwpool',
+ 'doc' : 'vns|show-tenant-id-router-gwpools',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'virtualrouter-gwpool'},
+ ),
+ },
+ {
+ 'optional' : True,
+ 'args' : (
+ {
+ 'field' : 'vrgwname',
+ 'obj-type' : 'virtualrouter-gwpool',
+ 'completion' : ['complete-virtualrouter-preprocess',
+ 'complete-from-another'],
+ 'other' : 'virtualrouter-gwpool|vrgwname',
+ 'scoped' : 'virtual-router',
+ 'explicit' : True,
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'virtualrouter-gwpool'},
+ ),
+ },
+ {'optional' : True,
+ 'token' : 'gw-address-pool',
+ 'obj-type' : 'gateway-address-pool',
+ 'action' : (
+ { 'proc' : 'tenant-show-preprocess'},
+ { 'proc' : 'query-table'},
+ { 'proc' : 'display',
+ 'format' : 'gateway-address-pool'},
+ ),
+ },
+ ),
+ },
+ ),
+ ),
+ },
+ )
+}
+
+VIRTUALROUTER_DEF_DESCRIPTION_COMMAND_DESCRIPTION = {
+ 'name' : 'description',
+ 'mode' : 'config-tenant-router',
+ 'command-type' : 'config',
+ 'short-help' : 'Provide description for a virtual router instance',
+ 'doc' : 'vns|tenant-router-description',
+ 'doc-example' : 'vns|tenant-router-description-example',
+ 'args' : (
+ {
+ 'field' : 'description',
+ 'type' : 'string',
+ }
+ ),
+}
+
+
+VIRTUALROUTER_DEF_ORIGIN_COMMAND_DESCRIPTION = {
+ 'name' : 'origin',
+ 'mode' : 'config-tenant-router',
+ 'command-type' : 'config',
+ 'short-help' : 'Describe virtual router origin',
+ 'doc' : 'virtualrouter|origin',
+ 'doc-example' : 'virtualrouter|origin-example',
+ 'args' : (
+ {
+ 'field' : 'origin',
+ 'type' : 'string',
+ 'action' : (
+ {
+ 'proc' : 'virtualrouter-warn-external-config',
+ },
+ {
+ 'proc' : 'write-fields',
+ },
+ ),
+ },
+ ),
+}
+
+VIRTUALROUTER_INTF_DEF_ORIGIN_COMMAND_DESCRIPTION = {
+ 'name' : 'origin',
+ 'mode' : 'config-tenant-router-intf',
+ 'command-type' : 'config',
+ 'short-help' : 'Describe virtual router interface origin',
+ 'doc' : 'virtualrouter|origin',
+ 'doc-example' : 'virtualrouter|origin-example',
+ 'args' : (
+ {
+ 'field' : 'origin',
+ 'type' : 'string',
+ 'action' : (
+ {
+ 'proc' : 'virtualrouter-warn-external-config',
+ },
+ {
+ 'proc' : 'write-fields',
+ },
+ ),
+ },
+ ),
+}
+
+#
+# ----------------------------------------------------------------------
+# router interface submode commands
+#
+VROUTER_INTERFACE_COMMAND_DESCRIPTION = {
+ 'name' : 'interface',
+ 'help' : 'Enter virtual router interface definition submode',
+ 'mode' : 'config-tenant-router*',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'virtualrouter-interface',
+ 'submode-name' : 'config-tenant-router-intf',
+ 'short-help' : 'Enter virtual router interface definition submode',
+ 'doc' : 'vns|tenant-router-interface',
+ 'doc-example' : 'vns|tenant-router-interface-example',
+ 'args' : (
+ {
+ 'field' : 'vriname',
+ 'type' : 'identifier',
+ 'scoped' : 'virtual-router',
+ 'explicit' : True,
+ 'completion' : [ 'complete-virtualrouter-preprocess',
+ 'complete-object-field',
+ ],
+ 'other' : 'virtualrouter-interface|vriname',
+ 'syntax-help' : 'Enter a router interface name',
+ 'action' : (
+ {
+ 'proc' : 'virtualrouter-preprocess',
+ },
+ {
+ 'proc' : 'push-mode-stack',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'virtualrouter-preprocess',
+ },
+ {
+ 'proc' : 'delete-objects',
+ },
+ )
+ },
+ {
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'choices' : (
+ (
+ {
+ 'token' : 'vns',
+ 'doc' : 'vns|interface-vns-connected',
+ },
+ {
+ 'field' :'vns-connected',
+ 'type' : 'identifier',
+ 'completion' : ['complete-virtualrouter-preprocess',
+ 'complete-from-another'],
+ 'other' : 'vns-definition|vnsname',
+ 'syntax-help' : 'Enter a VNS to connect',
+ 'scoped' : 'tenant',
+
+ 'explicit' : True,
+ }
+ ),
+ (
+ {
+ 'token' : 'tenant',
+ 'doc' : 'vns|interface-router-connected',
+ },
+ { 'field' :'router-connected-tenant',
+ 'type' : 'identifier',
+ 'completion' : ['complete-from-another',
+ 'complete-virtualrouter-postprocess'],
+ 'other' : 'tenant|name',
+ 'syntax-help' : 'Enter a Tenant Router to connect',
+ },
+ {
+ 'field' :'router-connected',
+ 'type' : 'identifier',
+ 'scoped' : 'tenant',
+ 'explicit' : True,
+ 'completion' : ['complete-virtualrouter-preprocess',
+ 'complete-from-another'],
+ 'other' : 'virtualrouter|vrname',
+ 'syntax-help' : 'Enter a Tenant Router to connect',
+ },
+ )
+ ),
+ },
+
+ ),
+}
+
+VRI_DEF_ACTIVE_COMMAND_DESCRIPTION = {
+ 'name' : 'active',
+ 'mode' : 'config-tenant-router-intf',
+ 'short-help' : 'Set Virtual Router Interface active',
+ 'doc' : 'vns|tenant-router-active',
+ 'doc-example' : 'vns|tenant-router-active-example',
+ 'doc-include' : [ 'default' ],
+ 'obj-type' : 'virtualrouter-interface',
+ 'args' : (),
+ 'action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : True },
+ 'syntax-help' : 'mark the interface as active',
+ }
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : False },
+ 'syntax-help' : 'mark the interface as inactive',
+ }
+ )
+}
+
+VRI_DEF_IP_COMMAND_DESCRIPTION = {
+ 'name' : 'ip',
+ 'mode' : 'config-tenant-router-intf',
+ 'short-help' : 'Set Virtual Router Interface IP address',
+ 'doc' : 'vns|tenant-router-interfaceip',
+ 'doc-example' : 'vns|tenant-router-interfaceip-example',
+ 'doc-include' : [ 'default' ],
+ 'parent-field' : 'virtual-router-interface',
+ 'command-type' : 'config-object',
+ 'obj-type' : 'interface-address-pool',
+ 'data' : {
+ 'ip-address' : None,
+ 'subnet-mask' : None,
+ },
+ 'args' : (
+ { 'choices': (
+ (
+ {
+ 'field' : 'ip-address',
+ 'type' : 'ip-address-not-mask',
+ 'doc' : 'vns|vns-access-list-ip-and-mask-ip',
+ },
+ {
+ 'field' : 'subnet-mask',
+ 'type' : 'netmask',
+ 'data-handler' : 'convert-inverse-netmask',
+ 'doc' : 'vns|vns-access-list-ip-and-mask-mask',
+ },
+ ),
+ (
+ {
+ 'field' : 'ip-address',
+ 'type' : 'cidr-range',
+ 'help-name' : 'src-cidr',
+ 'data-handler' : 'split-cidr-data-inverse',
+ 'dest-ip' : 'ip-address',
+ 'dest-netmask' : 'subnet-mask',
+ 'doc' : 'vns|vns-access-list-cidr-range',
+ }
+ ),
+ )
+ }
+ ),
+ 'action' : ( {
+ 'proc' : 'verify-router-intf-ip'
+ },
+ {
+ 'proc' : 'write-object',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'delete-objects',
+ },
+ ),
+}
+
+#
+# ----------------------------------------------------------------------
+# gateway pool submode commands
+#
+VROUTER_GWPOOL_COMMAND_DESCRIPTION = {
+ 'name' : 'gateway-pool',
+ 'help' : 'Enter virtual router gateway pool submode',
+ 'mode' : 'config-tenant-router*',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'virtualrouter-gwpool',
+ 'submode-name' : 'config-tenant-router-gw',
+ 'short-help' : 'Enter virtual router gateway pool definition submode',
+ 'doc' : 'vns|tenant-router-gwpool',
+ 'doc-example' : 'vns|tenant-router-gwpool-example',
+ 'args' : (
+ {
+ 'field' : 'vrgwname',
+ 'type' : 'identifier',
+ 'scoped' : 'virtual-router',
+ 'explicit' : True,
+ 'completion' : [ 'complete-virtualrouter-preprocess',
+ 'complete-object-field',
+ ],
+ 'other' : 'virtualrouter-gwpool|vrgwname',
+ 'syntax-help' : 'Enter a router gateway pool name',
+ 'action' : (
+ {
+ 'proc' : 'virtualrouter-preprocess',
+ },
+ {
+ 'proc' : 'push-mode-stack',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'virtualrouter-preprocess',
+ },
+ {
+ 'proc' : 'delete-objects',
+ },
+ )
+ },
+ ),
+}
+
+VRGW_DEF_IP_COMMAND_DESCRIPTION = {
+ 'name' : 'ip',
+ 'mode' : 'config-tenant-router-gw',
+ 'short-help' : 'Add IP address to the gateway pool',
+ 'doc' : 'vns|tenant-router-gwip',
+ 'doc-example' : 'vns|tenant-router-gwip-example',
+ 'doc-include' : [ 'default' ],
+ 'parent-field' : 'virtual-router-gwpool',
+ 'command-type' : 'config-object',
+ 'obj-type' : 'gateway-address-pool',
+ 'data' : {
+ 'ip-address' : None,
+ },
+ 'args' : (
+ {
+ 'field' : 'ip-address',
+ 'type' : 'ip-address-not-mask',
+ 'doc' : 'vns|vns-access-list-ip-and-mask-ip',
+ 'action' : (
+ {
+ 'proc' : 'verify-router-gw-ip'
+ },
+ {
+ 'proc' : 'write-object',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'delete-objects',
+ },
+ ),
+ },
+ ),
+}
+
+
+STATIC_ARP_COMMAND_DESCRIPTION = {
+ 'name' : 'arp',
+ 'mode' : 'config*',
+ 'short-help' : 'Set Static ARP',
+ 'doc' : 'static-arp',
+ 'doc-example' : 'static-arp-example',
+ 'doc-include' : [ 'default' ],
+ 'command-type' : 'config',
+ 'obj-type' : 'static-arp',
+ 'data' : {
+ 'ip' : None,
+ 'mac' : None,
+ },
+ 'args' : (
+
+ {
+ 'field' : 'ip',
+ 'type' : 'ip-address-not-mask',
+ },
+ {
+ 'field' : 'mac',
+ 'type' : 'mac-address',
+ },
+
+ ),
+ 'action' : (
+ {
+ 'proc' : 'write-object',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'delete-objects',
+ },
+ ),
+}
+tenant_show_action = (
+ {
+ 'proc' : 'query-table',
+ },
+ {
+ 'proc' : 'display',
+ 'format' : 'staticarp',
+ },
+)
+
+STATIC_ARP_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'all-help' : 'Show static ARP details',
+ 'short-help' : 'Show all configured static ARPs',
+ 'command-type' : 'display-table',
+ 'obj-type' : 'static-arp',
+ 'doc' : 'show-arp',
+ 'doc-example' : 'show-arp-example',
+ 'action' : tenant_show_action,
+ 'args' : (
+ 'arp',
+ )
+}
+#
+# FORMATS
+ARP_FORMAT = {
+ 'staticarp' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'ip', 'mac'],
+ },
+ 'fields' : {
+ 'ip' : {
+ },
+ 'mac' : {
+ },
+ }
+ },
+}
+SRC_IP_MATCH = {
+ 'choices' : (
+ (
+ {
+ 'field' : 'src-ip',
+ 'type' : 'ip-address-not-mask',
+ 'doc' : 'vns|vns-access-list-ip-and-mask-ip',
+ },
+ {
+ 'field' : 'src-ip-mask',
+ 'type' : 'netmask',
+ 'doc' : 'vns|vns-access-list-ip-and-mask-mask',
+ 'data-handler' : 'convert-inverse-netmask',
+ },
+ ),
+ (
+ {
+ 'field' : 'src-ip',
+ 'type' : 'ip-address-not-mask',
+ 'data' : {
+ 'src-ip-mask' : '0.0.0.0',
+ },
+ 'doc' : 'vns|vns-access-list-ip-only',
+ },
+ ),
+ (
+ {
+ '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',
+ 'doc' : 'vns|vns-access-list-cidr-range',
+ }
+ ),
+ (
+ {
+ 'token' : 'any',
+ 'data' : {
+ 'src-ip' : '0.0.0.0',
+ 'src-ip-mask' : '255.255.255.255',
+ },
+ 'doc' : 'vns|vns-access-list-ip-any',
+ }
+ ),
+ )
+}
+
+DST_IP_MATCH = {
+ 'choices' : (
+ (
+ {
+ 'field' : 'dst-ip',
+ 'type' : 'ip-address-not-mask',
+ 'doc' : 'vns|vns-access-list-ip-and-mask-ip',
+ },
+ {
+ 'field' : 'dst-ip-mask',
+ 'type' : 'netmask',
+ 'doc' : 'vns|vns-access-list-ip-and-mask-mask',
+ 'data-handler' : 'convert-inverse-netmask',
+ },
+ ),
+ (
+ {
+ 'field' : 'dst-ip',
+ 'type' : 'ip-address-not-mask',
+ 'data' : {
+ 'dst-ip-mask' : '0.0.0.0',
+ },
+ 'doc' : 'vns|vns-access-list-ip-only',
+ },
+ ),
+ (
+ {
+ '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',
+ 'dst-ip-mask' : '255.255.255.255',
+ },
+ 'doc' : 'vns|vns-access-list-ip-any',
+ }
+ ),
+ )
+}
+
+ROUTING_RULE_COMMAND_DESCRIPTION = {
+ 'name' : 'route',
+ 'mode' : 'config-tenant-router*',
+ 'short-help' : 'Set Routing Rule',
+ 'doc' : 'vns|tenant-router-route',
+ 'doc-example' : 'vns|tenant-router-route-example',
+ 'doc-include' : [ 'default' ],
+ 'command-type' : 'config-object',
+ 'obj-type' : 'virtualrouter-routingrule',
+ 'args' : (
+ {'token' : 'from'
+ },
+ {
+ 'choices': (
+ ({'token' : 'tenant'},
+ {'field' : 'src-tenant',
+ 'type' : 'identifier',
+ 'completion' : 'complete-from-another',
+ 'other' : 'tenant|name',
+ 'help-name' : 'source tenant'
+ },
+ {
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'args' : (
+ {'token' : 'vns',
+ },
+ {'field' : 'src-vns',
+ 'type' : 'identifier',
+ 'completion' : ['complete-virtualrouter-preprocess',
+ 'complete-from-another'],
+ 'other' : 'vns-definition|vnsname',
+ 'help-name' : 'source VNS',
+ },
+ ),
+ },
+ ),
+ ({'token' : 'vns',
+ },
+ {'field' : 'src-vns',
+ 'type' : 'identifier',
+ 'completion' : 'complete-from-another',
+ 'other' : 'vns-definition|vnsname',
+ 'help-name' : 'source VNS',
+ },
+ ),
+ ( SRC_IP_MATCH,
+ )
+ )
+ },
+ {'token' : 'to',
+ },
+ {
+ 'choices': (
+ ({'token' : 'tenant'},
+ {'field' : 'dst-tenant',
+ 'type' : 'identifier',
+ 'completion' : 'complete-from-another',
+ 'other' : 'tenant|name',
+ 'help-name' : 'destination tenant'
+ },
+ {
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'args' : (
+ {'token' : 'vns',
+ },
+ {'field' : 'dst-vns',
+ 'type' : 'identifier',
+ 'completion' : ['complete-virtualrouter-preprocess',
+ 'complete-from-another'],
+ 'other' : 'vns-definition|vnsname',
+ 'help-name' : 'destination VNS',
+ },
+ ),
+ },
+ ),
+ ({'token' : 'vns',
+ },
+ {'field' : 'dst-vns',
+ 'type' : 'identifier',
+ 'completion' : 'complete-from-another',
+ 'other' : 'vns-definition|vnsname',
+ 'help-name' : 'destination VNS',
+ },
+ ),
+ ( DST_IP_MATCH,
+ )
+ )
+ },
+ {
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'choices' : (
+ (
+ {
+ 'field' : 'nh-ip',
+ 'type' : 'ip-address-not-mask',
+ 'help-name': 'next hop ip address',
+ 'doc' : 'vns|vns-access-list-ip-only',
+ },
+ ),
+ (
+ {'token' : 'gw-pool',
+ },
+ {
+ 'field' : 'gateway-pool',
+ 'type' : 'identifier',
+ 'scoped' : 'virtual-router',
+ 'explicit' : True,
+ 'completion' : ['complete-virtualrouter-preprocess',
+ 'complete-from-another'],
+ 'other' : 'virtualrouter-gwpool|vrgwname',
+ 'help-name' : 'gateway pool name',
+ 'doc' : 'vns|gateway-pool',
+ },
+ ),
+ ),
+ },
+ {
+ 'field' : 'outgoing-intf',
+ 'type' : 'identifier',
+ 'scoped' : 'virtual-router',
+ 'explicit' : True,
+ 'completion' : ['complete-virtualrouter-preprocess',
+ 'complete-from-another'],
+ 'other' : 'virtualrouter-interface|vriname',
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'help-name' : 'outgoing interface',
+ 'doc' : 'vns|outgoing-interface',
+ },
+ {'field' : 'action',
+ 'type' : 'enum',
+ 'values' : ('deny', 'permit'),
+ }
+ ),
+ 'action' : (
+ {
+ 'proc' : 'virtualrouter-preprocess'
+ },
+ {
+ 'proc' : 'write-object',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'virtualrouter-preprocess'
+ },
+ {
+ 'proc' : 'delete-objects',
+ },
+ ),
+}
+
+# FORMATS
+VIRTUALROUTER_FORMAT = {
+ 'virtualrouter' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'tenant', 'vrname', 'description'],
+ 'details' : [ 'Idx', 'tenant', 'vrname', 'description'],
+ 'brief' : [ 'Idx', 'tenant', 'vrname'],
+ },
+ 'fields' : {
+ 'tenant' : { 'verbose-name' : 'Tenant ID',
+ },
+ 'vrname' : {
+ },
+ 'description' : {
+ },
+ }
+ },
+}
+VIRTUALROUTER_INTERFACE_FORMAT = {
+ 'virtualrouter-interface' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'virtual-router', 'vriname', 'active', 'vns-connected','router-connected'],
+ 'details' : [ 'Idx', 'virtual-router', 'vriname', 'active', 'vns-connected','router-connected'],
+ 'brief' : [ 'Idx', 'virtual-router', 'vriname', 'active'],
+ },
+ 'fields' : {
+ 'virtual-router' : {},
+ 'vriname' : {},
+ 'active' : {},
+ 'vns-connected' : {},
+ 'router-connected' : {},
+ }
+ },
+}
+VIRTUALROUTER_GWPOOL_FORMAT = {
+ 'virtualrouter-gwpool' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'virtual-router', 'vrgwname'],
+ 'details' : [ 'Idx', 'virtual-router', 'vrgwname'],
+ 'brief' : [ 'Idx', 'virtual-router', 'vrgwname'],
+ },
+ 'fields' : {
+ 'virtual-router' : {},
+ 'vrgwname' : {},
+ }
+ },
+}
+GATEWAY_ADDRESS_POOL_FORMAT = {
+ 'gateway-address-pool' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'virtual-router-gwpool', 'ip-address'],
+ },
+ 'fields' : {
+ 'virtual-router-gwpool' : {'verbose-name' : 'Virtual Router Gateway Pool',},
+ 'ip-address' : {'verbose-name' : 'IP Address',},
+ }
+ },
+}
+VIRTUALROUTER_ROUTINGRULE_FORMAT = {
+ 'virtualrouter-routingrule' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'virtual-router','action','src-tenant','src-vns','src-ip','src-ip-mask','dst-tenant','dst-vns','dst-ip','dst-ip-mask','nh-ip','gateway-pool','outgoing-intf'],
+ },
+ 'fields' : {
+ 'virtual-router' : {},
+ 'src-tenant' : {},
+ 'src-vns' : {},
+ 'src-ip' : {},
+ 'src-ip-mask' : {'formatter' : fmtcnv.convert_inverse_netmask_handler,},
+ 'dst-tenant' : {},
+ 'dst-vns' : {},
+ 'dst-ip' : {},
+ 'dst-ip-mask' : {'formatter' : fmtcnv.convert_inverse_netmask_handler,},
+ 'nh-ip' : {},
+ 'gateway-pool' : {},
+ 'outgoing-intf' : {},
+ 'action' : {},
+ }
+ },
+}
+INTERFACE_ADDRESS_POOL_FORMAT = {
+ 'interface-address-pool' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'virtual-router-interface', 'ip-address', 'subnet-mask'],
+ },
+ 'fields' : {
+ 'virtual-router-interface' : {'verbose-name' : 'Virtual Router Interface',},
+ 'ip-address' : {'verbose-name' : 'IP Address',},
+ 'subnet-mask' : {'formatter' : fmtcnv.convert_inverse_netmask_handler,},
+ }
+ },
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/virtualrouter_model.py b/cli/desc/version200/virtualrouter_model.py
new file mode 100755
index 0000000..a962874
--- /dev/null
+++ b/cli/desc/version200/virtualrouter_model.py
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_disable_edit('virtualrouter', 'origin')
+command.model_obj_type_disable_edit('virtualrouter', 'vrname')
+command.model_obj_type_disable_edit('virtualrouter', 'tenant')
+command.model_obj_type_disable_edit('virtualrouter', 'description')
+command.model_obj_type_disable_edit('virtualrouter', 'active')
+command.model_obj_type_disable_edit('virtualrouter-interface', 'active')
+command.model_obj_type_disable_edit('virtualrouter-interface', 'vriname')
+command.model_obj_type_disable_edit('virtualrouter-interface', 'origin')
+command.model_obj_type_disable_edit('virtualrouter-interface', 'vns-connected')
+command.model_obj_type_disable_edit('virtualrouter-interface', 'router-connected')
+command.model_obj_type_disable_edit('virtualrouter-interface', 'virtual-router')
+command.model_obj_type_disable_edit('virtualrouter-gwpool', 'vrgwname')
\ No newline at end of file
diff --git a/cli/desc/version200/vns.py b/cli/desc/version200/vns.py
new file mode 100755
index 0000000..8ea1f19
--- /dev/null
+++ b/cli/desc/version200/vns.py
@@ -0,0 +1,1892 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+import fmtcnv
+'''
+def vns_origin_external(data):
+ """
+ Return origin-name when the vns wasn't created by the cli,
+ return None otherwise.
+ """
+ pk = command.mi.pk('vns-definition')
+ if not pk in data:
+ return;
+
+ vns = command.sdnsh.get_table_from_store('vns-definition',
+ pk,
+ data[pk])
+ if len(vns) == 0:
+ return None
+
+ local = ['cli', 'rest']
+ if 'origin' in vns[0] and not vns[0]['origin'] in local:
+ return vns[0]['origin']
+ return None
+
+
+def vns_warn_external_config(data):
+ """
+ From the named vns, look up the entry, if it exists in the
+ database, validate the 'origin' is either null, or 'cli',
+ otherwise provide a warning about this particular vns
+ (along with the originator name)
+ """
+ external_origin = vns_origin_external(data)
+ if external_origin:
+ command.sdnsh.warning('vns %s may not be intended for cli update, '
+ 'origin/creator "%s" ' % (data['id'], external_origin))
+
+command.add_action('vns-warn-external-config', vns_warn_external_config,
+ {'kwargs': {'data' : '$data',}})
+
+def complete_tenantname_preprocess(data):
+ data['tenant']='default'
+ if 'name' in data:
+ data['tenant']= data['name']
+ del data['name']
+ else:
+ current_mode=command.sdnsh.current_mode()
+ if not current_mode.startswith('config-tenant'):
+ data['tenant']='default'
+ if current_mode.startswith('config-tenant'):
+ for x in command.sdnsh.mode_stack:
+ if x['mode_name'] == 'config-tenant':
+ data['tenant'] = x['obj']
+
+
+command.add_completion('complete-tenantname-preprocess', complete_tenantname_preprocess,
+ {'kwargs': {'data': '$data',
+ }})
+
+def vns_confirm_external_delete(data):
+ """
+ From the named vns, look up the entry, if it exists in the
+ database, validate the 'origin' is either null, or 'cli',
+ otherwise provide a warning about this particular vns
+ (along with the originator name)
+ """
+ external_origin = vns_origin_external(data)
+ if external_origin:
+ confirm = command.action_registry['confirm'][0] # XXX accessor?
+ confirm('vns %s may not be intended for cli delete, '
+ 'origin/creator "%s"\nEnter y or yes to continue delete: '
+ % (data['id'], external_origin))
+
+command.add_action('vns-confirm-external-delete', vns_confirm_external_delete,
+ {'kwargs': {'data' : '$data',}})
+
+command.add_action('vns-confirm-external-delete', vns_confirm_external_delete,
+ {'kwargs': {'data' : '$data',}})
+'''
+"""
+#
+# ----------------------------------------------------------------------
+# vns-definition submode commands
+#
+
+# notice the submode is called 'config-def-vns', this was
+# changed from 'config-vns-def' so that the vns submode,
+# which is called 'config-vns', wouldn't be a string-prefix
+# submode of config-vns. Various command, such as the
+# vns-submode access-list command were showing up in the
+# vns-definition submode due to this prefixing.
+
+VNS_DEFINITION_COMMAND_DESCRIPTION = {
+ 'name' : 'vns-definition',
+ 'help' : 'Enter VNS definition submode',
+ 'mode' : 'config*',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'vns-definition',
+ 'submode-name' : 'config-tenant-def-vns',
+ 'feature' : 'vns',
+ 'short-help' : 'Enter VNS definition submode',
+ 'doc' : 'vns|vns-definition',
+ 'doc-example' : 'vns|vns-definition-example',
+ 'args' : (
+ {
+ 'field' : 'vnsname',
+ 'type' : 'identifier',
+ 'completion' : ['complete-tenantname-preprocess',
+ 'complete-object-field'],
+ 'other' : 'vns-definition|vnsname',
+# 'scoped' : 'tenant',
+ 'syntax-help' : 'Enter a vns name',
+ 'doc' : 'vns|vns-id',
+ 'doc-example' : 'vns|vns-id-example',
+ 'doc-include' : [ 'type-doc' ],
+ 'action' : (
+ {
+ 'proc' : 'vns-warn-external-config',
+ },
+ {
+ 'proc' : 'tenant-show-preprocess',
+ },
+ {
+ 'proc' : 'push-mode-stack',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'vns-confirm-external-delete',
+ },
+ {
+ 'proc' : 'tenant-show-preprocess',
+ },
+ {
+ 'proc' : 'delete-objects',
+ },
+ )
+ }
+ ),
+}
+
+vns_show_action = (
+ {
+ 'proc' : 'tenant-show-preprocess',
+ },
+ {
+ 'proc' : 'query-table',
+ },
+ {
+ 'proc' : 'display',
+ 'format' : 'vns-definition',
+ },
+)
+
+VNS_SHOW_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'login',
+ 'all-help' : 'Show VNS details',
+ 'short-help' : 'Show all defined VNSs belong to current tenant',
+ 'command-type' : 'display-table',
+ 'obj-type' : 'vns-definition',
+ 'action' : vns_show_action,
+ 'doc' : 'vns|show',
+ 'doc-example' : 'vns|show-example',
+ 'args' : (
+ 'vns',
+ ),
+}
+VNS_SHOW_ID_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'vns-definition',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'action' : vns_show_action,
+ 'short-help' : 'Show specific VNS, identified by name',
+ 'doc' : 'vns|show-id',
+ 'doc-example' : 'vns|show-id-example',
+ 'args' : (
+ 'vns',
+ {
+ 'choices' : (
+ {
+ 'field' : 'vnsname',
+ 'type' : 'identifier',
+# 'completion' : 'complete-object-field',
+ 'completion' : ['complete-tenantname-preprocess',
+ 'complete-from-another'],
+ 'other' : 'vns-definition|vnsname',
+ 'scoped' : 'tenant',
+ 'help-name' : "vns-id",
+ },
+ {
+ 'field' : 'vnsname',
+ 'type' : 'enum',
+ 'values' : 'all',
+ }
+ ),
+ },
+ {
+ 'field' : 'detail',
+ 'optional' : True,
+ 'type' : 'enum',
+ 'values' : ('details', 'brief'),
+ 'doc' : 'format|+',
+ }
+ )
+}
+
+VNS_SHOW_ID_DETAILS_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'obj-type' : 'vns-definition',
+ 'mode' : 'login',
+ 'command-type' : 'display-table',
+ 'short-help' : 'Show VNS associated details based on name',
+ 'doc' : 'vns|show-id',
+ 'doc-example' : 'vns|show-id-example',
+ 'args' : (
+ 'vns',
+ {
+ 'choices' : (
+ {
+ 'field' : 'vnsname',
+ 'type' : 'identifier',
+ 'completion' : ['complete-tenantname-preprocess',
+ 'complete-from-another'],
+ 'other' : 'vns-definition|vnsname',
+ 'scoped' : 'tenant',
+ 'help-name' : "vns-id",
+ },
+ {
+ 'field' : 'vnsname',
+ 'type' : 'enum',
+ 'values' : 'all',
+ }
+ ),
+ },
+ {
+ 'choices' : (
+ {
+ 'field' : 'vns-interface',
+ 'type' : 'enum',
+ 'values' : 'interfaces',
+ 'obj-type' : 'vns-interface',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ 'short-help' : 'Show VNS associated interfaces',
+ },
+ {
+ 'field' : 'mac-address-table',
+ 'type' : 'enum',
+ 'values' : 'mac-address-table',
+ 'obj-type' : 'host-vns-interface-vns',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ 'short-help' : 'Show VNS associated mac addresses',
+ },
+ {
+ 'field' : 'interface-rules',
+ 'type' : 'enum',
+ 'values' : 'interface-rules',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'display-table'),
+ 'obj-type' : 'vns-interface-rule',
+ 'short-help' : 'Show VNS configured interfaces-rules',
+ 'doc' : 'vns|show-id-interface-rules',
+ },
+ {
+ 'field' : 'access-lists',
+ 'type' : 'enum',
+ 'values' : 'access-lists',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'display-table'),
+ 'obj-type' : 'vns-access-list-entry',
+ 'detail' : 'acl-brief',
+ 'short-help' : 'Show VNS configured access-lists',
+ 'doc' : 'vns|show-id-access-lists',
+ },
+ {
+ 'field' : 'running-config',
+ 'type' : 'enum',
+ 'values' : 'running-config',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ 'short-help' : 'Show VNS running-config',
+ },
+ {
+ 'field' : 'legacy-cli',
+ 'type' : 'enum',
+ 'values' : 'switch',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ 'obj-type' : 'vns-switch-ports',
+ 'short-help' : 'Show VNS associated switches',
+ },
+ (
+ {
+ 'field' : 'legacy-cli',
+ 'type' : 'enum',
+ 'values' : 'flow',
+ 'obj-type' : 'vns-flow',
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ 'short-help' : 'Show VNS associated flows',
+ 'doc' : 'vns|show-id-flow',
+ },
+ {
+ 'field' : 'detail',
+ 'type' : 'enum',
+ 'values' : ('brief',
+ 'full-detail',
+ 'details',
+ 'summary',
+ ),
+ 'optional' : True,
+ 'short-help' : 'Detail level',
+ 'doc' : 'format|+'
+ }
+ )
+ )
+ }
+ ),
+}
+
+HOST_VNS_INTERFACE_VNS_FORMAT = {
+ 'host-vns-interface-vns' : { # with vns know, no vns column
+ 'source' : 'only display',
+
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'tenant', 'vns', 'address-space', 'host', 'vlan', 'ips', 'attachment-points', 'last-seen' ],
+ 'vns' : [ 'Idx', 'address-space', 'host', 'vlan', 'ips', 'attachment-points', 'last-seen' ],
+ },
+ 'fields' : {
+ 'Idx' : { 'verbose-name' : '#',
+ },
+ 'host' : { 'verbose-name' : 'MAC Address',
+ 'formatter' : fmtcnv.print_host_and_alias,
+ },
+ 'address-space' : {
+ 'verbose-name' : 'Address Space',
+ },
+ 'vlan' : {
+ 'verbose-name' : 'VLAN',
+ },
+ 'ips' : { 'verbose-name' : 'IP Address',
+ 'formatter' : fmtcnv.print_ip_addresses,
+ 'entry_formatter' : fmtcnv.print_all_ip_addresses,
+ },
+ 'attachment-points' : { 'verbose-name' : 'Attachment Point',
+ 'formatter' : fmtcnv.print_host_attachment_point,
+ 'entry_formatter' : fmtcnv.print_all_host_attachment_points,
+ },
+ 'last-seen' : { 'verbose-name' : 'Last Seen',
+ 'formatter' : fmtcnv.print_time_since_utc
+ },
+ 'tenant' : {'verbose-name' : 'Tenant',
+ }
+ }
+ },
+}
+
+
+
+VNS_DEF_DESCRIPTION_COMMAND_DESCRIPTION = {
+ 'name' : 'description',
+ 'mode' : 'config-tenant-def-vns',
+ 'command-type' : 'config',
+ 'short-help' : 'Provide description for a VNS instance',
+ 'doc' : 'vns|description',
+ 'doc-example' : 'vns|description-example',
+ 'args' : (
+ {
+ 'field' : 'description',
+ 'type' : 'string',
+ }
+ ),
+}
+
+
+VNS_DEF_ACTIVE_COMMAND_DESCRIPTION = {
+ 'name' : 'active',
+ 'mode' : 'config-tenant-def-vns',
+ 'short-help' : 'Set vns active',
+ 'doc' : 'vns|active',
+ 'doc-example' : 'vns|active-example',
+ 'doc-include' : [ 'default' ],
+ 'args' : (),
+ 'action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : True },
+ 'syntax-help' : 'mark the vns as active',
+ }
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : False },
+ 'syntax-help' : 'mark the vns as inactive',
+ }
+ )
+}
+
+VNS_DEF_ORIGIN_COMMAND_DESCRIPTION = {
+ 'name' : 'origin',
+ 'mode' : 'config-tenant-def-vns',
+ 'command-type' : 'config',
+ 'short-help' : 'Describe vns origin',
+ 'doc' : 'vns|origin',
+ 'doc-example' : 'vns|origin-example',
+ 'args' : (
+ {
+ 'field' : 'origin',
+ 'type' : 'string',
+ 'action' : (
+ {
+ 'proc' : 'vns-warn-external-config',
+ },
+ {
+ 'proc' : 'write-fields',
+ },
+ ),
+ },
+ ),
+}
+
+VNS_DEF_USE_ADDRESS_SPACE_COMMAND_DESCRIPTION = {
+ 'name' : 'use',
+ 'short-help' : 'Associate address space',
+ 'all-help' : 'Associate VNS with other objects',
+ 'mode' : 'config-tenant-def-vns',
+ 'command-type' : 'config',
+ 'obj-type' : 'vns-definition',
+ 'doc' : 'vns|use-address-space',
+ 'doc-example' : 'vns|use-address-space-example',
+ 'doc-include' : 'default',
+ 'args' : (
+ 'address-space',
+ {
+ 'field' : 'address-space',
+ 'type' : 'identifier',
+ 'completion' : [
+ 'complete-object-field',
+ 'complete-from-another',
+ ],
+ 'other' : 'address-space',
+ 'syntax-help' : 'Enter associated address-space name',
+ 'optional-for-no' : False,
+ 'match-for-no' : 'address-space',
+ }
+ )
+}
+
+VNS_DEF_ARP_MODE_COMMAND_DESCRIPTION = {
+ 'name' : 'arp-mode',
+ 'short-help' : 'Configure arp mode',
+ 'doc' : 'vns|arp-mode',
+ 'doc-example' : 'vns|arp-mode-example',
+ 'mode' : 'config-tenant-def-vns',
+ 'command-type' : 'config',
+ 'doc-include' : [ 'default' ],
+ 'args' : (
+ {
+ 'field' : 'arp-mode',
+ 'type' : 'enum',
+ 'values' : ('always-flood', 'flood-if-unknown', 'drop-if-unknown'),
+ 'doc' : 'vns|arp-mode-value-+',
+ }
+ ),
+}
+
+VNS_DEF_BROADCAST_COMMAND_DESCRIPTION = {
+ 'name' : 'broadcast',
+ 'mode' : 'config-tenant-def-vns',
+ 'command-type' : 'config',
+ 'short-help' : 'Configure broadcast mode',
+ 'doc' : 'vns|broadcast',
+ 'doc-example' : 'vns|broadcast-example',
+ 'doc-include' : [ 'default' ],
+ 'args' : (
+ {
+ 'field' : 'broadcast',
+ 'type' : 'enum',
+ 'values' : ('always-flood', 'forward-to-known', 'drop'),
+ 'doc' : 'vns|broadcast-value-+',
+ }
+ ),
+}
+
+VNS_DEF_DHCP_IP_COMMAND_DESCRIPTION = {
+ 'name' : 'dhcp-ip',
+ 'mode' : 'config-tenant-def-vns',
+ 'command-type' : 'config',
+ 'short-help' : 'Configure dhcp ip address',
+ 'doc' : 'vns|dhcp-ip',
+ 'doc-example' : 'vns|dhcp-ip-example',
+ 'args' : (
+ {
+ 'field' : 'dhcp-ip',
+ 'type' : 'ip-address',
+ 'syntax-help' : 'Enter an IP Address',
+ }
+ ),
+}
+
+VNS_DEF_DHCP_MODE_COMMAND_DESCRIPTION = {
+ 'name' : 'dhcp-mode',
+ 'mode' : 'config-tenant-def-vns',
+ 'command-type' : 'config',
+ 'short-help' : 'Set dhcp mode',
+ 'doc' : 'vns|dhcp-mode',
+ 'doc-example' : 'vns|dhcp-mode-example',
+ 'doc-include' : [ 'default' ],
+ 'args' : (
+ {
+ 'field' : 'dhcp-mode',
+ 'type' : 'enum',
+ 'values' : ('always-flood', 'flood-if-unknown', 'static'),
+ 'doc' : 'vns|dhcp-value-+',
+ }
+ ),
+}
+
+VNS_INTERFACE_RULE_COMMAND_DESCRIPTION = {
+ 'name' : 'interface-rule',
+ 'mode' : 'config-tenant-def-vns*',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'vns-interface-rule',
+ 'parent-field' : 'vns',
+ 'submode-name' : 'config-tenant-def-vns-if-rule',
+ 'short-help' : 'Enter interface-rule submode, configure vns details',
+ 'doc' : 'vns|interface-rule',
+ 'doc-example' : 'vns|interface-rule-example',
+ 'args' : (
+ {
+ 'field' : 'rule',
+ 'type' : 'identifier',
+ 'syntax-help' : 'Enter a vns interface rule name',
+ 'completion' : 'complete-object-field',
+ 'scoped' : True,
+ }
+ )
+}
+
+VNS_PRIORITY_COMMAND_DESCRIPTION = {
+ 'name' : 'priority',
+ 'mode' : 'config-tenant-def-vns',
+ 'command-type' : 'config',
+ 'short-help' : 'Set vns priority',
+ 'doc' : 'vns|priority',
+ 'doc-example' : 'vns|priority-example',
+ 'args' : (
+ {
+ 'field' : 'priority',
+ 'base-type' : 'integer',
+ 'range' : (0, 65535),
+ }
+ )
+}
+
+#
+# ----------------------------------------------------------------------
+# vns-def-if submode commands
+# (vns definition interface rules submode)
+#
+
+VNS_DEF_IF_ACTIVE_COMMAND_DESCRIPTION = {
+ 'name' : 'active',
+ 'mode' : 'config-tenant-def-vns-if-rule',
+ 'command-type' : 'config',
+ 'short-help' : 'Set rule to Active',
+ 'doc' : 'vns|interface-rule-active',
+ 'doc-example' : 'vns|interface-rule-active-example',
+ 'doc-inlcude' : [ 'default' ],
+ 'args' : (),
+ 'action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : True }
+ }
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'active' : False }
+ }
+ )
+}
+
+VNS_DEF_IF_ALLOW_MULTIPLE_COMMAND_DESCRIPTION = {
+ 'name' : 'allow-multiple',
+ 'mode' : 'config-tenant-def-vns-if-rule',
+ 'command-type' : 'config',
+ 'short-help' : 'Enable multiple interface rule matches',
+ 'doc' : 'vns|interface-rule-allow-multiple',
+ 'doc-example' : 'vns|interface-rule-allow-multiple-example',
+ 'doc-include' : [ 'default' ],
+ 'args' : (),
+ 'action' : (
+ {
+ 'proc' : 'write-fields',
+ 'data' : { 'allow-multiple' : True }
+ }
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'reset-fields',
+ 'fields' : [ 'allow-multiple' ]
+ }
+ )
+}
+
+#
+# XXX vlan-tag-on-egress required in future releases when multiple vlans
+# tagging are supported in vns egress.
+#
+#VNS_DEF_IF_VLAN_TAG_ON_EGRESS_TMP_COMMAND_DESCRIPTION = {
+# 'name' : 'vlan-tag-on-egress',
+# 'short-help' : 'Enable vlan tagging on egress',
+# 'mode' : 'config-def-vns-if-rule',
+# 'command-type' : 'config',
+# 'args' : (),
+# 'action' : (
+# {
+# 'proc' : 'write-fields',
+# 'data' : { 'vlan-tag-on-egress' : True }
+# }
+# ),
+# 'no-action' : (
+# {
+# 'proc' : 'reset-fields',
+# 'fields' : [ 'vlan-tag-on-egress' ]
+# }
+# )
+# }
+
+VNS_DEF_IF_DESCRIPTION_COMMAND_DESCRIPTION = {
+ 'name' : 'description',
+ 'mode' : 'config-tenant-def-vns-if-rule',
+ 'short-help' : 'Provide description for interface rule',
+ 'doc' : 'vns|interface-rule-description',
+ 'doc-example' : 'vns|interface-rule-description-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'description',
+ 'type' : 'string',
+ }
+ ),
+}
+
+VNS_DEF_IF_PRIORITY_COMMAND_DESCRIPTION = {
+ 'name' : 'priority',
+ 'mode' : 'config-tenant-def-vns-if-rule',
+ 'command-type' : 'config',
+ 'short-help' : 'Describe priority for interface rule',
+ 'doc' : 'vns|interface-rule-priority',
+ 'doc-example' : 'vns|interface-rule-priority-example',
+ 'args' : (
+ {
+ 'field' : 'priority',
+ 'value' : 'integer',
+ }
+ ),
+}
+
+
+VNS_DEF_IF_MATCH_MAC_COMMAND_DESCRIPTION = {
+ 'name' : 'match',
+ 'mode' : 'config-tenant-def-vns-if-rule',
+ 'command-type' : 'config',
+ 'short-help' : 'Associate mac (host) with interface rule',
+ 'all-help' : 'Configure a match for this interface rule',
+ 'doc' : 'vns|interface-rule-match-mac',
+ 'doc-example' : 'vns|interface-rule-match-mac-example',
+ 'doc-all' : 'address-space|match',
+ 'data' : { 'mac' : None }, # for no command reset
+ 'obj-type' : 'vns-interface-rule',
+ 'args' : (
+ {
+ 'token' : 'mac',
+ },
+ {
+ 'field' : 'mac',
+ 'type' : 'host',
+ 'help-name' : 'host mac or alias',
+ 'completion' : ['complete-object-field',
+ 'complete-from-another',
+ ],
+ 'scoped' : True,
+ 'data-handler' : 'alias-to-value',
+ 'other' : 'host',
+ 'optional-for-no' : True,
+ 'doc' : 'vns|interface-rule-match-mac-field',
+ }
+ ),
+}
+
+
+VNS_DEF_IF_MATCH_IP_SUBNET_COMMAND_DESCRIPTION = {
+ 'name' : 'match',
+ 'mode' : 'config-tenant-def-vns-if-rule',
+ 'command-type' : 'config',
+ 'short-help' : 'Associate ip-subnet (ip or cidr range) for interface rule',
+ 'doc' : 'vns|interface-rule-match-ip-subnet',
+ 'doc-example' : 'vns|interface-rule-match-ip-subnet-example',
+ 'data' : { 'ip-subnet' : None }, # for no command reset
+ 'args' : (
+ {
+ 'token' : 'ip-subnet',
+ },
+ {
+ 'field' : 'ip-subnet',
+ 'type' : 'cidr-range',
+ 'help-name' : 'ip address (10.10.10.10), or cidr (10.20.30.0/24)',
+ 'optional-for-no' : True,
+ 'doc' : 'vns|interface-rule-match-ip-subnet-field',
+ }
+ ),
+}
+
+
+VNS_DEF_IF_MATCH_SWITCH_COMMAND_DESCRIPTION = {
+ 'name' : 'match',
+ 'mode' : 'config-tenant-def-vns-if-rule',
+ 'command-type' : 'config',
+ 'obj-type' : 'vns-interface-rule',
+ 'short-help' : 'Associate switch with interface rule',
+ 'doc' : 'vns|interface-rule-match-switch',
+ 'doc-example' : 'vns|interface-rule-match-switch-example',
+ 'data' : { # for no command reset
+ 'switch' : None,
+ 'ports' : None,
+ },
+ 'args' : (
+ {
+ 'token' : 'switch',
+ },
+ {
+ # constructed as args to ensure that the ports isn't
+ # completed along with swtich values for 'no match switch'
+ 'optional-for-no' : True,
+ 'args' : (
+ {
+ 'field' : 'switch',
+ 'type' : 'string',
+ 'parent-field' : None,
+ 'completion' : [
+ 'complete-object-field',
+ 'complete-alias-choice',
+ ],
+ 'help-name' : 'switch dpid or switch alias',
+ 'data-handler' : 'alias-to-value',
+ 'other' : 'switches|dpid',
+ },
+ {
+ 'field' : 'ports',
+ 'optional' : True,
+ 'type' : 'string',
+ 'help-name' : 'switch interface, or range, or list',
+ 'completion' : 'complete-interface-list',
+ 'data-handler' : 'warn-missing-interface',
+ 'optional-for-no' : True,
+ },
+ ),
+ },
+ ),
+}
+
+
+VNS_DEF_IF_MATCH_TAGS_COMMAND_DESCRIPTION = {
+ 'name' : 'match',
+ 'mode' : 'config-tenant-def-vns-if-rule',
+ 'command-type' : 'config',
+ 'short-help' : 'Associate tags with interface rule',
+ 'doc' : 'vns|interface-rule-match-tag',
+ 'doc-example' : 'vns|interface-rule-match-tag-example',
+ 'data' : { # for no command reset
+ 'tags' : None,
+ },
+ 'args' : (
+ {
+ 'token' : 'tags',
+ },
+ {
+ 'field' : 'tags',
+ 'type' : 'string',
+ 'optional-for-no' : True,
+ }
+ ),
+}
+
+# Remove match vlan command temporarily on gregor's requres
+# the running config can still generate these commands, but
+# they won't get read correctly
+VNS_DEF_IF_MATCH_VLANS_COMMAND_DESCRIPTION = {
+ 'name' : 'match',
+ 'mode' : 'config-tenant-def-vns-if-rule',
+ 'command-type' : 'config',
+ 'short-help' : 'Associate vlans with interface rule',
+ 'doc' : 'vns|interface-rule-match-vlans',
+ 'doc-example' : 'vns|interface-rule-match-vlans-example',
+ 'data' : { # for no command reset
+ 'vlans' : None,
+ },
+ 'args' : (
+ {
+ 'token' : 'vlans',
+ },
+ {
+ 'field' : 'vlans',
+ 'value' : 'string',
+ 'help-name' : 'Vlan number (0-4096) or range, or list',
+ 'optional-for-no' : True,
+ }
+ ),
+}
+
+#
+# ----------------------------------------------------------------------
+# vns submode commands
+#
+
+
+VNS_COMMAND_DESCRIPTION = {
+ 'name' : 'vns',
+ 'short-help' : 'Enter VNS submode, manage access lists',
+ 'mode' : 'config*',
+ 'feature' : 'vns',
+ 'no-supported' : False,
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'vns-definition',
+ 'submode-name' : 'config-tenant-vns',
+ 'syntax-help' : 'Enter a vns name',
+ 'create' : False,
+ 'doc' : 'vns|vns',
+ 'doc-example' : 'vns|vns-example',
+ 'args' : (
+ {
+ 'field' : 'vnsname',
+ 'type' : 'identifier',
+ 'completion' : ['complete-tenantname-preprocess',
+ 'complete-from-another'],
+ 'other' : 'vns-definition|vnsname',
+ 'scoped' : 'tenant',
+ 'syntax-help' : 'Enter a vns name',
+ 'doc' : 'vns|vns-id',
+ 'doc-include' : [ 'type-doc' ],
+ 'action' : (
+ {
+ 'proc' : 'tenant-show-preprocess',
+ },
+ {
+ 'proc' : 'push-mode-stack',
+ }
+ ),
+
+ }
+ )
+}
+
+VNS_INTERFACE_COMMAND_DESCRIPTION = {
+ 'name' : 'interface',
+ 'short-help' : 'Enter VNS-if submode',
+ 'mode' : 'config-tenant-vns*',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'vns-interface-config',
+ 'parent-field' : 'vns',
+ 'current-mode-obj-id' : 'vns-definition',
+ 'submode-name' : 'config-tenant-vns-if',
+ 'syntax-help' : 'Enter an interface name',
+ 'doc' : 'vns|vns-interface',
+ 'doc-example' : 'vns|vns-interface-example',
+ 'args' : (
+ {
+ 'field' : 'interface',
+ 'completion' : 'complete-object-field',
+ 'doc' : 'vns|vns-interface-field',
+ }
+ )
+}
+
+VNS_ACCESS_GROUP_COMMAND_DESCRIPTION = {
+ 'name' : 'access-group',
+ 'short-help' : 'Associate interface with access-list',
+ 'mode' : 'config-tenant-vns-if',
+ 'command-type' : 'config',
+ 'obj-type' : 'vns-interface-access-list',
+ 'parent-field' : 'vns-interface',
+ # 'current-mode-obj-id' : 'vns-definition',
+ 'submode-name' : 'config-tenant-vns-if',
+ 'doc' : 'vns|vns-access-group',
+ 'doc-example' : 'vns|vns-access-group-example',
+ 'args' : (
+ {
+ 'field' : 'vns-access-list',
+ 'type' : 'string',
+ 'completion' : 'complete-from-another',
+ 'other' : 'vns-access-list|name',
+ 'optional-for-no' : False,
+ },
+ {
+ 'field' : 'in-out',
+ 'type' : 'enum',
+ 'values' : ('in', 'out'),
+ 'syntax-help' : 'apply access-list in this direction',
+ 'optional-for-no' : False,
+ 'doc' : 'vns|vns-access-group-direction-+',
+ }
+ ),
+ 'action' : (
+ {
+ 'proc' : 'convert-vns-access-list',
+ },
+ {
+ 'proc' : 'write-object',
+ },
+ ),
+ 'no-action' : (
+ {
+ 'proc' : 'convert-vns-access-list',
+ },
+ {
+ 'proc' : 'delete-objects',
+ },
+ )
+}
+
+SHOW_VNS_ACCESS_GROUP_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'config-tenant-vns-if*',
+ 'action' : 'display-table',
+ 'command-type' : 'display-table',
+ 'scoped' : True, # displayed entries filtered by pushed obj id
+ 'obj-type' : 'vns-interface-access-list',
+ 'short-help' : 'show access-group details',
+ 'args' : (
+ 'access-group',
+ )
+}
+
+
+SHOW_VNS_ACCESS_LIST_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : ['config-tenant-vns-*'],
+ 'short-help' : 'Show VNS access lists',
+ 'action' : 'display-table',
+ 'command-type' : 'display-table',
+ 'obj-type' : 'vns-access-list',
+ 'scoped' : True, # displayed entries filtered by pushed obj id
+ 'args' : (
+ 'access-list',
+ )
+}
+
+SHOW_VNS_INTERFACES_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : ['config-tenant-vns', 'config-tenant-vns-if'],
+ 'short-help' : 'Show VNS associated interfaces',
+ 'doc' : 'vns|vns-show-interface',
+ 'obj-type' : 'vns-interface',
+ 'args' : (
+ {
+ 'token' : 'interfaces',
+ 'scoped' : True,
+ 'action' : ({'proc' : 'tenant-show-preprocess'},
+ 'legacy-cli'),
+ }
+ )
+}
+
+SHOW_VNS_ACCESS_LIST_ENTRY_COMMAND_DESCRIPTION = {
+ 'name' : 'show',
+ 'mode' : 'config-tenant-vns*',
+ 'short-help' : 'show VNS access list rules',
+ 'action' : 'display-table',
+ 'command-type' : 'display-table',
+ 'obj-type' : 'vns-access-list-entry',
+ 'detail' : 'acl-brief',
+ 'args' : (
+ 'access-list-entry',
+ ),
+}
+
+VNS_ACCESS_LIST_COMMAND_DESCRIPTION = {
+ 'name' : 'access-list',
+ 'mode' : 'config-tenant-vns*',
+ 'command-type' : 'config-submode',
+ 'obj-type' : 'vns-access-list',
+ 'parent-field' : 'vns',
+ 'submode-name' : 'config-tenant-vns-acl',
+ 'syntax-help' : 'Enter an access list name',
+ 'short-help' : 'Enter vns access-list submode',
+ 'doc' : 'vns|vns-access-list',
+ 'doc-example' : 'vns|vns-access-list-example',
+ 'args' : (
+ {
+ 'field' : 'name',
+ 'completion' : 'complete-object-field',
+ 'doc' : 'vns|vns-access-list-name'
+ }
+ )
+}
+
+
+VNS_ACCESS_LIST_DESCRIPTION_COMMAND_DESCRIPTION = {
+ 'name' : 'description',
+ 'mode' : 'config-tenant-vns-acl',
+ 'short-help' : 'Provide a description for a VNS access list',
+ 'doc' : 'vns|vns-access-list-description',
+ 'doc-example' : 'vns|vns-access-list-description-example',
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'description',
+ 'type' : 'string',
+ }
+ ),
+}
+
+
+VNS_ACCESS_LIST_PRIORITY_COMMAND_DESCRIPTION = {
+ 'name' : 'priority',
+ 'mode' : 'config-tenant-vns-acl',
+ 'short-help' : 'Set VNS priority',
+ 'doc' : 'vns|vns-access-list-priority',
+ 'doc-example' : 'vns|vns-access-list-priority-example',
+ 'doc-include' : [ 'default', 'range' ],
+ 'command-type' : 'config',
+ 'args' : (
+ {
+ 'field' : 'priority',
+ 'base-type' : 'integer',
+ 'range' : (0, 65535),
+ }
+ )
+}
+
+
+#
+# ----------------------------------------------------------------------
+# vns access list command
+#
+
+SRC_IP_MATCH = {
+ 'choices' : (
+ (
+ {
+ 'field' : 'src-ip',
+ 'type' : 'ip-address-not-mask',
+ 'doc' : 'vns|vns-access-list-ip-and-mask-ip',
+ },
+ {
+ 'field' : 'src-ip-mask',
+ 'type' : 'inverse-netmask',
+ 'data' : {
+ 'dst-ip' : '0.0.0.0',
+ 'dst-ip-mask' : '255.255.255.255',
+ },
+ 'doc' : 'vns|vns-access-list-ip-and-mask-mask',
+ },
+ ),
+ (
+ {
+ 'field' : 'src-ip',
+ 'type' : 'ip-address-not-mask',
+ 'data' : {
+ 'src-ip-mask' : '0.0.0.0',
+ 'dst-ip' : '0.0.0.0',
+ 'dst-ip-mask' : '255.255.255.255',
+ },
+ 'doc' : 'vns|vns-access-list-ip-only',
+ },
+ ),
+ (
+ {
+ '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',
+ 'dst-ip-mask' : '255.255.255.255',
+ },
+ 'doc' : 'vns|vns-access-list-cidr-range',
+ }
+ ),
+ (
+ {
+ 'token' : 'any',
+ 'data' : {
+ 'src-ip' : '0.0.0.0',
+ 'src-ip-mask' : '255.255.255.255',
+ 'dst-ip' : '0.0.0.0',
+ 'dst-ip-mask' : '255.255.255.255',
+ },
+ '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' : 'ip-address-not-mask',
+ 'doc' : 'vns|vns-access-list-ip-and-mask-ip',
+ },
+ {
+ 'field' : 'dst-ip-mask',
+ 'type' : 'inverse-netmask',
+ 'doc' : 'vns|vns-access-list-ip-and-mask-mask',
+ },
+ ),
+ (
+ {
+ 'field' : 'dst-ip',
+ 'type' : 'ip-address-not-mask',
+ 'data' : {
+ 'dst-ip-mask' : '0.0.0.0',
+ },
+ 'doc' : 'vns|vns-access-list-ip-only',
+ },
+ ),
+ (
+ {
+ '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',
+ 'dst-ip-mask' : '255.255.255.255',
+ },
+ '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'
+ },
+ ),
+ }
+)
+
+
+# Unfortunatly, the model defines the compound key using the
+# rule field as a character field, not an integer.
+# Since '00' is then the same rule as '0', two rows could be
+# created describing the same integer rule.
+# Here the character string is normalized.
+# (This may be the result of having a requirement that all fields used to
+# construct compound keys must be character fields)
+#
+# Additionally, for tcp and udp matches, the *tp_port_op needs
+# to be set.
+#
+def vns_normalize_rule(data):
+ data['rule'] = str(int(data['rule']))
+
+ if data.get('type', '') in ['tcp', 'udp']:
+ if not 'src-tp-port-op' in data or data['src-tp-port-op'] == None:
+ data['src-tp-port-op'] = 'any'
+ if not 'dst-tp-port-op' in data or data['dst-tp-port-op'] == None:
+ data['dst-tp-port-op'] = 'any'
+
+
+command.add_action('vns-normalize-rule', vns_normalize_rule,
+ {'kwargs' : { 'data' : '$data' }})
+#
+
+VNS_ACCESS_LIST_ENTRY_COMMAND_DESCRIPTION = {
+ 'name' : { 'type' : 'pattern',
+ 'pattern' : r'\d',
+ 'field' : 'rule',
+ 'title' : '<acl rule number>',
+ 'completion' : 'complete-object-field',
+ 'obj-type' : 'vns-access-list-entry',
+ },
+ 'mode' : 'config-tenant-vns-acl',
+ 'short-help' : 'Define ACL details for this access-list',
+ 'doc' : 'vns|vns-access-list-entry',
+ 'doc-example' : 'vns|vns-access-list-entry-example',
+ 'command-type' : 'config-object',
+ 'parent-field' : 'vns-access-list',
+ 'obj-type' : 'vns-access-list-entry',
+ 'data' : {
+ 'ether-type' : None,
+ 'src-ip' : None,
+ 'src-ip-mask' : None,
+ 'dst-ip' : None,
+ 'dst-ip-mask' : None,
+ 'src-tp-port' : None,
+ 'src-tp-port-op' : None,
+ 'dst-tp-port' : None,
+ 'dst-tp-port-op' : None,
+ 'src-mac' : None,
+ 'dst-mac' : None,
+ 'vlan' : None,
+ 'icmp-type' : None,
+ },
+ 'args' : (
+ {
+ 'field' : 'action',
+ 'type' : 'enum',
+ 'values' : ( 'permit', 'deny' ),
+ 'doc' : 'vns|vns-access-list-entry-action-+',
+ },
+ {
+ '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,
+ },
+ ),
+ },
+ ),
+ (
+ # Only allow the icmp type for icmp syntax
+ # this further increases the syntax complexity
+ {
+ 'field' : 'type',
+ 'type' : 'enum',
+ 'values' : 'icmp',
+ 'doc' : 'vns|vns-access-list-ip-+',
+ },
+ 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,
+ },
+ ),
+ },
+ {
+ 'field' : 'icmp-type',
+ 'optional' : True,
+ 'optional-for-no' : True,
+ 'base-type' : 'hex-or-decimal-integer',
+ 'range' : (0,255),
+ 'data-handler' : 'hex-to-integer',
+ },
+ ),
+ (
+ {
+ 'field' : 'type',
+ 'type' : 'enum',
+ 'values' : 'mac',
+ 'doc' : 'vns|vns-access-list-mac',
+ },
+ {
+ 'choices' : (
+ {
+ 'token' : 'any',
+ },
+ {
+ 'field' : 'src-mac',
+ 'type' : 'host',
+ 'completion' : [ 'complete-alias-choice',
+ ],
+ 'other' : 'host|mac',
+ 'data-handler' : 'alias-to-value',
+ },
+ )
+ },
+ {
+ 'choices' : (
+ {
+ 'token' : 'any',
+ },
+ {
+ 'field' : 'dst-mac',
+ 'type' : 'host',
+ 'completion' : [ 'complete-alias-choice',
+ ],
+ 'other' : 'host|mac',
+ 'data-handler' : 'alias-to-value',
+ },
+ ),
+ },
+ {
+ 'optional' : True,
+ 'choices' : (
+ {
+ 'field' : 'ether-type',
+ 'base-type' : 'hex-or-decimal-integer',
+ 'range' : (1536,65536),
+ 'data-handler' : 'hex-to-integer',
+ 'doc' : 'vns|vns-access-list-ether-type',
+ },
+ {
+ 'field' : 'ether-type',
+ 'type' : 'enum',
+ 'values' : fmtcnv.ether_type_to_number_dict,
+ 'permute' : 'skip'
+ },
+ )
+ },
+ {
+ 'field' : 'vlan',
+ 'tag' : 'vlan',
+ 'base-type' : 'hex-or-decimal-integer',
+ 'range' : (1,4096), # no zero? really?
+ 'data-handler' : 'hex-to-integer',
+ 'optional' : True,
+ 'optional-for-no' : True,
+ },
+ ),
+ )
+ }
+ ),
+ 'action' : (
+ {
+ 'proc' : 'vns-normalize-rule',
+ 'field' : 'rule',
+ },
+ {
+ 'proc' : 'write-object',
+ },
+ ),
+}
+
+VNS_DEFINITION_FORMAT = {
+ 'vns-definition' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'tenant','vnsname', 'active', 'priority', 'arp-mode',
+ 'dhcp-mode', 'dhcp-ip', 'broadcast',
+ 'address-space' ],
+ 'vns-config' : [ 'Idx', 'tenant','vnsname','active', 'priority', 'arp-mode',
+ 'dhcp-mode', 'dhcp-ip', 'broadcast',
+ 'address-space', ],
+ 'brief' : [ 'Idx', 'tenant', 'vnsname', 'address-space', ]
+ },
+ 'fields' : {
+ 'vnsname' : { 'verbose-name' : 'VNS ID',
+ },
+ 'active' : {
+ },
+ 'address-space' : { 'verbose-name' : 'Address Space',
+ },
+ 'priority' : {
+ },
+ 'arp-mode' : { 'verbose-name' : 'ARP Config Mode',
+ },
+ 'dhcp-mode' : { 'verbose-name' : 'DHCP Config Mode' ,
+ },
+ 'dhcp-ip' : { 'verbose-name' : 'DHCP Ip' ,
+ },
+ 'broadcast' : { 'verbose-name' : 'Broadcast Mode' ,
+ },
+ 'address-space' : {
+ 'verbose-name' : 'Address Space',
+ },
+ 'tenant' : {
+ 'verbose-name' : 'Tenant',
+ },
+
+ }
+ },
+}
+
+VNS_INTERFACE_RULE_FORMAT = {
+ 'vns-interface-rule' : {
+ 'field-orderings': {
+ 'default' : [ 'Idx', 'tenant', 'vnsname', 'rule', 'description',
+ 'allow-multiple', 'active', 'priority',
+ 'mac', 'vlans', 'ip-subnet', 'switch', 'ports', 'tags'
+ ],
+ 'vns-config' : [ 'Idx', 'rule', 'description', 'allow-multiple', 'active',
+ 'priority', 'mac', 'vlans', 'ip-subnet', 'switch', 'ports', 'tags'
+ ],
+ },
+ 'fields': {
+ 'rule' : { 'verbose-name' : 'VNS Rule ID',
+ },
+ 'tenant' : {
+ 'verbose-name' : 'Tenant',
+ },
+ 'vnsname' : { 'verbose-name' : 'VNS ID'
+ },
+ 'mac' : {
+ 'formatter' : fmtcnv.print_host_and_alias
+ },
+ 'tags' : {
+ },
+ 'active' : {
+ },
+ 'allow-multiple' : {
+ },
+ 'description' : {
+ },
+ 'ip-subnet' : {
+ },
+ 'ports' : {
+ },
+ 'priority' : {
+ },
+ 'rule' : {
+ },
+ 'switch' : {
+ },
+ 'tags' : {
+ },
+ 'vlans' : {
+ },
+ }
+ },
+}
+
+
+VNS_DISPLAY_VNS_INTERFACE_FORMAT = {
+ 'display-vns-interface' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'tenant', 'vnsname', 'address-space', 'id', 'rule', 'mac', 'vlan',
+ 'ips', 'attachment-points', 'last-seen'],
+ 'vns-config' : ['Idx', 'id', 'rule', 'mac', 'vlan',
+ 'ips', 'attachment-points', 'last-seen']
+ },
+ 'fields': {
+ 'tenant' : {
+ 'verbose-name' : 'Tenant',
+ },
+ 'vnsname' : {
+ 'verbose-name' : 'VNS ID',
+ },
+ 'id' : {
+ },
+ 'rule' : {
+ },
+ 'address-space' : {
+ 'verbose-name' : 'Address Space',
+ },
+ 'mac' : { 'verbose-name' : 'MAC Address',
+ 'formatter' : fmtcnv.print_host_and_alias,
+ },
+ 'vlan' : { 'verbose-name' : 'VLAN',
+ },
+ 'ips' : {
+ 'formatter' : fmtcnv.print_ip_addresses,
+ 'entry-formatter' : fmtcnv.print_all_ip_addresses,
+ },
+ 'attachment-points' : { 'formatter' : fmtcnv.print_host_attachment_point,
+ 'entry-formatter' : fmtcnv.print_all_host_attachment_points,
+ },
+ 'last-seen' : {
+ 'formatter' : fmtcnv.print_time_since_utc_timestr
+ }
+ }
+ },
+}
+
+
+VNS_INTERFACE_DISPLAY_FORMAT = {
+ 'vns-interface-display' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'tenant', 'vnsname', 'address-space', 'id', 'rule', 'mac', 'vlan',
+ 'ips', 'attachment-points', 'last-seen'],
+ 'vns-config' : ['Idx', 'id', 'address-space', 'rule', 'mac', 'vlan',
+ 'ips', 'attachment-points', 'last-seen']
+ },
+ 'fields': {
+ 'id' : {
+ },
+ 'tenant' : {
+ 'verbose-name' : 'Tenant',
+ },
+ 'vnsname' : {
+ 'verbose-name' : 'VNS ID',
+ },
+ 'rule' : {
+ },
+ 'mac' : { 'verbose-name' : 'MAC Address',
+ 'formatter' : fmtcnv.print_host_and_alias,
+ },
+ 'vlan' : { 'verbose-name' : 'VLAN',
+ },
+ 'ips' : {
+ 'formatter' : fmtcnv.print_ip_addresses,
+ 'entry-formatter' : fmtcnv.print_all_ip_addresses,
+ },
+ 'attachment-points' : { 'formatter' : fmtcnv.print_host_attachment_point,
+ 'entry-formatter' : fmtcnv.print_all_host_attachment_points,
+ },
+ 'address-space' : {
+ 'verbose-name' : 'Address Space',
+ },
+ 'last-seen' : {
+ 'formatter' : fmtcnv.print_time_since_utc
+ }
+ }
+ },
+}
+
+
+VNS_INTERFACE_MACS_FORMAT = {
+ 'vns-interface-macs' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'tenant', 'vns', 'address-space',
+ 'veth', 'mac', 'vlan', 'ips', 'tags', 'last-seen'],
+ 'scoped' : [ 'Idx', 'address-space',
+ 'veth', 'mac', 'vlan', 'ips', 'tags', 'last-seen'],
+ },
+ 'fields': {
+ 'veth' : {
+ 'verbose-name' : 'Virtual I/F',
+ },
+ 'tenant' : {
+ 'verbose-name' : 'Tenant',
+ },
+ 'vnsname' : {
+ 'verbose-name': 'VNS ID'
+ },
+ 'mac' : {
+ 'verbose-name' : 'MAC Address',
+ 'formatter' : fmtcnv.print_host_and_alias,
+ },
+ 'vlan' : {
+ 'verbose-name' : 'VLAN',
+ },
+ 'ips' : {
+ 'verbose-name' : 'IP Address',
+ 'formatter' : fmtcnv.print_ip_addresses,
+ 'entry-formatter' : fmtcnv.print_all_ip_addresses,
+ },
+ 'tags' : {
+ },
+ 'address-space' : {
+ 'verbose-name' : 'Address Space',
+ },
+ 'last-seen' : {
+ 'verbose-name' : 'Last Seen',
+ 'formatter' : fmtcnv.print_time_since_utc
+ }
+ }
+ },
+}
+
+
+VNS_INTERFACE_PHYS_FORMAT = {
+ 'vns-interface-phys' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'id', 'address-space', 'switch', 'last-seen' ],
+ },
+
+ 'fields' : {
+ 'id' : { 'formatter' : fmtcnv.print_vns_physical_interface_id,
+ 'verbose-name' : 'Physical I/F',
+ },
+ 'switch' : {
+ 'formatter' : fmtcnv.print_switch_and_alias
+ },
+ 'address-space' : {
+ 'verbose-name' : 'Address Space',
+ },
+ 'last-seen' : {
+ 'verbose-name' : 'Last Seen',
+ 'formatter' : fmtcnv.print_time_since_utc
+ }
+ }
+ },
+}
+
+
+VNS_VNS_SWITCH_PORTS_FORMAT = {
+ 'vns-switch-ports' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'tenant','vns', 'switch', 'port', 'reason' ],
+ },
+
+ 'fields' : {
+ 'tenant' : {
+ 'verbose-name' : 'Tenant',
+ },
+ 'vnsname' : {
+ 'verbose-name' : 'VNS ID',
+ },
+ 'switch' : {
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'port' : {
+ 'verbose-name' : 'OF Port #',
+ 'formatter' : fmtcnv.decode_openflow_port
+ },
+ 'switch-port' : {
+ 'verbose-name' : 'Phy I/F'
+ },
+ 'reason' : {
+ 'formatter' : fmtcnv.print_host_list_and_alias
+ },
+ }
+ },
+}
+
+
+VNS_SWITCH_PORTS_VNS_PORTS_FORMAT = {
+ 'switch-ports-vns' : {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'switch', 'port', 'tenant','vnsname', 'reason' ],
+ },
+
+ 'fields' : {
+ 'tenant' : {
+ 'verbose-name' : 'Tenant',
+ },
+ 'vnsname' : { 'verbose-name' : 'VNS',
+ 'formatter' : fmtcnv.print_vns_count_dict
+ },
+ 'switch' : {
+ 'formatter' : fmtcnv.replace_switch_with_alias
+ },
+ 'port' : {
+ 'verbose-name' : 'OF Port #',
+ 'formatter' : fmtcnv.decode_openflow_port
+ },
+ 'reason' : {
+ 'formatter' : fmtcnv.print_host_list_and_alias
+ },
+ }
+ },
+}
+
+
+VNS_VNS_ACCESS_LIST_FORMAT = {
+ 'vns-access-list': {
+ 'show-this' : [
+ ['vns-access-list', 'default'],
+ ['vns-access-list-entry', 'acl-brief']
+ ],
+
+ 'field-orderings' : {
+ 'default' : [ 'tenant', 'vns', 'name', 'priority', 'description' ],
+ 'vns-config' : [ 'name', 'priority', 'description' ]
+ },
+ 'fields' : {
+ 'name' : {
+ },
+ }
+ },
+}
+
+
+VNS_ACCESS_LIST_ENTRY_FORMAT = {
+ 'vns-access-list-entry': {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'vns', 'vns-access-list', 'rule', 'action', 'type',
+ 'src-ip', 'src-ip-mask',
+ 'dst-ip', 'dst-ip-mask',
+ 'src-tp-port-op', 'src-tp-port',
+ 'dst-tp-port-op', 'dst-tp-port',
+ 'icmp-type',
+ 'src-mac', 'dst-mac', 'ether-type',
+ 'vlan'
+ ],
+ 'vns-config' : ['Idx',
+ 'vns-access-list', 'rule', 'action', 'type',
+ 'src-ip', 'src-ip-mask',
+ 'dst-ip', 'dst-ip-mask' ,
+ 'src-tp-port-op', 'src-tp-port',
+ 'dst-tp-port-op', 'dst-tp-port',
+ 'icmp-type',
+ 'src-mac', 'dst-mac', 'ether-type',
+ 'vlan'
+ ],
+ 'acl-brief' : ['vns-access-list', 'rule', 'action', 'type', 'acl-text'
+ ],
+ 'scoped-acl-brief' : [ 'rule', 'action', 'type', 'acl-text'
+ ],
+ },
+ 'fields' : {
+ #
+ # vns-acl-entry fields are a bit uncommon. the action and type
+ # can only be configured via the create portion of the command,
+ # while many other fields requre specific validation so that
+ # alternate values can be replaced for some keywords
+ #
+ # the values of the 'validate' field is the name of the
+ # def to call (in the SDNSh class)
+ #
+ 'vns-access-list' : { 'verbose-name' : 'Acl'
+ },
+ 'rule' : { 'verbose-name' : 'Seq',
+ },
+ 'action' : { 'verbose-name' : 'Action',
+ },
+ 'type' : { 'verbose-name' : 'Type',
+ },
+ 'src-ip' : {
+ 'verbose-name' : 'Src-Ip'
+ },
+ 'src-ip-mask' : {
+ 'verbose-name' : 'Src-Ip-Mask'
+ },
+ 'dst-ip' : {
+ 'verbose-name' : 'Dst-Ip' },
+ 'dst-ip-mask' : {
+ 'verbose-name' : 'Dst-Ip-Mask' },
+ 'src-tp-port-op' : {
+ 'verbose-name' : 'Src-Port-Op' },
+ 'src-tp-port' : {
+ 'verbose-name' : 'Src-Port' },
+ 'dst-tp-port-op' : {
+ 'verbose-name' : 'Dst-Port-Op' },
+ 'dst-tp-port' : {
+ 'verbose-name' : 'Dst-Port' },
+ 'icmp-type' : {
+ },
+ 'ether-type' : {
+ },
+ 'vns' : {
+ 'verbose-name' : 'VNS ID',
+ }
+ }
+ },
+}
+
+
+VNS_INTERFACE_ACCESS_LIST_FORMAT = {
+ 'vns-interface-access-list': {
+ 'field-orderings' : {
+ 'default' : [ 'Idx', 'vnsname', 'vns-interface', 'name', 'in-out' ],
+ 'vns-config': [ 'Idx', 'vns-interface', 'name', 'in-out' ]
+ },
+ 'fields' : {
+ 'vnsname' : {
+ 'verbose-name' : 'VNS ID',
+ },
+ 'vns-interface-name' : {
+ 'verbose-name' : 'VNS Interface ID',
+ },
+ 'name' : {
+ 'verbose-name' : 'VNS Acl name',
+ },
+ }
+ },
+}
+
+
+VNS_INTERFACE_FORMAT = {
+ 'vns-interface' : {
+ 'field-orderings' : {
+ 'default' : ['Idx', 'vns', 'address-space', 'interface', 'rule', 'last-seen', ],
+ 'vns-config' : ['Idx', 'address-space', 'interface', 'rule', 'last-seen', ]
+ },
+ 'fields' : {
+ 'id' : {
+ 'verbose-name': 'ID',
+ },
+ 'vns' : {
+ 'verbose-name': 'VNS ID'
+ },
+ 'interface' : {
+ 'verbose-name': 'VNS Interface Name',
+ },
+ 'rule' : {
+ 'verbose-name': 'VNS Rule ID',
+ },
+ 'address-space' : {
+ 'verbose-name' : 'Address Space',
+ },
+ 'last-seen' : {
+ 'verbose-name': 'Last Seen',
+ 'formatter' : fmtcnv.timestamp_to_local_timestr,
+ },
+ }
+ },
+}
+"""
\ No newline at end of file
diff --git a/cli/desc/version200/vns_model.py b/cli/desc/version200/vns_model.py
new file mode 100755
index 0000000..3f8f2f3
--- /dev/null
+++ b/cli/desc/version200/vns_model.py
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import command
+
+command.model_obj_type_disable_submode('vns-interface-config')
+command.model_obj_type_disable_submode('vns-access-list-entry')
+
+command.model_obj_type_disable_submode('vns-interface-rule-network-service-node-mapping')
+
+command.model_obj_type_disable_edit('vns-definition', 'description')
+command.model_obj_type_disable_edit('vns-definition', 'origin')
+command.model_obj_type_disable_edit('vns-definition', 'priority')
+command.model_obj_type_disable_edit('vns-definition', 'vnsname')
+command.model_obj_type_disable_edit('vns-definition', 'tenant')
+
+
+command.model_obj_type_disable_edit('vns-access-list', 'priority')
+command.model_obj_type_disable_edit('vns-access-list', 'description')
+
+command.model_obj_type_set_show_this('vns-access-list', [
+ ['vns-access-list', 'vns-access-list', 'default' ],
+ ['vns-access-list-entry', 'vns-access-list-entry', 'scoped-acl-brief' ],
+ ])
+
+command.model_obj_type_set_title('vns-access-list-entry', 'Access List Rules')
diff --git a/cli/desc/version200/vns_techsupport.py b/cli/desc/version200/vns_techsupport.py
new file mode 100755
index 0000000..35086b4
--- /dev/null
+++ b/cli/desc/version200/vns_techsupport.py
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2012,2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+from tech_support import add_to_show_tech_support
+
+# VNS commands to be included in 'show tech-support' output
+vns_show_tech_support_commands = [
+ ['cli', 'show vns all'],
+ ['cli', 'show vns all interfaces'],
+ ['cli', 'show vns all switch'],
+ ['cli', 'show vns all mac-address-table'],
+ ['cli', 'show vns all flow'],
+]
+
+# add commands to central command table used for 'show tech-support'
+for entry in vns_show_tech_support_commands:
+ add_to_show_tech_support(str(entry[0]), str(entry[1]), 'vns')