Skip to content

Commit

Permalink
[config/main.py]Fixed - added a validation such that delete portchann…
Browse files Browse the repository at this point in the history
…el or portchannel members only when it is configured (sonic-net#277) (sonic-net#445)
  • Loading branch information
madhupalu authored and prsunny committed Jan 28, 2019
1 parent 97ac8c7 commit dc5d5c4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,11 @@ def add_portchannel(ctx, portchannel_name, min_links, fallback):
def remove_portchannel(ctx, portchannel_name):
"""Remove port channel"""
db = ctx.obj['db']
db.set_entry('PORTCHANNEL', portchannel_name, None)
if len(db.get_entry('PORTCHANNEL', portchannel_name)) != 0:
db.set_entry('PORTCHANNEL', portchannel_name, None)
else:
ctx.fail("{} is not configured".format(portchannel_name))


@portchannel.group('member')
@click.pass_context
Expand All @@ -488,9 +492,11 @@ def add_portchannel_member(ctx, portchannel_name, port_name):
def del_portchannel_member(ctx, portchannel_name, port_name):
"""Remove member from portchannel"""
db = ctx.obj['db']
db.set_entry('PORTCHANNEL_MEMBER', (portchannel_name, port_name), None)
db.set_entry('PORTCHANNEL_MEMBER', portchannel_name + '|' + port_name, None)

if len(db.get_entry('PORTCHANNEL_MEMBER', portchannel_name + '|' + port_namee)) != 0:
db.set_entry('PORTCHANNEL_MEMBER', (portchannel_name, port_name), None)
db.set_entry('PORTCHANNEL_MEMBER', portchannel_name + '|' + port_name, None)
else:
ctx.fail("{} is not part of {}".format(port_name, portchannel_name))

#
# 'mirror_session' group ('config mirror_session ...')
Expand Down

0 comments on commit dc5d5c4

Please sign in to comment.