Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mclag_validate #3643

Closed
wants to merge 13 commits into from
15 changes: 15 additions & 0 deletions config/mclag.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ def config_mclag_session_timeout(ctx, domain_id, time_in_secs):
db.mod_entry('MCLAG_DOMAIN', domain_id, fvs)


def is_portchannel_present_in_db(db, portchannel_name):
"""Check if Portchannel is present in Config DB
"""

# Return True if Portchannel name exists in the CONFIG_DB
portchannel_list = db.get_table(CFG_PORTCHANNEL_PREFIX)
if portchannel_list is None:
return False
if portchannel_name in portchannel_list:
return True
return False


#mclag interface config
@mclag.group('member')
@click.pass_context
Expand All @@ -289,6 +302,8 @@ def add_mclag_member(ctx, domain_id, portchannel_names):
if ADHOC_VALIDATION:
if is_portchannel_name_valid(portchannel_name) != True:
ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'" .format(portchannel_name, CFG_PORTCHANNEL_PREFIX, CFG_PORTCHANNEL_NO))
if is_portchannel_present_in_db(db, portchannel_name) is False:
ctx.fail("{} is not present.".format(portchannel_name))
try:
db.set_entry('MCLAG_INTERFACE', (domain_id, portchannel_name), {'if_type':"PortChannel"} )
except ValueError as e:
Expand Down
Loading