Skip to content

Commit

Permalink
Changes in show port-channel command
Browse files Browse the repository at this point in the history
Signed-off-by: Tejaswi Goel <[email protected]>
  • Loading branch information
Tejaswi-Goel committed Sep 28, 2019
1 parent 2fb01d0 commit e15b277
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 82 deletions.
78 changes: 36 additions & 42 deletions src/CLI/actioner/sonic-cli-if.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,50 +101,44 @@ def run(func, args):
if "PortChannel" in args[0] and func.__name__ == 'patch_openconfig_interfaces_interfaces_interface':
return

dummy_data= {
"openconfig-interfaces:interface": [
{
"members": [
"Ethernet56",
"Ethernet60"
],
"min-links": 2,
"mtu": 9100,
"admin_status": "up",
"oper_status": "down",
"name": "PortChannel1"
},
{
"members": [],
"min-links": 1,
"mtu": 9100,
"admin_status": "up",
"oper_status": "down",
"name": "PortChannel2"
},
{
"members": [],
"min-links": 1,
"mtu": 9100,
"admin_status": "up",
"oper_status": "down",
"name": "PortChannel3"
}
]
}

#show given port-channel details
if "PortChannel" in args[0] and func.__name__ == 'get_openconfig_if_aggregate_interfaces_interface_aggregation_state':
for dict in dummy_data['openconfig-interfaces:interface']:
if dict["name"] == "PortChannel3":
show_cli_output("show_portchannel_id.j2", dict)
return
print("%Error: Entry not found")
return

#show port-channels summary
if "PortChannel" in args[0] and func.__name__ == 'get_openconfig_interfaces_interfaces':
show_cli_output("show_portchannel.j2", dummy_data)

dummy_resp= {
"PORTCHANNEL": [
{
"members": [
"Ethernet56",
"Ethernet60"
],
"min-links": 2,
"mtu": 9100,
"admin_status": "up",
"oper_status": "down",
"name": "PortChannel1",
"id": "1"
},
{
"members": [],
"min-links": 1,
"mtu": 9100,
"admin_status": "up",
"oper_status": "down",
"name": "PortChannel12",
"id": "12"
},
{
"members": [],
"min-links": 1,
"mtu": 9100,
"admin_status": "up",
"oper_status": "down",
"name": "PortChannel3",
"id": "3"
}
]
}
show_cli_output(args[1], dummy_resp)
return

#add members to port-channel
Expand Down
62 changes: 34 additions & 28 deletions src/CLI/clitree/cli-xml/interface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,15 @@ limitations under the License.

<COMMAND
name="show port-channel"
help="Show vlan commands"
help="LAG status and configuration"
ptype="SUBCOMMAND"
mode="subcommand"
>
<PARAM
name="lag-id"
help="PortChannel identifier"
ptype="UINT"
optional="true"
>
</PARAM>
<ACTION>
if test "${lag-id}" = ""; then&#xA;
python $SONIC_CLI_ROOT/sonic-cli-if.py get_openconfig_interfaces_interfaces PortChannel show_portchannel.j2&#xA;
else&#xA;
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
mode="subcommand" />
<COMMAND
name="show port-channel summary"
help="LAG status and configurationn"
mode="subcommand">
<ACTION>
python $SONIC_CLI_ROOT/sonic-cli-if.py get_openconfig_interfaces_interfaces PortChannel show_portchannel.j2
</ACTION>
</COMMAND>

Expand Down Expand Up @@ -163,16 +155,16 @@ limitations under the License.

<COMMAND
name="interface port-channel"
help="port-channel Interface Configuration"
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"
help="PortChannel identifier(1-128)"
ptype="LAG_ID"
>
</PARAM>
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_interfaces_interfaces_interface PortChannel${lag-id}</ACTION>
Expand Down Expand Up @@ -210,7 +202,7 @@ limitations under the License.
<PARAM
name="lag-id"
help="port-channel identifier(1-128)"
ptype="UINT"
ptype="LAG_ID"
/>
</PARAM>
</PARAM>
Expand Down Expand Up @@ -261,14 +253,25 @@ 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"
ptype="SUBCOMMAND"
mode="subcommand"/>
<COMMAND
name="channel-group mode"
help="Set the LACP actor mode"
mode="subcommand"
ptype="SUBCOMMAND" />
<COMMAND
name="channel-group"
help="Configure port channel parameters">
<PARAM
name="lag-id"
name="channel-group mode active"
help="Channeling mode by default set to ACTIVE">
<PARAM
name="lag-id"
help="Specify a port channel number"
ptype="UINT" />
<ACTION>python $SONIC_CLI_ROOT/sonic-cli-if.py patch_openconfig_if_aggregate_interfaces_interface_ethernet_config_aggregate_id ${iface} ${lag-id} </ACTION>
ptype="LAG_ID"/>
<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"
Expand Down Expand Up @@ -438,7 +441,7 @@ limitations under the License.
<PARAM
name="min-links"
help="Configure the minimum number of links in a port-channel"
ptype="UINT" />
ptype="MIN_LINK" />
<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
Expand All @@ -463,10 +466,12 @@ limitations under the License.
<COMMAND
name="shutdown"
help="Disable the interface">
<ACTION builtin="clish_nop"></ACTION>
</COMMAND>
<COMMAND
name="no shutdown"
help="Enable the interface">
<ACTION builtin="clish_nop"></ACTION>
</COMMAND>
<COMMAND
name="ip"
Expand All @@ -477,14 +482,14 @@ limitations under the License.
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" />
<ACTION builtin="clish_nop"></ACTION>
</COMMAND>

<COMMAND
Expand All @@ -495,6 +500,7 @@ limitations under the License.
name="addr"
help="IP address"
ptype="IP_ADDR" />
<ACTION builtin="clish_nop"></ACTION>
</COMMAND>
</VIEW>
</CLISH_MODULE>
Expand Down
14 changes: 14 additions & 0 deletions src/CLI/clitree/cli-xml/sonic_types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ limitations under the License.
help=""
/>
<!--=======================================================-->
<PTYPE
name="LAG_ID"
method="integer"
pattern="0..9999"
help=""
/>
<!--=======================================================-->
<PTYPE
name="MIN_LINK"
method="integer"
pattern="1..255"
help=""
/>
<!--=======================================================-->
<PTYPE
name="UNIT_ID"
method="integer"
Expand Down
9 changes: 5 additions & 4 deletions src/CLI/renderer/templates/show_portchannel.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% set just_var = 2 %}
Flags: D - Down
U - Up (port-channel)

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")}}
{{'%-20s'|format("Group")}}{{'%-30s'|format("Port-Channel")}}{{'%-20s'|format("Type")}}{{'%-15s'|format("Protocol")}}{{'%-15s'|format("Member Ports")}}
{{'----------------------------------------------------------------------------------------------------------------------------'}}
{% 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("]", ""))}}
{% for dict in json_output['PORTCHANNEL'] %}
{{'%-20s'|format(dict['id']|string)}}{{'%-18s'|format(dict['name'])}}{{'%-12s'|format("(D)")}}{{'%-20s'|format("Eth")}}{{'%-15s'|format("LACP")}}{{'%-15s'|format(dict['members']|string|replace("[", "")|replace("]", ""))}}
{% endfor %}
8 changes: 0 additions & 8 deletions src/CLI/renderer/templates/show_portchannel_id.j2

This file was deleted.

0 comments on commit e15b277

Please sign in to comment.