Skip to content

Commit

Permalink
[config] Fix Breakout mode option and BREAKOUT_CFG table check method (
Browse files Browse the repository at this point in the history
…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 <sangitamaity0211@gmail.com>
  • Loading branch information
samaity authored Jan 20, 2021
1 parent 9bd709b commit 3df267e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _get_breakout_options(ctx, args, incomplete):
for i in breakout_mode_list.split(','):
breakout_mode_options.append(i)
all_mode_options = [str(c) for c in breakout_mode_options if incomplete in c]
return all_mode_options
return all_mode_options

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

# Get current breakout mode
cur_brkout_dict = config_db.get_table('BREAKOUT_CFG')
if len(cur_brkout_dict) == 0:
click.secho("[ERROR] BREAKOUT_CFG table is NOT present in CONFIG DB", fg='red')
raise click.Abort()

if interface_name not in cur_brkout_dict.keys():
click.secho("[ERROR] {} interface is NOT present in BREAKOUT_CFG table of CONFIG DB".format(interface_name), fg='red')
raise click.Abort()

cur_brkout_mode = cur_brkout_dict[interface_name]["brkout_mode"]

# Validate Interface and Breakout mode
Expand Down

0 comments on commit 3df267e

Please sign in to comment.