File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,14 +233,17 @@ def __str__(self):
233233 self .term .hop_limit or self .term .port or self .term .protocol or
234234 self .term .protocol_except or self .term .source_address or
235235 self .term .source_address_exclude or self .term .source_port or
236- self .term .source_prefix or self .term .ttl )
236+ self .term .source_prefix or self .term .ttl )
237237
238238 # if the term name is default-* we will render this into the
239239 # appropriate default term name to be used in this filter.
240240 is_default_term = re .match (r"^ipv(4|6)\-default\-.*" , self .term .name ,
241241 re .IGNORECASE )
242242
243- if (not has_match_criteria and not is_default_term ):
243+ # if the term doesn't match on anything and isn't a default-term and
244+ # isn't a counter term, then we don't render it.
245+ if (not has_match_criteria and not is_default_term
246+ and not self .term .counter ):
244247 # this term doesn't match on anything and isn't a default-term
245248 logging .warning (
246249 "WARNING: term %s has no valid match criteria and "
Original file line number Diff line number Diff line change 359359 action:: deny
360360}
361361"""
362+ NO_MATCH_TERM_COUNTER = """
363+ term deny-and-count {
364+ counter:: deny-counter
365+ action:: deny
366+ }
367+ """
362368LONG_COMMENT_TERM_1 = """
363369term long-comment-term-1 {
364370 comment:: "this is very very very very very very very very very very very
@@ -801,6 +807,13 @@ def testDefaultDeny(self):
801807 self .assertIn ("match ipv4-default-all ipv4" , output , output )
802808 self .assertIn ("match ipv6-default-all ipv6" , output , output )
803809
810+ def testEmptyMatchDenyCounter (self ):
811+ atp = arista_tp .AristaTrafficPolicy (
812+ policy .ParsePolicy (GOOD_HEADER + NO_MATCH_TERM_COUNTER , self .naming ),
813+ EXP_INFO )
814+ output = str (atp )
815+ self .assertIn ("count deny-counter" , output , output )
816+
804817 def testIcmpType (self ):
805818 atp = arista_tp .AristaTrafficPolicy (
806819 policy .ParsePolicy (GOOD_HEADER + GOOD_TERM_3 , self .naming ), EXP_INFO )
You can’t perform that action at this time.
0 commit comments