Skip to content

Commit

Permalink
Update Arista generator to add additional indentation for counter terms.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 599547123
  • Loading branch information
Capirca Team committed Jan 18, 2024
1 parent 041cc7b commit f36c911
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions capirca/lib/arista_tp.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,7 @@ def _TranslatePolicy(self, pol, exp_info):
# appropriate default term name to be used in this filter.
default_term = re.match(r"^default\-.*", term.name, re.IGNORECASE)

# TODO(sulrich): if term names become unique to address
# families, this can be removed.
# remove if term names become unique to address family.
if (filter_type == "mixed" and ft == "inet6"):
term.name = af_map_txt[ft] + "-" + term.name

Expand Down Expand Up @@ -944,7 +943,7 @@ def __str__(self):
# if there are counters, export the list of counters
if counters:
str_counters = " ".join(counters)
config.Append(" ", "counter %s" % str_counters)
config.Append(" ", "counter %s" % str_counters)

for term in terms:
term_str = str(term)
Expand Down
11 changes: 5 additions & 6 deletions tests/lib/arista_tp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
GOOD_TERM_OWNER = """
term owner-term {
protocol:: tcp
owner:: foo@google.com
owner:: foo@gmail.com
action:: accept
}
"""
Expand All @@ -188,7 +188,7 @@
action:: accept
}
"""
# TODO(sulric): write a test for this term
# write a test for this term.
GOOD_TERM_19 = """
term minimize-prefix-list {
source-address:: INCLUDES
Expand Down Expand Up @@ -630,7 +630,7 @@ def testCounterCleanup(self):
policy.ParsePolicy(GOOD_HEADER + COUNTER_CLEANUP_TERM, self.naming),
EXP_INFO)
output = str(atp)
self.assertIn("counter test-cleanup-check", output, output)
self.assertIn(" counter test-cleanup-check", output, output)
self.assertIn("count test-cleanup-check", output, output)

def testDefaultDeny(self):
Expand Down Expand Up @@ -934,7 +934,7 @@ def testOwnerTerm(self):
policy.ParsePolicy(GOOD_HEADER + GOOD_TERM_OWNER, self.naming),
EXP_INFO)
output = str(atp)
self.assertIn("!! owner: foo@google.com", output, output)
self.assertIn("!! owner: foo@gmail.com", output, output)

# confirm that we don't generate a term for non-default
@mock.patch.object(arista_tp.logging, "warning")
Expand Down Expand Up @@ -1150,8 +1150,7 @@ def testInetInet6(self):
atp = arista_tp.AristaTrafficPolicy(
policy.ParsePolicy(GOOD_HEADER + INET_INET6, self.naming), EXP_INFO)
output = str(atp)
# we should not generate this term
# TODO(sulrich): we should, however, throw a warning
# we should not generate this term we should, however, throw a warning.
self.assertNotIn("match INET_INET6 ipv4", output, output)
self.assertNotIn("match ipv6-INET_INET6 ipv6", output, output)

Expand Down

0 comments on commit f36c911

Please sign in to comment.