diff --git a/config/main.py b/config/main.py index 1cd172c05134..a4283531992b 100755 --- a/config/main.py +++ b/config/main.py @@ -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 @@ -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 ...')