Skip to content

Commit f496ac8

Browse files
authored
IOS/XR BGP large communities + delete community lists (#3179)
1 parent dfa5eb6 commit f496ac8

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

netsim/ansible/templates/routing/iosxr/clist.j2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
{% set ckw = {
2+
'standard': 'community',
3+
'large': 'large-community'}
4+
%}
15
{% for cl_name,cl_data in routing.community|dictsort %}
26
!
3-
community-set {{ cl_name }}
7+
{{ ckw[cl_data.type] }}-set {{ cl_name }}
48
{% for p_entry in cl_data.value %}
59
{% if p_entry.regexp|default(False) %}
610
ios-regex '{{ p_entry._value }}'{% if not loop.last %},{% endif +%}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{#
2+
Delete communities -- implemented with a loop to deal with various community types
3+
#}
4+
{% set ckw = {
5+
'standard': 'community',
6+
'large': 'large-community'}
7+
%}
8+
{% for c_kw,c_value in p_entry.delete.community|default({})|dictsort %}
9+
{% if c_kw in ['standard','large'] %}
10+
delete {{ ckw[c_kw] }} in ({{ c_value|join(",") }})
11+
{% elif c_kw == 'list' %}
12+
{% for l_kw,l_value in c_value|dictsort if l_kw in ckw %}
13+
delete {{ ckw[l_kw] }} in {{ l_value }}
14+
{% endfor %}
15+
{% endif %}
16+
{% endfor %}

netsim/ansible/templates/routing/iosxr/policy-match.j2

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
{% set ckw = {
2+
'standard': 'community',
3+
'large': 'large-community'}
4+
%}
15
{% for match_kw,match_value in p_entry.match|default({})|dictsort %}
26
{% if loop.first %} if{% else %} and{% endif %}
37
{% if match_kw == 'prefix'
@@ -10,12 +14,12 @@
1014
%} not as-path in {{ match_value.deny }} and as-path in {{ match_value.permit }}{% endif %}
1115
{% if match_kw == 'community' %}{%
1216
for c_type,c_list in match_value.items()
13-
%} community matches-any {{ c_list }}{%
17+
%} {{ ckw[c_type] }} matches-any {{ c_list }}{%
1418
endfor %}{%
1519
endif %}
1620
{% if match_kw == '_xr_community' %}{%
1721
for c_type,c_list in match_value.items()
18-
%} not community matches-any {{ c_list.deny }} and community matches-any {{ c_list.permit }}{%
22+
%} not {{ ckw[c_type] }} matches-any {{ c_list.deny }} and {{ ckw[c_type] }} matches-any {{ c_list.permit }}{%
1923
endfor %}{%
2024
endif %}
2125
{% if loop.last %} then{% endif +%}

netsim/ansible/templates/routing/iosxr/policy.j2

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,7 @@ route-policy {{ pname }}
66
#}
77
{% include 'iosxr/policy-match.j2' %}
88
{% include 'iosxr/policy-set.j2' %}
9-
{#
10-
Delete communities -- implemented with a loop to deal with various community types
11-
#}
12-
{% for c_kw,c_value in p_entry.delete.community|default({})|dictsort %}
13-
{% if c_kw == 'standard' %}
14-
delete community in ({{ c_value|join(",") }})
15-
{% elif c_kw == 'large' %}
16-
delete large-community in ({{ c_value|join(",") }})
17-
{% endif %}
18-
{% endfor %}
9+
{% include 'iosxr/policy-delete.j2' %}
1910
{#
2011
Process action
2112
#}

netsim/devices/xr.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ features:
6767
aspath: True
6868
community:
6969
standard: True
70-
# large: True
70+
large: True
7171
policy:
7272
set:
7373
community:
@@ -82,12 +82,13 @@ features:
8282
community:
8383
standard: True
8484
large: True
85+
list: True
8586
match:
8687
prefix: True
8788
aspath: True
8889
community:
8990
standard: True
90-
# large: True
91+
large: True
9192
prefix: True
9293
static:
9394
vrf: True

0 commit comments

Comments
 (0)