Skip to content

Commit

Permalink
Changing Nokia options from pre2024 to post2024 and nostats to filter…
Browse files Browse the repository at this point in the history
…stats inverting the defaults. (#367)

* Changing Nokia options from pre2024 to post2024 and nostats to filterstats inverting the defaults.

* Adding new tests ref file.

* Formatting

* Changing tests back to using the new format.

* Changing tests back to using the new format.

* Changing stats to default for tests and replacing the nostats test.

* Changing stats to default for tests and replacing the nostats test.

* Updating comment for r24.3.

* Fixing documentation for this change.
  • Loading branch information
ankenyr committed Apr 18, 2024
1 parent a7cfada commit 3221d59
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
13 changes: 7 additions & 6 deletions aerleon/lib/nokiasrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,22 @@ def _TranslateTerms(

for af in srl_acl_entries.keys():
if srl_acl_entries[af]:
# Accomodate pre-2024 filter syntax if requested
if 'pre2024' in filter_options:
key = "ipv4-filter" if af == 'inet' else "ipv6-filter"
else:
# r24.3 changed the syntax for filters. For r24.3 or higher use the option `r24.3`.
if 'r24.3' in filter_options:
key = "acl-filter"
else:
key = "ipv4-filter" if af == 'inet' else "ipv6-filter"

ip_filter = {
key: {
'_annotate': " ".join(aclgenerator.AddRepositoryTags()),
'name': filter_name,
'description': desc,
'statistics-per-entry': 'nostats' not in filter_options,
'entry': srl_acl_entries[af],
}
}
if 'pre2024' not in filter_options:
if 'stats' in filter_options:
ip_filter[key]['statistics-per-entry'] = True
if 'r24.3' in filter_options:
ip_filter[key]['type'] = "ipv4" if af == 'inet' else "ipv6"
self.acl_sets.append(ip_filter)
6 changes: 3 additions & 3 deletions docs/reference/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -1083,15 +1083,15 @@ The Nokia SR Linux header designation has the following format:

```yaml
targets:
nokiasrl: {section_name} {inet|inet6|mixed} {nostats} {pre2024}
nokiasrl: {section_name} {inet|inet6|mixed} {stats} {r24.3}
```

* _section_name_: specifies the name of the section all terms in this header apply to.
* _inet_: specifies that the resulting filter should only render IPv4 addresses.
* _inet6_: specifies that the resulting filter should only render IPv6 addresses.
* _mixed_: specifies that the resulting filter should render both IPv4 and IPv6 addresses.
* _nostats_: Do not collect stats for ACL entries (default: enable per ACL stats)
* _pre2024_: Use old format (pre release 24.3.1)
* _stats_: Collect stats for ACL entries
* _r24.3_: Use new format (post release 24.3.1)

(Required keywords option and verbatim are not supported)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
],
"name": "good-name-v4",
"statistics-per-entry": false,
"statistics-per-entry": true,
"type": "ipv4"
}
}
Expand Down
10 changes: 5 additions & 5 deletions tests/regression/nokiasrl/nokiasrl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@
GOOD_HEADER = """
header {
comment:: "The general policy comment."
target:: nokiasrl good-name-v4 inet
target:: nokiasrl good-name-v4 inet r24.3 stats
}
"""

GOOD_HEADER_MIXED = """
header {
comment:: "GOOD_HEADER_MIXED comment."
target:: nokiasrl good-name-mixed mixed
target:: nokiasrl good-name-mixed mixed r24.3 stats
}
"""


GOOD_HEADER_NO_STATS = """
header {
comment:: "The general policy comment."
target:: nokiasrl good-name-v4 inet nostats
target:: nokiasrl good-name-v4 inet stats r24.3
}
"""

GOOD_HEADER_PRE2024 = """
header {
comment:: "The general policy comment."
target:: nokiasrl good-name-mixed mixed pre2024
target:: nokiasrl good-name-mixed mixed stats
}
"""

Expand Down Expand Up @@ -390,7 +390,7 @@
GOOD_HEADER_INET6 = """
header {
comment:: "The general policy comment."
target:: nokiasrl good-name-v6 inet6
target:: nokiasrl good-name-v6 inet6 r24.3 stats
}
"""

Expand Down

0 comments on commit 3221d59

Please sign in to comment.