Skip to content

Added support for tunnel route status in show vnet routes all. #2341

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

Merged
merged 5 commits into from
Sep 15, 2022
Merged
Changes from 2 commits
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
8 changes: 6 additions & 2 deletions show/vnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ def all():
"""Show all vnet routes"""
appl_db = SonicV2Connector()
appl_db.connect(appl_db.APPL_DB)

state_db = SonicV2Connector()
state_db.connect(state_db.STATE_DB)
header = ['vnet name', 'prefix', 'nexthop', 'interface']

# Fetching data from appl_db for VNET ROUTES
Expand All @@ -227,7 +228,7 @@ def all():

click.echo()

header = ['vnet name', 'prefix', 'endpoint', 'mac address', 'vni']
header = ['vnet name', 'prefix', 'endpoint', 'mac address', 'vni', 'status']
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add tests so as to pass coverage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


# Fetching data from appl_db for VNET TUNNEL ROUTES
vnet_rt_keys = appl_db.keys(appl_db.APPL_DB, "VNET_ROUTE_TUNNEL_TABLE:*")
Expand All @@ -237,10 +238,13 @@ def all():
for k in vnet_rt_keys:
r = []
r.extend(k.split(":", 2)[1:])
state_db_key = '|'.join(k.split(":",2))
val = appl_db.get_all(appl_db.APPL_DB, k)
val_state = state_db.get_all(state_db.STATE_DB, state_db_key)
r.append(val.get('endpoint'))
r.append(val.get('mac_address'))
r.append(val.get('vni'))
r.append(val_state.get('state'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check the output if the entry is not present in state_db?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

table.append(r)

click.echo(tabulate(table, header))
Expand Down