From d7f6154bba5ffd8ba2e1c550c27e60a213d06531 Mon Sep 17 00:00:00 2001 From: madhu Pal Date: Fri, 25 Jan 2019 16:58:10 +0000 Subject: [PATCH 1/2] [config/main.py]Fixed - added a validation such that delete portchannel or portchannel members only when it is configured (#277) --- config/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/config/main.py b/config/main.py index 99955d90c3..475480d480 100755 --- a/config/main.py +++ b/config/main.py @@ -450,7 +450,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 @@ -474,9 +478,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 ...') From c71894370394fbda51635b2a549169cfde829217 Mon Sep 17 00:00:00 2001 From: madhu Pal Date: Wed, 30 Jan 2019 04:20:26 +0000 Subject: [PATCH 2/2] [config/main.py] Fixed typo in passing arguments -port_namee (#277) Signed-off-by: madhu Pal --- config/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/main.py b/config/main.py index 475480d480..d9f977a4f1 100755 --- a/config/main.py +++ b/config/main.py @@ -478,7 +478,7 @@ 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'] - if len(db.get_entry('PORTCHANNEL_MEMBER', portchannel_name + '|' + port_namee)) != 0: + if len(db.get_entry('PORTCHANNEL_MEMBER', portchannel_name + '|' + port_name)) != 0: db.set_entry('PORTCHANNEL_MEMBER', (portchannel_name, port_name), None) db.set_entry('PORTCHANNEL_MEMBER', portchannel_name + '|' + port_name, None) else: