Skip to content

Commit

Permalink
Add ACL table name associated with the rules (#263)
Browse files Browse the repository at this point in the history
And sort the output with table name and rule name
  • Loading branch information
zhenggen-xu authored and lguohan committed Jun 26, 2018
1 parent b292905 commit 3db4275
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/aclshow
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import swsssdk
import sys

from tabulate import tabulate
from natsort import natsorted

### temp file to save counter positions when doing clear counter action.
### if we could have a SAI command to clear counters will be better, so no need to maintain
Expand Down Expand Up @@ -253,10 +254,13 @@ class AclStat(object):
table_props.append(line)
print(tabulate(table_props, headers=['Property', 'Value']), "\n")

for table_name, rule_name in self.acl_rules.keys():
acl_rules_sort = self.acl_rules.keys()
acl_rules_sort = natsorted(acl_rules_sort, key=lambda x: (x[0], x[1]))

for table_name, rule_name in acl_rules_sort:
rule_props = []
rule = self.acl_rules[table_name, rule_name]
header = "ACL Rule: " + rule_name
header = "ACL Table: " + table_name + ", ACL Rule: " + rule_name
print(header)
print("="*len(header))
for rk in rule.keys():
Expand Down

0 comments on commit 3db4275

Please sign in to comment.