Skip to content

Commit f7b7fcb

Browse files
authored
add fec config/show option (#764)
Signed-off-by:yangshiping@jd.com
1 parent aae4f85 commit f7b7fcb

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
@@ -1954,6 +1954,25 @@ def mtu(ctx, interface_name, interface_mtu, verbose):
19541954
command += " -vv"
19551955
run_command(command, display_cmd=verbose)
19561956

1957+
@interface.command()
1958+
@click.pass_context
1959+
@click.argument('interface_name', metavar='<interface_name>', required=True)
1960+
@click.argument('interface_fec', metavar='<interface_fec>', required=True)
1961+
@click.option('-v', '--verbose', is_flag=True, help="Enable verbose output")
1962+
def fec(ctx, interface_name, interface_fec, verbose):
1963+
"""Set interface fec"""
1964+
if interface_fec not in ["rs", "fc", "none"]:
1965+
ctx.fail("'fec not in ['rs', 'fc', 'none']!")
1966+
if get_interface_naming_mode() == "alias":
1967+
interface_name = interface_alias_to_name(interface_name)
1968+
if interface_name is None:
1969+
ctx.fail("'interface_name' is None!")
1970+
1971+
command = "portconfig -p {} -f {}".format(interface_name, interface_fec)
1972+
if verbose:
1973+
command += " -vv"
1974+
run_command(command, display_cmd=verbose)
1975+
19571976
#
19581977
# 'ip' subgroup ('config interface ip ...')
19591978
#

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"
@@ -339,7 +340,7 @@ def appl_db_sub_intf_status_get(appl_db, config_db, front_panel_ports_list, port
339340

340341
# ========================== interface-status logic ==========================
341342

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

345346
class IntfStatus(object):
@@ -365,6 +366,7 @@ class IntfStatus(object):
365366
appl_db_port_status_get(self.appl_db, key, PORT_LANES_STATUS),
366367
appl_db_port_status_get(self.appl_db, key, PORT_SPEED),
367368
appl_db_port_status_get(self.appl_db, key, PORT_MTU_STATUS),
369+
appl_db_port_status_get(self.appl_db, key, PORT_FEC),
368370
appl_db_port_status_get(self.appl_db, key, PORT_ALIAS),
369371
config_db_vlan_port_keys_get(self.combined_int_to_vlan_po_dict, self.front_panel_ports_list, key),
370372
appl_db_port_status_get(self.appl_db, key, PORT_OPER_STATUS),
@@ -378,6 +380,7 @@ class IntfStatus(object):
378380
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_LANES_STATUS, self.portchannel_speed_dict),
379381
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_SPEED, self.portchannel_speed_dict),
380382
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_MTU_STATUS, self.portchannel_speed_dict),
383+
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_FEC, self.portchannel_speed_dict),
381384
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, PORT_ALIAS, self.portchannel_speed_dict),
382385
appl_db_portchannel_status_get(self.appl_db, self.config_db, po, "vlan", self.portchannel_speed_dict),
383386
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)