Skip to content

Commit

Permalink
Keep original method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Jun 1, 2022
1 parent d4ab077 commit e4db00c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='<portchannel_name>', required=True)
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion config/validated_config_db_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e4db00c

Please sign in to comment.