@@ -49,6 +49,7 @@ class AclLoader(object):
49
49
ACL_TABLE_TYPE_MIRROR = "MIRROR"
50
50
ACL_TABLE_TYPE_CTRLPLANE = "CTRLPLANE"
51
51
MIRROR_SESSION = "MIRROR_SESSION"
52
+ POLICER = "POLICER"
52
53
SESSION_PREFIX = "everflow"
53
54
54
55
min_priority = 1
@@ -92,10 +93,11 @@ def __init__(self):
92
93
self .read_tables_info ()
93
94
self .read_rules_info ()
94
95
self .read_sessions_info ()
96
+ self .read_policers_info ()
95
97
96
98
def read_tables_info (self ):
97
99
"""
98
- Read ACL tables information from Config DB
100
+ Read ACL_TABLE table from configuration database
99
101
:return:
100
102
"""
101
103
self .tables_db_info = self .configdb .get_table (self .ACL_TABLE )
@@ -105,17 +107,27 @@ def get_tables_db_info(self):
105
107
106
108
def read_rules_info (self ):
107
109
"""
108
- Read rules information from Config DB
110
+ Read ACL_RULE table from configuration database
109
111
:return:
110
112
"""
111
113
self .rules_db_info = self .configdb .get_table (self .ACL_RULE )
112
114
113
115
def get_rules_db_info (self ):
114
116
return self .rules_db_info
115
117
118
+ def read_policers_info (self ):
119
+ """
120
+ Read POLICER table from configuration database
121
+ :return:
122
+ """
123
+ self .policers_db_info = self .configdb .get_table (self .POLICER )
124
+
125
+ def get_policers_db_info (self ):
126
+ return self .policers_db_info
127
+
116
128
def read_sessions_info (self ):
117
129
"""
118
- Read ACL tables information from Config DB
130
+ Read MIRROR_SESSION table from configuration database
119
131
:return:
120
132
"""
121
133
self .sessions_db_info = self .configdb .get_table (self .MIRROR_SESSION )
@@ -128,15 +140,11 @@ def read_sessions_info(self):
128
140
self .sessions_db_info [key ]["status" ] = status
129
141
130
142
def get_sessions_db_info (self ):
131
- """
132
- Read mirror session information from Config DB
133
- :return:
134
- """
135
143
return self .sessions_db_info
136
144
137
145
def get_session_name (self ):
138
146
"""
139
- Read mirror session name from Config DB
147
+ Get requested mirror session name or default session
140
148
:return: Mirror session name
141
149
"""
142
150
if self .requested_session :
@@ -545,6 +553,25 @@ def show_session(self, session_name):
545
553
546
554
print (tabulate .tabulate (data , headers = header , tablefmt = "simple" , missingval = "" ))
547
555
556
+
557
+ def show_policer (self , policer_name ):
558
+ """
559
+ Show policer configuration.
560
+ :param policer_name: Optional. Policer name. Filter policers by specified name.
561
+ :return:
562
+ """
563
+ header = ("Name" , "Type" , "Mode" , "CIR" , "CBS" )
564
+
565
+ data = []
566
+ for key , val in self .get_policers_db_info ().iteritems ():
567
+ if policer_name and key != policer_name :
568
+ continue
569
+
570
+ data .append ([key , val ["meter_type" ], val ["mode" ], val .get ("cir" , "" ), val .get ("cbs" , "" )])
571
+
572
+ print (tabulate .tabulate (data , headers = header , tablefmt = "simple" , missingval = "" ))
573
+
574
+
548
575
def show_rule (self , table_name , rule_id ):
549
576
"""
550
577
Show ACL rules configuration.
@@ -648,6 +675,18 @@ def session(ctx, session_name):
648
675
acl_loader .show_session (session_name )
649
676
650
677
678
+ @show .command ()
679
+ @click .argument ('policer_name' , type = click .STRING , required = False )
680
+ @click .pass_context
681
+ def policer (ctx , policer_name ):
682
+ """
683
+ Show policer configuration.
684
+ :return:
685
+ """
686
+ acl_loader = ctx .obj ["acl_loader" ]
687
+ acl_loader .show_policer (policer_name )
688
+
689
+
651
690
@show .command ()
652
691
@click .argument ('table_name' , type = click .STRING , required = False )
653
692
@click .argument ('rule_id' , type = click .STRING , required = False )
0 commit comments