Skip to content

Commit 5976399

Browse files
authored
[console] Include Flow Control status in show line result (sonic-net#1549)
- Render the flow control option in show line table - Update unit test case - Update document Signed-off-by: Jing Kan [email protected]
1 parent b1097b2 commit 5976399

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

consutil/main.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ def show(db, brief):
4141
ports.sort(key=lambda p: int(p.line_num))
4242

4343
# set table header style
44-
header = ["Line", "Baud", "PID", "Start Time", "Device"]
44+
header = ["Line", "Baud", "Flow Control", "PID", "Start Time", "Device"]
4545
body = []
4646
for port in ports:
4747
# runtime information
4848
busy = "*" if port.busy else " "
4949
pid = port.session_pid if port.session_pid else "-"
5050
date = port.session_start_date if port.session_start_date else "-"
5151
baud = port.baud
52-
body.append([busy+port.line_num, baud if baud else "-", pid if pid else "-", date if date else "-", port.remote_device])
52+
flow_control = "Enabled" if port.flow_control else "Disabled"
53+
body.append([busy+port.line_num, baud if baud else "-", flow_control, pid if pid else "-", date if date else "-", port.remote_device])
5354
click.echo(tabulate(body, header, stralign='right'))
5455

5556
# 'clear' subcommand

doc/Command-Reference.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1993,23 +1993,23 @@ This command displays serial port or a virtual network connection status.
19931993
- Example:
19941994
```
19951995
admin@sonic:~$ show line
1996-
Line Baud PID Start Time Device
1997-
------ ------ ----- ------------ --------
1998-
0 - - -
1999-
1 9600 - - switch1
2000-
2 - - -
2001-
3 - - -
2002-
4 - - -
1996+
Line Baud Flow Control PID Start Time Device
1997+
------ ------ -------------- ----- ------------ --------
1998+
1 9600 Enabled - - switch1
1999+
2 - Disabled - -
2000+
3 - Disabled - -
2001+
4 - Disabled - -
2002+
5 - Disabled - -
20032003
```
20042004
20052005
Optionally, you can display configured console ports only by specifying the `-b` or `--breif` flag.
20062006
20072007
- Example:
20082008
```
20092009
admin@sonic:~$ show line -b
2010-
Line Baud PID Start Time Device
2011-
------ ------ ----- ------------ --------
2012-
1 9600 - - switch1
2010+
Line Baud Flow Control PID Start Time Device
2011+
------ ------ -------------- ----- ------------ --------
2012+
1 9600 Enabled - - switch1
20132013
```
20142014
20152015
## Console config commands

tests/console_test.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -531,19 +531,19 @@ def setup_class(cls):
531531
print("SETUP")
532532

533533
expect_show_output = ''+ \
534-
""" Line Baud PID Start Time Device
535-
------ ------ ----- ------------------------ --------
536-
1 9600 - - switch1
537-
*2 9600 223 Wed Mar 6 08:31:35 2019 switch2
538-
3 9600 - -
534+
""" Line Baud Flow Control PID Start Time Device
535+
------ ------ -------------- ----- ------------------------ --------
536+
1 9600 Disabled - - switch1
537+
*2 9600 Disabled 223 Wed Mar 6 08:31:35 2019 switch2
538+
3 9600 Enabled - -
539539
"""
540540
@mock.patch('consutil.lib.SysInfoProvider.init_device_prefix', mock.MagicMock(return_value=None))
541541
def test_show(self):
542542
runner = CliRunner()
543543
db = Db()
544544
db.cfgdb.set_entry("CONSOLE_PORT", 1, { "remote_device" : "switch1", "baud_rate" : "9600" })
545545
db.cfgdb.set_entry("CONSOLE_PORT", 2, { "remote_device" : "switch2", "baud_rate" : "9600" })
546-
db.cfgdb.set_entry("CONSOLE_PORT", 3, { "baud_rate" : "9600" })
546+
db.cfgdb.set_entry("CONSOLE_PORT", 3, { "baud_rate" : "9600", "flow_control" : "1" })
547547

548548
db.db.set(db.db.STATE_DB, "CONSOLE_PORT|2", "state", "busy")
549549
db.db.set(db.db.STATE_DB, "CONSOLE_PORT|2", "pid", "223")

0 commit comments

Comments
 (0)