Skip to content

Commit 3df267e

Browse files
authored
[config] Fix Breakout mode option and BREAKOUT_CFG table check method (sonic-net#1270)
Made a robust check for below cases: - when the interface is wrong and the mode is correct. - BREAKOUT_CFG table is NOT present in CONFIG DB Also, Fixed Breakout mode option when options are not available for easy readability. Signed-off-by: Sangita Maity <[email protected]>
1 parent 9bd709b commit 3df267e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

config/main.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _get_breakout_options(ctx, args, incomplete):
116116
for i in breakout_mode_list.split(','):
117117
breakout_mode_options.append(i)
118118
all_mode_options = [str(c) for c in breakout_mode_options if incomplete in c]
119-
return all_mode_options
119+
return all_mode_options
120120

121121
def shutdown_interfaces(ctx, del_intf_dict):
122122
""" shut down all the interfaces before deletion """
@@ -2422,6 +2422,14 @@ def breakout(ctx, interface_name, mode, verbose, force_remove_dependencies, load
24222422

24232423
# Get current breakout mode
24242424
cur_brkout_dict = config_db.get_table('BREAKOUT_CFG')
2425+
if len(cur_brkout_dict) == 0:
2426+
click.secho("[ERROR] BREAKOUT_CFG table is NOT present in CONFIG DB", fg='red')
2427+
raise click.Abort()
2428+
2429+
if interface_name not in cur_brkout_dict.keys():
2430+
click.secho("[ERROR] {} interface is NOT present in BREAKOUT_CFG table of CONFIG DB".format(interface_name), fg='red')
2431+
raise click.Abort()
2432+
24252433
cur_brkout_mode = cur_brkout_dict[interface_name]["brkout_mode"]
24262434

24272435
# Validate Interface and Breakout mode

0 commit comments

Comments
 (0)