-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI skeletion for VLAN feature: config, show and its templates #129
Changes from 2 commits
2fdee4b
77a8dff
da35b70
4cdb8c5
d5d6b80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,31 +35,31 @@ limitations under the License. | |
ptype="SUBCOMMAND" | ||
> | ||
<PARAM | ||
name="counters" | ||
help="Counters for Physical Interfaces" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
</PARAM> | ||
name="counters" | ||
help="Counters for Physical Interfaces" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
</PARAM> | ||
<PARAM | ||
name="Ethernet" | ||
help="Physical Interface" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="Ethernet" | ||
help="Physical Interface" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="phy-if-id" | ||
help="Physical interface(Multiples of 4)" | ||
ptype="UINT" | ||
ptype="UINT" | ||
optional="true" | ||
> | ||
</PARAM> | ||
</PARAM> | ||
</PARAM> | ||
<PARAM | ||
name="status" | ||
help="Physical interfaces status" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
name="status" | ||
help="Physical interfaces status" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
</PARAM> | ||
</PARAM> | ||
|
@@ -77,33 +77,92 @@ limitations under the License. | |
fi | ||
</ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="show vlan" | ||
help="show vlan commands" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="id" | ||
help="vlan identifier" | ||
ptype="VLAN_ID" | ||
optional="true" | ||
> | ||
</PARAM> | ||
<ACTION> | ||
python $SONIC_CLI_ROOT/sonic-cli-if.py get_openconfig_vlan_interfaces_interface_ethernet_switched_vlan_state show_vlan.j2 | ||
</ACTION> | ||
</COMMAND> | ||
|
||
</VIEW> | ||
|
||
<VIEW | ||
name="configure-view" | ||
> | ||
<!-- interface commands --> | ||
<COMMAND | ||
name="interface" | ||
help="Select an interface" | ||
/> | ||
|
||
<COMMAND | ||
name="interface" | ||
name="interface Ethernet" | ||
help="Select an interface" | ||
view="configure-if-view" | ||
viewid="iface=Ethernet${phy-if-name}" | ||
> | ||
<PARAM | ||
name="Ethernet" | ||
help="Interface commands" | ||
mode="subcommand" | ||
ptype="SUBCOMMAND" | ||
> | ||
<PARAM | ||
name="phy-if-name" | ||
help="Physical interface(Multiples of 4)" | ||
ptype="UINT" | ||
view="configure-if-view" | ||
viewid="iface=Ethernet${phyifname}" | ||
/> | ||
</PARAM> | ||
<ACTION builtin="clish_nop"></ACTION> | ||
</COMMAND> | ||
> | ||
<PARAM | ||
name="phy-if-name" | ||
help="Physical interface(Multiples of 4)" | ||
ptype="UINT" | ||
> | ||
</PARAM> | ||
<ACTION builtin="clish_nop"></ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="interface vlan" | ||
help="Vlan Interface Configuration" | ||
mode="subcommand" | ||
ptype="SUBCOMMAND" | ||
view="configure-vlan-view" | ||
viewid="vlan_id=vlan${vlan-id}" | ||
> | ||
<PARAM | ||
name="vlan-id" | ||
help="Vlan identifier(1-4094)" | ||
ptype="UINT" | ||
> | ||
</PARAM> | ||
<ACTION builtin="clish_nop"></ACTION> | ||
</COMMAND> | ||
|
||
<!-- no interface commands --> | ||
<COMMAND | ||
name="no interface" | ||
help="Delete interface" | ||
> | ||
<PARAM | ||
name="if-subcommands" | ||
help="Interface sub-commands" | ||
mode="switch" | ||
ptype="SUBCOMMAND" | ||
> | ||
<PARAM | ||
name="vlan" | ||
help="Delete vlan" | ||
mode="subcommand" | ||
ptype="SUBCOMMAND" | ||
> | ||
<PARAM | ||
name="vlan-id" | ||
help="Vlan identifier(1-4094)" | ||
ptype="UINT" | ||
/> | ||
</PARAM> | ||
</PARAM> | ||
<ACTION builtin="clish_nop"></ACTION> | ||
</COMMAND> | ||
</VIEW> | ||
<VIEW | ||
name="configure-if-view" | ||
|
@@ -120,17 +179,7 @@ limitations under the License. | |
name="no" | ||
help="Negate a command or set its defaults" | ||
/> | ||
<COMMAND | ||
name="shutdown" | ||
help="Disable the interface"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_enabled ${iface} False </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="no shutdown" | ||
help="Enable the interface"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_enabled ${iface} True </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
<COMMAND | ||
name="description" | ||
help="Textual description"> | ||
<PARAM | ||
|
@@ -153,11 +202,151 @@ limitations under the License. | |
ptype="RANGE_MTU" /> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_mtu ${iface} ${mtu} </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
<COMMAND | ||
name="no mtu" | ||
help="Remove MTU"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_mtu ${iface} 9100 </ACTION> | ||
</COMMAND> | ||
</VIEW> | ||
<COMMAND | ||
name="shutdown" | ||
help="Disable the interface"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_enabled ${iface} False </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="no shutdown" | ||
help="Enable the interface"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_enabled ${iface} True </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="switchport" | ||
help="Configure switchport parameters" | ||
> | ||
<PARAM | ||
name="switchport-subcommands" | ||
help="Switchport subcommands" | ||
ptype="SUBCOMMAND" | ||
mode="switch" | ||
> | ||
<PARAM | ||
name="access" | ||
help="Set access mode characteristics of the interface" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="vlan" | ||
help="Set VLAN when interface is in access mode" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="vlan-id" | ||
help="VLAN ID of the VLAN when this port is in access mode" | ||
ptype="UINT" | ||
> | ||
</PARAM> | ||
</PARAM> | ||
</PARAM> | ||
|
||
<PARAM | ||
name="trunk" | ||
help="Configure trunking parameters on an interface" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="allowed" | ||
help="Configure trunking parameters on an interface" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="vlan" | ||
help="Configure trunking parameters on an interface" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="vlan-id" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix the help string...it should say trunk mode. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
help="VLAN ID of the VLAN when this port is in access mode" | ||
ptype="UINT" | ||
> | ||
</PARAM> | ||
</PARAM> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the alignment...it's hard to see the tag completions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
</PARAM> | ||
</PARAM> | ||
</PARAM> | ||
<ACTION builtin="clish_nop"></ACTION> | ||
</COMMAND> | ||
|
||
<COMMAND | ||
name="no switchport" | ||
help="Remove switchport parameters" | ||
> | ||
<PARAM | ||
name="switchport-subcommands" | ||
help="Switchport subcommands" | ||
ptype="SUBCOMMAND" | ||
mode="switch" | ||
> | ||
<PARAM | ||
name="access" | ||
help="Remove access mode characteristics of the interface" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="vlan" | ||
help="Remove VLAN when interface is in access mode" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
</PARAM> | ||
</PARAM> | ||
|
||
<PARAM | ||
name="trunk" | ||
help="Remove trunking parameters on an interface" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it possible to add this as the MACRO? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will take care of it in the final PR. |
||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="allowed" | ||
help="Remove trunking parameters on an interface" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="vlan" | ||
help="Remove trunking parameters on an interface" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="vlan-id" | ||
help="VLAN ID of the VLAN when this port is in access mode" | ||
ptype="UINT" | ||
> | ||
</PARAM> | ||
</PARAM> | ||
</PARAM> | ||
</PARAM> | ||
</PARAM> | ||
<ACTION builtin="clish_nop"></ACTION> | ||
</COMMAND> | ||
</VIEW> | ||
|
||
<VIEW | ||
name="configure-vlan-view" | ||
prompt="${SYSTEM_NAME}(conf-if-${vlan_id})# " | ||
depth="2" | ||
> | ||
<!-- Inheritance --> | ||
<NAMESPACE | ||
ref="configure-view" | ||
help="false" | ||
completion="false" | ||
/> | ||
</VIEW> | ||
</CLISH_MODULE> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% set vars = {'vlanName': ""} %} | ||
{% set vars = {'ifName': ""} %} | ||
{% set vars = {'tagMode': ""} %} | ||
{% set vars = {'tagLetter': ""} %} | ||
{% if json_output -%} | ||
Q: A - Access (Untagged), T - Tagged | ||
{{'%-11s'|format("NUM")}}{{'%-2s'|format("Q Ports")}} | ||
{% for vlanKey, memberEntries in json_output.items() %} | ||
{% if vars.update({'vlanName':vlanKey}) %}{% endif %} | ||
{% for ifKey, ifMode in memberEntries.items() %} | ||
{% if vars.update({'ifName':ifKey}) %}{% endif %} | ||
{% if vars.update({'tagMode':ifMode}) %}{% endif %} | ||
{% if ifMode == "untagged" %} | ||
{% if vars.update({'tagLetter':" U "}) %}{% endif %} | ||
{% else %} | ||
{% if vars.update({'tagLetter':" T "}) %}{% endif %} | ||
{% endif %} | ||
{{'%-10s'|format(vars.vlanName)}}{{'%-2s'|format(vars.tagLetter)}}{{'%-10s'|format(vars.ifName)}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may have to use short form of interface (e.g Eth0 instead of Ethernet0 but this conflicts with "mgmt intf"), we should have the logic to combine multiple intfs in a range and show here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I have considered that behavior similar to what we have in OS10. Need more time to investigate inorder to figure it out,I will handle it later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make sure we follow the below format for "show vlan" output, for example, instead of Vlan100, use just 100 under Num column. S6K-12# show vlan
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, will take care of it. Earlier, we didn't had oper-status support.
|
||
{% if vars.update({'vlanName':''}) %}{% endif %} | ||
{% endfor %} | ||
{% endfor %} | ||
{% endif %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason for not using VLAN_ID ptype?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed