Skip to content

Commit bc05ba7

Browse files
Issue #22420: Modify 'config route add' command not to include empty elements (#12)
'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 c5df741 commit bc05ba7

File tree

2 files changed

+84
-27
lines changed

2 files changed

+84
-27
lines changed

config/main.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ def cli_sroute_to_config(ctx, command_str, strict_nh = True):
11711171
else:
11721172
key = ip_prefix
11731173

1174-
return key, config_entry
1174+
return key, config_entry, vrf_name
11751175

11761176
def update_sonic_environment():
11771177
"""Prepare sonic environment variable using SONiC environment template file.
@@ -7169,7 +7169,7 @@ def route(ctx):
71697169
def add_route(ctx, command_str):
71707170
"""Add route command"""
71717171
config_db = ctx.obj['config_db']
7172-
key, route = cli_sroute_to_config(ctx, command_str)
7172+
key, route, vrf = cli_sroute_to_config(ctx, command_str)
71737173

71747174
entry_counter = 1
71757175
if 'nexthop' in route:
@@ -7185,7 +7185,7 @@ def add_route(ctx, command_str):
71857185
vrf = route['nexthop-vrf'].split(',')[0]
71867186
route['nexthop-vrf'] += ',' + vrf
71877187
else:
7188-
route['nexthop-vrf'] = ''
7188+
route['nexthop-vrf'] = vrf
71897189

71907190
# Set nexthop to empty string if not defined
71917191
if 'nexthop' in route:
@@ -7248,7 +7248,7 @@ def add_route(ctx, command_str):
72487248
def del_route(ctx, command_str):
72497249
"""Del route command"""
72507250
config_db = ctx.obj['config_db']
7251-
key, route = cli_sroute_to_config(ctx, command_str, strict_nh=False)
7251+
key, route, vrf = cli_sroute_to_config(ctx, command_str, strict_nh=False)
72527252
keys = config_db.get_keys('STATIC_ROUTE')
72537253

72547254
if not tuple(key.split("|")) in keys:
@@ -7291,6 +7291,8 @@ def del_route(ctx, command_str):
72917291
if ',' in route[item]:
72927292
ctx.fail('Only one nexthop can be deleted at a time')
72937293
cli_tuple += (route[item],)
7294+
elif entry == 'nexthop-vrf':
7295+
cli_tuple += (vrf,)
72947296
else:
72957297
cli_tuple += ('',)
72967298

0 commit comments

Comments
 (0)