From e4db00c42387ad778a90665da9a0a17d2ee5b1cb Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 1 Jun 2022 22:21:09 +0000 Subject: [PATCH] Keep original method signature --- config/main.py | 4 ++-- config/validated_config_db_connector.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config/main.py b/config/main.py index 5b507c6c07..c2b2549bb0 100644 --- a/config/main.py +++ b/config/main.py @@ -1906,7 +1906,7 @@ def add_portchannel(ctx, portchannel_name, min_links, fallback): fvs["min_links"] = str(min_links) if fallback != "false": fvs["fallback"] = "true" - db.set_entry("add", "/PORTCHANNEL/{}".format(portchannel_name), fvs) + db.set_entry('PORTCHANNEL', portchannel_name, fvs) @portchannel.command('del') @click.argument('portchannel_name', metavar='', required=True) @@ -1920,7 +1920,7 @@ def remove_portchannel(ctx, portchannel_name): if len([(k, v) for k, v in db.get_table('PORTCHANNEL_MEMBER') if k == portchannel_name]) != 0: click.echo("Error: Portchannel {} contains members. Remove members before deleting Portchannel!".format(portchannel_name)) else: - db.set_entry("remove", "/PORTCHANNEL/{}".format(portchannel_name), None) + db.set_entry('PORTCHANNEL', portchannel_name, None) @portchannel.group(cls=clicommon.AbbreviationGroup, name='member') @click.pass_context diff --git a/config/validated_config_db_connector.py b/config/validated_config_db_connector.py index 4658e9af7e..60f9af4295 100644 --- a/config/validated_config_db_connector.py +++ b/config/validated_config_db_connector.py @@ -5,12 +5,18 @@ class ValidatedConfigDBConnector(ConfigDBConnector): - def set_entry(self, op, path, value): + def set_entry(self, table, key, value): + if value: + op = "add" + else: + op = "remove" + path = "/{}/{}".format(table, key) gcu_json_input = [] gcu_json = {"op": "{}".format(op), "path": "{}".format(path)} if value: gcu_json["value"] = value + gcu_json_input.append(gcu_json) gcu_patch = jsonpatch.JsonPatch(gcu_json_input) format = ConfigFormat.CONFIGDB.name