Skip to content

Commit 7f89091

Browse files
yangshp1987abdosi
authored andcommitted
add fec config/show option (#764)
Signed-off-by:[email protected]
1 parent 5243cc5 commit 7f89091

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

config/main.py

+19
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,25 @@ def mtu(ctx, interface_name, interface_mtu, verbose):
19431943
command += " -vv"
19441944
run_command(command, display_cmd=verbose)
19451945

1946+
@interface.command()
1947+
@click.pass_context
1948+
@click.argument('interface_name', metavar='<interface_name>', required=True)
1949+
@click.argument('interface_fec', metavar='<interface_fec>', required=True)
1950+
@click.option('-v', '--verbose', is_flag=True, help="Enable verbose output")
1951+
def fec(ctx, interface_name, interface_fec, verbose):
1952+
"""Set interface fec"""
1953+
if interface_fec not in ["rs", "fc", "none"]:
1954+
ctx.fail("'fec not in ['rs', 'fc', 'none']!")
1955+
if get_interface_naming_mode() == "alias":
1956+
interface_name = interface_alias_to_name(interface_name)
1957+
if interface_name is None:
1958+
ctx.fail("'interface_name' is None!")
1959+
1960+
command = "portconfig -p {} -f {}".format(interface_name, interface_fec)
1961+
if verbose:
1962+
command += " -vv"
1963+
run_command(command, display_cmd=verbose)
1964+
19461965
#
19471966
# 'ip' subgroup ('config interface ip ...')
19481967
#

scripts/intfutil

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ PORT_OPER_STATUS = "oper_status"
3232
PORT_ADMIN_STATUS = "admin_status"
3333
PORT_SPEED = "speed"
3434
PORT_MTU_STATUS = "mtu"
35+
PORT_FEC = "fec"
3536
PORT_DESCRIPTION = "description"
3637
PORT_OPTICS_TYPE = "type"
3738
PORT_PFC_ASYM_STATUS = "pfc_asym"
@@ -340,7 +341,7 @@ def appl_db_sub_intf_status_get(appl_db, config_db, front_panel_ports_list, port
340341

341342
# ========================== interface-status logic ==========================
342343

343-
header_stat = ['Interface', 'Lanes', 'Speed', 'MTU', 'Alias', 'Vlan', 'Oper', 'Admin', 'Type', 'Asym PFC']
344+
header_stat = ['Interface', 'Lanes', 'Speed', 'MTU', 'FEC', 'Alias', 'Vlan', 'Oper', 'Admin', 'Type', 'Asym PFC']
344345
header_stat_sub_intf = ['Sub port interface', 'Speed', 'MTU', 'Vlan', 'Admin', 'Type']
345346

346347
class IntfStatus(object):
@@ -366,6 +367,7 @@ class IntfStatus(object):
366367
appl_db_port_status_get(self.appl_db, key, PORT_LANES_STATUS),
367368
appl_db_port_status_get(self.appl_db, key, PORT_SPEED),
368369
appl_db_port_status_get(self.appl_db, key, PORT_MTU_STATUS),
370+
appl_db_port_status_get(self.appl_db, key, PORT_FEC),
369371
appl_db_port_status_get(self.appl_db, key, PORT_ALIAS),
370372
config_db_vlan_port_keys_get(self.combined_int_to_vlan_po_dict, self.front_panel_ports_list, key),
371373
appl_db_port_status_get(self.appl_db, key, PORT_OPER_STATUS),
@@ -379,6 +381,7 @@ class IntfStatus(object):
379381
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_LANES_STATUS, self.portchannel_speed_dict),
380382
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_SPEED, self.portchannel_speed_dict),
381383
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_MTU_STATUS, self.portchannel_speed_dict),
384+
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_FEC, self.portchannel_speed_dict),
382385
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_ALIAS, self.portchannel_speed_dict),
383386
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, "vlan", self.portchannel_speed_dict),
384387
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_OPER_STATUS, self.portchannel_speed_dict),

sonic-utilities-tests/intfutil_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def test_intf_status(self):
2727
result = self.runner.invoke(show.cli.commands["interfaces"].commands["status"], [])
2828
print >> sys.stderr, result.output
2929
expected_output = (
30-
"Interface Lanes Speed MTU Alias Vlan Oper Admin Type Asym PFC\n"
31-
"----------- ------- ------- ----- --------- ------ ------ ------- --------------- ----------\n"
32-
" Ethernet0 0 25G 9100 Ethernet0 routed down up QSFP28 or later off"
30+
"Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC\n"
31+
"----------- ------- ------- ----- ----- --------- ------ ------ ------- --------------- ----------\n"
32+
" Ethernet0 0 25G 9100 rs Ethernet0 routed down up QSFP28 or later off"
3333
)
3434
self.assertEqual(result.output.strip(), expected_output)
3535

sonic-utilities-tests/mock_tables/appl_db.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"oper_status": "down",
88
"pfc_asym": "off",
99
"mtu": "9100",
10+
"fec": "rs",
1011
"admin_status": "up"
1112
},
1213
"PORT_TABLE:Ethernet200": {

0 commit comments

Comments
 (0)