Skip to content

Commit 9e9a65b

Browse files
Issue #22420: Modify 'config route add' command not to include empty elements (#12) (#3862)
'config route add' fills out missing 'nexthop-vrf' elements with the empty string (''). This is not valid in the yang model; vrf names can only be 'default', 'mgmt', or 'VRF<somestring>'.
1 parent 0edb592 commit 9e9a65b

File tree

2 files changed

+150
-31
lines changed

2 files changed

+150
-31
lines changed

config/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ def cli_sroute_to_config(ctx, command_str, strict_nh = True):
12481248
else:
12491249
key = ip_prefix
12501250

1251-
return key, config_entry
1251+
return key, config_entry, vrf_name
12521252

12531253
def update_sonic_environment():
12541254
"""Prepare sonic environment variable using SONiC environment template file.
@@ -7314,7 +7314,7 @@ def route(ctx):
73147314
def add_route(ctx, command_str):
73157315
"""Add route command"""
73167316
config_db = ctx.obj['config_db']
7317-
key, route = cli_sroute_to_config(ctx, command_str)
7317+
key, route, vrf = cli_sroute_to_config(ctx, command_str)
73187318

73197319
entry_counter = 1
73207320
if 'nexthop' in route:
@@ -7330,7 +7330,7 @@ def add_route(ctx, command_str):
73307330
vrf = route['nexthop-vrf'].split(',')[0]
73317331
route['nexthop-vrf'] += ',' + vrf
73327332
else:
7333-
route['nexthop-vrf'] = ''
7333+
route['nexthop-vrf'] = vrf
73347334

73357335
# Set nexthop to empty string if not defined
73367336
if 'nexthop' in route:
@@ -7393,7 +7393,7 @@ def add_route(ctx, command_str):
73937393
def del_route(ctx, command_str):
73947394
"""Del route command"""
73957395
config_db = ctx.obj['config_db']
7396-
key, route = cli_sroute_to_config(ctx, command_str, strict_nh=False)
7396+
key, route, vrf = cli_sroute_to_config(ctx, command_str, strict_nh=False)
73977397
keys = config_db.get_keys('STATIC_ROUTE')
73987398

73997399
if not tuple(key.split("|")) in keys:
@@ -7436,6 +7436,8 @@ def del_route(ctx, command_str):
74367436
if ',' in route[item]:
74377437
ctx.fail('Only one nexthop can be deleted at a time')
74387438
cli_tuple += (route[item],)
7439+
elif item == 'nexthop-vrf':
7440+
cli_tuple += (vrf,)
74397441
else:
74407442
cli_tuple += ('',)
74417443

0 commit comments

Comments
 (0)