Skip to content

Commit

Permalink
[acl-loader]: Add 'delete' command (sonic-net#180)
Browse files Browse the repository at this point in the history
Signed-off-by: marian-pritsak <[email protected]>
  • Loading branch information
marian-pritsak authored Dec 26, 2017
1 parent 24ca577 commit 5ad8486
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions acl_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,19 @@ def incremental_update(self):
self.configdb.mod_entry(self.ACL_RULE, key, None)
self.configdb.mod_entry(self.ACL_RULE, key, self.rules_info[key])


def delete(self, table=None, rule=None):
"""
:param table:
:param rule:
:return:
"""
for key in self.rules_db_info.iterkeys():
if not table or table == key[0]:
if not rule or rule == key[1]:
self.configdb.set_entry(self.ACL_RULE, key, None)


def show_table(self, table_name):
"""
Show ACL table configuration.
Expand Down Expand Up @@ -602,6 +615,19 @@ def incremental(ctx, filename, session_name, max_priority):
acl_loader.incremental_update()


@cli.command()
@click.argument('table', required=False)
@click.argument('rule', required=False)
@click.pass_context
def delete(ctx, table, rule):
"""
Delete ACL rules.
"""
acl_loader = ctx.obj["acl_loader"]

acl_loader.delete(table, rule)


if __name__ == "__main__":
try:
cli()
Expand Down

0 comments on commit 5ad8486

Please sign in to comment.