From 597639943a5fdd21183ac50428e74f160288b4ae Mon Sep 17 00:00:00 2001 From: Blueve <672454911@qq.com> Date: Wed, 7 Apr 2021 10:16:32 +0800 Subject: [PATCH] [console] Include Flow Control status in show line result (#1549) - Render the flow control option in show line table - Update unit test case - Update document Signed-off-by: Jing Kan jika@microsoft.com --- consutil/main.py | 5 +++-- doc/Command-Reference.md | 20 ++++++++++---------- tests/console_test.py | 12 ++++++------ 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/consutil/main.py b/consutil/main.py index b4ee3fa4fe8a..069f6bb27e46 100644 --- a/consutil/main.py +++ b/consutil/main.py @@ -41,7 +41,7 @@ def show(db, brief): ports.sort(key=lambda p: int(p.line_num)) # set table header style - header = ["Line", "Baud", "PID", "Start Time", "Device"] + header = ["Line", "Baud", "Flow Control", "PID", "Start Time", "Device"] body = [] for port in ports: # runtime information @@ -49,7 +49,8 @@ def show(db, brief): pid = port.session_pid if port.session_pid else "-" date = port.session_start_date if port.session_start_date else "-" baud = port.baud - body.append([busy+port.line_num, baud if baud else "-", pid if pid else "-", date if date else "-", port.remote_device]) + flow_control = "Enabled" if port.flow_control else "Disabled" + body.append([busy+port.line_num, baud if baud else "-", flow_control, pid if pid else "-", date if date else "-", port.remote_device]) click.echo(tabulate(body, header, stralign='right')) # 'clear' subcommand diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index ffbc0c26f434..66154132551d 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -1993,13 +1993,13 @@ This command displays serial port or a virtual network connection status. - Example: ``` admin@sonic:~$ show line - Line Baud PID Start Time Device - ------ ------ ----- ------------ -------- - 0 - - - - 1 9600 - - switch1 - 2 - - - - 3 - - - - 4 - - - + Line Baud Flow Control PID Start Time Device + ------ ------ -------------- ----- ------------ -------- + 1 9600 Enabled - - switch1 + 2 - Disabled - - + 3 - Disabled - - + 4 - Disabled - - + 5 - Disabled - - ``` Optionally, you can display configured console ports only by specifying the `-b` or `--breif` flag. @@ -2007,9 +2007,9 @@ Optionally, you can display configured console ports only by specifying the `-b` - Example: ``` admin@sonic:~$ show line -b - Line Baud PID Start Time Device - ------ ------ ----- ------------ -------- - 1 9600 - - switch1 + Line Baud Flow Control PID Start Time Device + ------ ------ -------------- ----- ------------ -------- + 1 9600 Enabled - - switch1 ``` ## Console config commands diff --git a/tests/console_test.py b/tests/console_test.py index c38b7ebb568a..e4b5156837df 100644 --- a/tests/console_test.py +++ b/tests/console_test.py @@ -531,11 +531,11 @@ def setup_class(cls): print("SETUP") expect_show_output = ''+ \ - """ Line Baud PID Start Time Device ------- ------ ----- ------------------------ -------- - 1 9600 - - switch1 - *2 9600 223 Wed Mar 6 08:31:35 2019 switch2 - 3 9600 - - + """ Line Baud Flow Control PID Start Time Device +------ ------ -------------- ----- ------------------------ -------- + 1 9600 Disabled - - switch1 + *2 9600 Disabled 223 Wed Mar 6 08:31:35 2019 switch2 + 3 9600 Enabled - - """ @mock.patch('consutil.lib.SysInfoProvider.init_device_prefix', mock.MagicMock(return_value=None)) def test_show(self): @@ -543,7 +543,7 @@ def test_show(self): db = Db() db.cfgdb.set_entry("CONSOLE_PORT", 1, { "remote_device" : "switch1", "baud_rate" : "9600" }) db.cfgdb.set_entry("CONSOLE_PORT", 2, { "remote_device" : "switch2", "baud_rate" : "9600" }) - db.cfgdb.set_entry("CONSOLE_PORT", 3, { "baud_rate" : "9600" }) + db.cfgdb.set_entry("CONSOLE_PORT", 3, { "baud_rate" : "9600", "flow_control" : "1" }) db.db.set(db.db.STATE_DB, "CONSOLE_PORT|2", "state", "busy") db.db.set(db.db.STATE_DB, "CONSOLE_PORT|2", "pid", "223")