-
Notifications
You must be signed in to change notification settings - Fork 16
CLI skeleton for Port channel #134
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
Changes from 3 commits
fffeffc
006737e
2fb01d0
7a257f7
4474149
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 |
---|---|---|
|
@@ -96,6 +96,28 @@ limitations under the License. | |
</ACTION> | ||
</COMMAND> | ||
|
||
<COMMAND | ||
name="show port-channel" | ||
help="Show vlan commands" | ||
ptype="SUBCOMMAND" | ||
mode="subcommand" | ||
> | ||
<PARAM | ||
name="lag-id" | ||
help="PortChannel identifier" | ||
ptype="UINT" | ||
optional="true" | ||
> | ||
</PARAM> | ||
<ACTION> | ||
if test "${lag-id}" = ""; then
 | ||
python $SONIC_CLI_ROOT/sonic-cli-if.py get_openconfig_interfaces_interfaces PortChannel show_portchannel.j2
 | ||
else
 | ||
python $SONIC_CLI_ROOT/sonic-cli-if.py get_openconfig_if_aggregate_interfaces_interface_aggregation_state PortChannel${lag-id} show_portchannel_id.j2#xA; | ||
fi | ||
</ACTION> | ||
</COMMAND> | ||
|
||
</VIEW> | ||
|
||
<VIEW | ||
|
@@ -139,6 +161,23 @@ limitations under the License. | |
<ACTION builtin="clish_nop"></ACTION> | ||
</COMMAND> | ||
|
||
<COMMAND | ||
name="interface port-channel" | ||
help="port-channel Interface Configuration" | ||
mode="subcommand" | ||
ptype="SUBCOMMAND" | ||
view="configure-lag-view" | ||
viewid="po_id=po${lag-id}" | ||
> | ||
<PARAM | ||
name="lag-id" | ||
help="port-channel identifier(1-128)" | ||
ptype="UINT" | ||
> | ||
</PARAM> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface PortChannel${lag-id}</ACTION> | ||
</COMMAND> | ||
|
||
<!-- no interface commands --> | ||
<COMMAND | ||
name="no interface" | ||
|
@@ -162,10 +201,23 @@ limitations under the License. | |
ptype="VLAN_ID" | ||
/> | ||
</PARAM> | ||
<PARAM | ||
name="port-channel" | ||
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. Before merging, need one thing to get clarified. "port-channel" is represented as PortChannel in Kernel, so need to get confirmation on what naming convention we go for interface name commands. Say for Interface, we go as Ethernet . I guess it would be better to go with the same name for CLI command. Let me confirm with Joyas, will get back soon. 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. Just talked with @joyas-joseph , lets have the name "PortChannel" (name used in Kernel) to be consistent across all the CLI. Sorry for not pointing this out earlier. I did it wrong for vlan too, I will fix it. |
||
help="Delete port-channel" | ||
mode="subcommand" | ||
ptype="SUBCOMMAND" | ||
> | ||
<PARAM | ||
name="lag-id" | ||
help="port-channel identifier(1-128)" | ||
ptype="UINT" | ||
/> | ||
</PARAM> | ||
</PARAM> | ||
<ACTION builtin="clish_nop"></ACTION> | ||
</COMMAND> | ||
</VIEW> | ||
|
||
<VIEW | ||
name="configure-if-view" | ||
prompt="${SYSTEM_NAME}(conf-if-${iface})# " | ||
|
@@ -209,6 +261,20 @@ limitations under the License. | |
help="Remove MTU"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_mtu ${iface} 9100 </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="channel-group" | ||
help="Configure port channel parameters"> | ||
<PARAM | ||
name="lag-id" | ||
help="Specify a port channel number" | ||
ptype="UINT" /> | ||
Tejaswi-Goel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_if_aggregate_interfaces_interface_ethernet_config_aggregate_id ${iface} ${lag-id} </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="no channel-group" | ||
help="Remove from port channel group"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py delete_openconfig_if_aggregate_interfaces_interface_ethernet_config_aggregate_id ${iface} </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="shutdown" | ||
help="Disable the interface"> | ||
|
@@ -350,5 +416,86 @@ limitations under the License. | |
completion="false" | ||
/> | ||
</VIEW> | ||
<VIEW | ||
name="configure-lag-view" | ||
prompt="${SYSTEM_NAME}(conf-if-${po_id})# " | ||
depth="2" | ||
> | ||
<!-- Inheritance --> | ||
<NAMESPACE | ||
ref="configure-view" | ||
help="false" | ||
completion="false" | ||
/> | ||
|
||
<COMMAND | ||
name="no" | ||
help="Negate a command or set its defaults" | ||
/> | ||
<COMMAND | ||
name="min-links" | ||
help="Configure the minimum number of links in a port-channel"> | ||
<PARAM | ||
name="min-links" | ||
help="Configure the minimum number of links in a port-channel" | ||
ptype="UINT" /> | ||
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. Do we know max. no. of ports that can be added to port-channel? |
||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_if_aggregate_interfaces_interface_aggregation_config_min_links ${po_id} ${min-links} </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="no min-links" | ||
help="Default the minimum number of links in a port channel" > | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_if_aggregate_interfaces_interface_aggregation_config_min_links ${po_id} 1 </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="mtu" | ||
help="Configure MTU"> | ||
<PARAM | ||
name="mtu" | ||
help="MTU of the interface" | ||
ptype="RANGE_MTU" /> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_mtu ${po_id} ${mtu} </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="no mtu" | ||
help="Remove MTU"> | ||
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface_config_mtu ${po_id} 9100 </ACTION> | ||
</COMMAND> | ||
<COMMAND | ||
name="shutdown" | ||
help="Disable the interface"> | ||
</COMMAND> | ||
<COMMAND | ||
name="no shutdown" | ||
help="Enable the interface"> | ||
</COMMAND> | ||
<COMMAND | ||
name="ip" | ||
help="Interface Internet Protocol config commands" | ||
/> | ||
<COMMAND | ||
name="no ip" | ||
help="Interface Internet Protocol config commands" | ||
> | ||
</COMMAND> | ||
|
||
<COMMAND | ||
name="ip address" | ||
help="IP address" > | ||
<PARAM | ||
name="addr" | ||
help="IP address with mask" | ||
ptype="IP_ADDR_MASK" /> | ||
</COMMAND> | ||
|
||
<COMMAND | ||
name="no ip address" | ||
help="Interface Internet Protocol config commands" | ||
> | ||
<PARAM | ||
name="addr" | ||
help="IP address" | ||
ptype="IP_ADDR" /> | ||
</COMMAND> | ||
</VIEW> | ||
</CLISH_MODULE> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% set just_var = 2 %} | ||
|
||
Flags: A - Active, Dw - Oper status down | ||
Tejaswi-Goel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{{'----------------------------------------------------------------------------------------------------------------------------'}} | ||
{{'%-20s'|format("Port-Channel")}}{{'%-20s'|format("min-links")}}{{'%-20s'|format("Protocol")}}{{'%-15s'|format("MTU")}}{{'%-15s'|format("Admin")}}{{'%-15s'|format("port-members")}} | ||
{{'----------------------------------------------------------------------------------------------------------------------------'}} | ||
{% for dict in json_output['openconfig-interfaces:interface'] %} | ||
{{'%-20s'|format(dict['name']|string)}}{{'%-20s'|format(dict['min-links'])}}{{'%-20s'|format("LACP(A)(Dw)")}}{{'%-15s'|format(dict['mtu'])}}{{'%-15s'|format(dict['admin_status'])}}{{'%-15s'|format(dict['members']|string|replace("[", "")|replace("]", ""))}} | ||
{% endfor %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% set just_var = 2 %} | ||
|
||
Flags: A - Active, Dw - Oper status down | ||
{{'----------------------------------------------------------------------------------------------------------------------------'}} | ||
{{'%-20s'|format("Port-Channel")}}{{'%-20s'|format("min-links")}}{{'%-20s'|format("Protocol")}}{{'%-15s'|format("MTU")}}{{'%-15s'|format("Admin")}}{{'%-15s'|format("port-members")}} | ||
{{'----------------------------------------------------------------------------------------------------------------------------'}} | ||
{% set dict = json_output %} | ||
{{'%-20s'|format(dict['name']|string)}}{{'%-20s'|format(dict['min-links'])}}{{'%-20s'|format("LACP(A)")}}{{'%-15s'|format(dict['mtu'])}}{{'%-15s'|format(dict['admin_status'])}}{{'%-15s'|format(dict['members']|string|replace("[", "")|replace("]", ""))}} |
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.
Example, it has to be interface PortChannel