Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[show] Allow system with no ports in config db run without errors #1697

Closed
wants to merge 2 commits into from

Conversation

liorghub
Copy link
Contributor

@liorghub liorghub commented Jun 28, 2021

What I did
Allow system with no ports in config db run without errors.
This is needed for modular system which should boot properly without line cards.

How I did it
Do not raise warning if ports dictionary is empty.

How to verify it
Run show interfaces status

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

root@r-leopard-41:/home/admin# show interfaces status
Warning: failed to retrieve PORT table from ConfigDB!
Warning: failed to retrieve PORT table from ConfigDB!
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
*----------- ------- ------- ----- ----- ------- ------ ------ ------- ------ ----------
root@r-leopard-41:/home/admin#

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

root@r-leopard-41:/home/admin# show interfaces status
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
*----------- ------- ------- ----- ----- ------- ------ ------ ------- ------ ----------
root@r-leopard-41:/home/admin#

@prsunny
Copy link
Contributor

prsunny commented Jul 1, 2021

please provide previous and new output as mentioned in the template

@@ -125,8 +125,7 @@ def __init__(self, db=None):
self.port_dict = self.config_db.get_table('PORT')
self.alias_max_length = 0


if not self.port_dict:
if self.port_dict is None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the get_table API doesn't return None, this check may not be needed and we can remove it altogether. Can you please confirm?

Copy link
Contributor Author

@liorghub liorghub Jul 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Both get_table() and get_port_table() initialize an empty dictionary which is being returned even if 'PORT' table is empty. I removed this check.

@caizhenghui-juniper
Copy link

Is this the only change needed for empty port config in the show commands? Or this is just enough to allow system to come up?

@liorghub
Copy link
Contributor Author

@caizhenghui-juniper
This is the only change needed in sonic utilities (not just to allow clean init).

@liorghub
Copy link
Contributor Author

liorghub commented Aug 4, 2021

@prsunny
Can you please approve this change?

@liorghub liorghub closed this Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants