Skip to content

Commit

Permalink
Remove the warning message appear when there are no ports on CONFIG DB (
Browse files Browse the repository at this point in the history
#2050)

#### What I did

Remove the warning of "Configuration database contains no ports" when ports table is empty.
Because when having a system with zero ports, this message appear per each access to ports tables on CONFIG DB

For example:

Run any cli command. For example  "show boot" or "show int st"

Observed behavior

root@r-sn4800-simx:/home/admin# show boot
Configuration database contains no ports
Configuration database contains no ports
Configuration database contains no ports


#### How I did it

Remove the warning and remove the unit test verify this warning 

#### How to verify it

Remove all the ports and verify there is no such warning in case of running "show interface status" CLi command

#### Previous command output (if the output of a command-line utility has changed)

Configuration database contains no ports
  Interface    Lanes    Speed    MTU    FEC    Alias    Vlan    Oper    Admin    Type    Asym PFC
-----------  -------  -------  -----  -----  -------  ------  ------  -------  ------  ----------
 
#### New command output (if the output of a command-line utility has changed)

  Interface    Lanes    Speed    MTU    FEC    Alias    Vlan    Oper    Admin    Type    Asym PFC
-----------  -------  -------  -----  -----  -------  ------  ------  -------  ------  ----------
  • Loading branch information
dprital authored Feb 23, 2022
1 parent ed6e66e commit 8b01d3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 3 additions & 5 deletions tests/interfaces_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def test_show_interfaces_portchannel_in_alias_mode(self):
traceback.print_tb(result.exc_info[2])
assert result.exit_code == 0
assert result.output == show_interfaces_portchannel_in_alias_mode_output

@mock.patch('sonic_py_common.multi_asic.get_port_table', mock.MagicMock(return_value={}))
def test_supervisor_show_interfaces_alias_etp1_with_waring(self):
runner = CliRunner()
Expand All @@ -303,8 +303,7 @@ def test_supervisor_show_interfaces_alias_etp1_with_waring(self):
print(result.exit_code)
print(result.output)
assert result.exit_code != 0
assert "Configuration database contains no ports" in result.output


@mock.patch('sonic_py_common.multi_asic.get_port_table', mock.MagicMock(return_value={}))
@mock.patch('sonic_py_common.device_info.is_supervisor', mock.MagicMock(return_value=True))
def test_supervisor_show_interfaces_alias_etp1_without_waring(self):
Expand All @@ -315,8 +314,7 @@ def test_supervisor_show_interfaces_alias_etp1_without_waring(self):
print(result.exit_code)
print(result.output)
assert result.exit_code != 0
assert "Configuration database contains no ports" not in result.output


@classmethod
def teardown_class(cls):
print("TEARDOWN")
4 changes: 1 addition & 3 deletions utilities_common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import netaddr

from natsort import natsorted
from sonic_py_common import multi_asic, device_info
from sonic_py_common import multi_asic
from utilities_common.db import Db
from utilities_common.general import load_db_config

Expand Down Expand Up @@ -131,8 +131,6 @@ def __init__(self, db=None):


if not self.port_dict:
if not device_info.is_supervisor():
click.echo(message="Configuration database contains no ports")
self.port_dict = {}

for port_name in self.port_dict:
Expand Down

0 comments on commit 8b01d3e

Please sign in to comment.