Skip to content

Commit

Permalink
[config] Add 'interface transceiver' subgroup with 'lpmode' and 'rese…
Browse files Browse the repository at this point in the history
…t' subcommands (#904)
  • Loading branch information
jleveque authored and abdosi committed May 20, 2020
1 parent 189f57e commit 83b88d5
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 1 deletion.
51 changes: 51 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,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 @@ -2381,7 +2381,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 @@ -2516,6 +2516,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 @@ -2543,6 +2544,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 @@ -2581,6 +2583,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
```

Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces)
Expand Down

0 comments on commit 83b88d5

Please sign in to comment.