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

[port_util] Allow system without ports in config db run without errors #109

Merged
merged 2 commits into from
Sep 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/swsssdk/port_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,19 @@ def get_interface_oid_map(db):
"""
Get the Interface names from Counters DB
"""
if_name_map = {}
if_id_map = {}

db.connect('COUNTERS_DB')
if_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_PORT_NAME_MAP', blocking=True)
if_lag_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_LAG_NAME_MAP', blocking=True)
if_name_map.update(if_lag_name_map)
if db.exists('COUNTERS_DB', 'COUNTERS_PORT_NAME_MAP'):
liorghub marked this conversation as resolved.
Show resolved Hide resolved
if_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_PORT_NAME_MAP', blocking=True)

if db.exists('COUNTERS_DB', 'COUNTERS_LAG_NAME_MAP'):
if_lag_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_LAG_NAME_MAP', blocking=True)
if_name_map.update(if_lag_name_map)

if not if_name_map:
return {}, {}

oid_pfx = len("oid:0x")
if_name_map = {if_name: sai_oid[oid_pfx:] for if_name, sai_oid in if_name_map.items()}
Expand Down