Skip to content

Commit 3db4275

Browse files
zhenggen-xulguohan
authored andcommitted
Add ACL table name associated with the rules (#263)
And sort the output with table name and rule name
1 parent b292905 commit 3db4275

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/aclshow

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import swsssdk
2929
import sys
3030

3131
from tabulate import tabulate
32+
from natsort import natsorted
3233

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

256-
for table_name, rule_name in self.acl_rules.keys():
257+
acl_rules_sort = self.acl_rules.keys()
258+
acl_rules_sort = natsorted(acl_rules_sort, key=lambda x: (x[0], x[1]))
259+
260+
for table_name, rule_name in acl_rules_sort:
257261
rule_props = []
258262
rule = self.acl_rules[table_name, rule_name]
259-
header = "ACL Rule: " + rule_name
263+
header = "ACL Table: " + table_name + ", ACL Rule: " + rule_name
260264
print(header)
261265
print("="*len(header))
262266
for rk in rule.keys():

0 commit comments

Comments
 (0)