Skip to content

Commit

Permalink
add fec config/show option (#764)
Browse files Browse the repository at this point in the history
Signed-off-by:yangshiping@jd.com
  • Loading branch information
yangshp1987 authored Jun 2, 2020
1 parent aae4f85 commit f7b7fcb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
19 changes: 19 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,25 @@ def mtu(ctx, interface_name, interface_mtu, verbose):
command += " -vv"
run_command(command, display_cmd=verbose)

@interface.command()
@click.pass_context
@click.argument('interface_name', metavar='<interface_name>', required=True)
@click.argument('interface_fec', metavar='<interface_fec>', required=True)
@click.option('-v', '--verbose', is_flag=True, help="Enable verbose output")
def fec(ctx, interface_name, interface_fec, verbose):
"""Set interface fec"""
if interface_fec not in ["rs", "fc", "none"]:
ctx.fail("'fec not in ['rs', 'fc', 'none']!")
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!")

command = "portconfig -p {} -f {}".format(interface_name, interface_fec)
if verbose:
command += " -vv"
run_command(command, display_cmd=verbose)

#
# 'ip' subgroup ('config interface ip ...')
#
Expand Down
5 changes: 4 additions & 1 deletion scripts/intfutil
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ PORT_OPER_STATUS = "oper_status"
PORT_ADMIN_STATUS = "admin_status"
PORT_SPEED = "speed"
PORT_MTU_STATUS = "mtu"
PORT_FEC = "fec"
PORT_DESCRIPTION = "description"
PORT_OPTICS_TYPE = "type"
PORT_PFC_ASYM_STATUS = "pfc_asym"
Expand Down Expand Up @@ -339,7 +340,7 @@ def appl_db_sub_intf_status_get(appl_db, config_db, front_panel_ports_list, port

# ========================== interface-status logic ==========================

header_stat = ['Interface', 'Lanes', 'Speed', 'MTU', 'Alias', 'Vlan', 'Oper', 'Admin', 'Type', 'Asym PFC']
header_stat = ['Interface', 'Lanes', 'Speed', 'MTU', 'FEC', 'Alias', 'Vlan', 'Oper', 'Admin', 'Type', 'Asym PFC']
header_stat_sub_intf = ['Sub port interface', 'Speed', 'MTU', 'Vlan', 'Admin', 'Type']

class IntfStatus(object):
Expand All @@ -365,6 +366,7 @@ class IntfStatus(object):
appl_db_port_status_get(self.appl_db, key, PORT_LANES_STATUS),
appl_db_port_status_get(self.appl_db, key, PORT_SPEED),
appl_db_port_status_get(self.appl_db, key, PORT_MTU_STATUS),
appl_db_port_status_get(self.appl_db, key, PORT_FEC),
appl_db_port_status_get(self.appl_db, key, PORT_ALIAS),
config_db_vlan_port_keys_get(self.combined_int_to_vlan_po_dict, self.front_panel_ports_list, key),
appl_db_port_status_get(self.appl_db, key, PORT_OPER_STATUS),
Expand All @@ -378,6 +380,7 @@ class IntfStatus(object):
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_LANES_STATUS, self.portchannel_speed_dict),
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_SPEED, self.portchannel_speed_dict),
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_MTU_STATUS, self.portchannel_speed_dict),
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_FEC, self.portchannel_speed_dict),
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_ALIAS, self.portchannel_speed_dict),
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, "vlan", self.portchannel_speed_dict),
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_OPER_STATUS, self.portchannel_speed_dict),
Expand Down
6 changes: 3 additions & 3 deletions sonic-utilities-tests/intfutil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def test_intf_status(self):
result = self.runner.invoke(show.cli.commands["interfaces"].commands["status"], [])
print >> sys.stderr, result.output
expected_output = (
"Interface Lanes Speed MTU Alias Vlan Oper Admin Type Asym PFC\n"
"----------- ------- ------- ----- --------- ------ ------ ------- --------------- ----------\n"
" Ethernet0 0 25G 9100 Ethernet0 routed down up QSFP28 or later off"
"Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC\n"
"----------- ------- ------- ----- ----- --------- ------ ------ ------- --------------- ----------\n"
" Ethernet0 0 25G 9100 rs Ethernet0 routed down up QSFP28 or later off"
)
self.assertEqual(result.output.strip(), expected_output)

Expand Down
1 change: 1 addition & 0 deletions sonic-utilities-tests/mock_tables/appl_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"oper_status": "down",
"pfc_asym": "off",
"mtu": "9100",
"fec": "rs",
"admin_status": "up"
},
"PORT_TABLE:Ethernet200": {
Expand Down

0 comments on commit f7b7fcb

Please sign in to comment.