Skip to content
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

[config] Add 'interface transceiver' subgroup with 'lpmode' and 'reset' subcommands #904

Merged
merged 4 commits into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,57 @@ def remove(ctx, interface_name, ip_addr):
except ValueError:
ctx.fail("'ip_addr' is not valid.")

#
# 'transceiver' subgroup ('config interface transceiver ...')
#

@interface.group(cls=AbbreviationGroup)
@click.pass_context
def transceiver(ctx):
"""SFP transceiver configuration"""
pass

#
# 'lpmode' subcommand ('config interface transceiver lpmode ...')
#

@transceiver.command()
@click.argument('interface_name', metavar='<interface_name>', required=True)
@click.argument('state', metavar='(enable|disable)', type=click.Choice(['enable', 'disable']))
@click.pass_context
def lpmode(ctx, interface_name, state):
"""Enable/disable low-power mode for SFP transceiver module"""
if get_interface_naming_mode() == "alias":
interface_name = interface_alias_to_name(interface_name)
if interface_name is None:
ctx.fail("'interface_name' is None!")

if interface_name_is_valid(interface_name) is False:
ctx.fail("Interface name is invalid. Please enter a valid interface name!!")

cmd = "sudo sfputil lpmode {} {}".format("on" if state == "enable" else "off", interface_name)
run_command(cmd)

#
# 'reset' subcommand ('config interface reset ...')
#

@transceiver.command()
@click.argument('interface_name', metavar='<interface_name>', required=True)
@click.pass_context
def reset(ctx, interface_name):
"""Reset SFP transceiver module"""
if get_interface_naming_mode() == "alias":
interface_name = interface_alias_to_name(interface_name)
if interface_name is None:
ctx.fail("'interface_name' is None!")

if interface_name_is_valid(interface_name) is False:
ctx.fail("Interface name is invalid. Please enter a valid interface name!!")

cmd = "sudo sfputil reset {}".format(interface_name)
run_command(cmd)

#
# 'vrf' subgroup ('config interface vrf ...')
#
Expand Down
42 changes: 41 additions & 1 deletion doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2501,7 +2501,7 @@ This sub-section explains the following list of configuration on the interfaces.

From 201904 release onwards, the “config interface” command syntax is changed and the format is as follows:

- config interface interface_subcommand <interface_name>
- config interface interface_subcommand <interface_name>
i.e Interface name comes after the subcommand
- Ex: config interface startup Ethernet63

Expand Down Expand Up @@ -2667,6 +2667,7 @@ This command is used to administratively shut down either the Physical interface
*Versions <= 201811*
```
config interface <interface_name> shutdown (for 201811- version)
```

- Example:

Expand Down Expand Up @@ -2694,6 +2695,7 @@ This command is used for administratively bringing up the Physical interface or
*Versions <= 201811*
```
config interface <interface_name> startup (for 201811- version)
```

- Example:

Expand Down Expand Up @@ -2732,6 +2734,44 @@ Dynamic breakout feature is yet to be supported in SONiC and hence uses cannot c
- Example (Versions <= 201811):
```
admin@sonic:~$ sudo config interface Ethernet63 speed 40000

```

**config interface transceiver lpmode**

This command is used to enable or disable low-power mode for an SFP transceiver

- Usage:

```
config interface transceiver lpmode <interface_name> (enable | disable)
```

- Examples:

```
user@sonic~$ sudo config interface transceiver lpmode Ethernet0 enable
Enabling low-power mode for port Ethernet0... OK

user@sonic~$ sudo config interface transceiver lpmode Ethernet0 disable
Disabling low-power mode for port Ethernet0... OK
```

**config interface transceiver reset**

This command is used to reset an SFP transceiver

- Usage:

```
config interface transceiver reset <interface_name>
```

- Examples:

```
user@sonic~$ sudo config interface transceiver reset Ethernet0
Resetting port Ethernet0... OK
```

**config interface mtu <interface_name> (Versions >= 201904)**
Expand Down