From 3db42752130e6c27f010f365780fab87d285c001 Mon Sep 17 00:00:00 2001 From: zhenggen-xu Date: Tue, 26 Jun 2018 08:54:34 -0700 Subject: [PATCH] Add ACL table name associated with the rules (#263) And sort the output with table name and rule name --- scripts/aclshow | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/aclshow b/scripts/aclshow index b9c4777105c0..5b0849eea668 100755 --- a/scripts/aclshow +++ b/scripts/aclshow @@ -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 @@ -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():