Skip to content

Commit

Permalink
Revert to just db.set_entry()
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Jun 14, 2022
1 parent 57ab896 commit 1df71b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1894,8 +1894,7 @@ def portchannel(db, ctx, namespace):
def add_portchannel(ctx, portchannel_name, min_links, fallback):
"""Add port channel"""

db = ctx.obj['db']
validated_db = ValidatedConfigDBConnector(db)
db = ValidatedConfigDBConnector(ctx.obj['db'])

if is_portchannel_present_in_db(db, portchannel_name):
ctx.fail("{} already exists!".format(portchannel_name))
Expand All @@ -1907,21 +1906,20 @@ def add_portchannel(ctx, portchannel_name, min_links, fallback):
fvs['min_links'] = str(min_links)
if fallback != 'false':
fvs['fallback'] = 'true'
validated_db.set_entry('PORTCHANNEL', portchannel_name, fvs)
db.set_entry('PORTCHANNEL', portchannel_name, fvs)

@portchannel.command('del')
@click.argument('portchannel_name', metavar='<portchannel_name>', required=True)
@click.pass_context
def remove_portchannel(ctx, portchannel_name):
"""Remove port channel"""

db = ctx.obj['db']
validated_db = ValidatedConfigDBConnector(db)
db = ValidatedConfigDBConnector(ctx.obj['db'])

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:
validated_db.set_entry('PORTCHANNEL', portchannel_name, None)
db.set_entry('PORTCHANNEL', portchannel_name, None)

@portchannel.group(cls=clicommon.AbbreviationGroup, name='member')
@click.pass_context
Expand Down
2 changes: 1 addition & 1 deletion config/validated_config_db_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class ValidatedConfigDBConnector(ConfigDBConnector):

def __init__(self, db):
pass
super().__init__()

def set_entry(self, table, key, value):
if value:
Expand Down

0 comments on commit 1df71b3

Please sign in to comment.