Skip to content

Commit

Permalink
Use 'default' VRF when VRF name is not provided (sonic-net#2368)
Browse files Browse the repository at this point in the history
While adding static routes, if VRF name is not present, use default VRF
  • Loading branch information
sumukhatv authored and preetham-singh committed Nov 18, 2022
1 parent ecb9ea7 commit 5014bd4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 55 deletions.
5 changes: 3 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,7 @@ def cli_sroute_to_config(ctx, command_str, strict_nh = True):
elif 'prefix' in prefix_str:
# prefix_str: ['prefix', ip]
ip_prefix = prefix_str[1]
vrf_name = "default"
else:
ctx.fail("prefix is not in pattern!")

Expand Down Expand Up @@ -5314,7 +5315,7 @@ def add_route(ctx, command_str):

# Check if exist entry with key
keys = config_db.get_keys('STATIC_ROUTE')
if key in keys:
if tuple(key.split("|")) in keys:
# If exist update current entry
current_entry = config_db.get_entry('STATIC_ROUTE', key)

Expand All @@ -5339,7 +5340,7 @@ def del_route(ctx, command_str):
key, route = cli_sroute_to_config(ctx, command_str, strict_nh=False)
keys = config_db.get_keys('STATIC_ROUTE')
prefix_tuple = tuple(key.split('|'))
if not key in keys and not prefix_tuple in keys:
if not tuple(key.split("|")) in keys and not prefix_tuple in keys:
ctx.fail('Route {} doesnt exist'.format(key))
else:
# If not defined nexthop or intf name remove entire route
Expand Down
Loading

0 comments on commit 5014bd4

Please sign in to comment.