bird: param bird__bgp_sessions is now a dict

This commit is contained in:
jeltz 2023-07-05 01:20:47 +02:00
parent 9de88d0a28
commit 75f0ee785b
Signed by: jeltz
GPG key ID: 800882B66C0C3326

View file

@ -125,10 +125,10 @@ bgp_local_pref = {{ filter.local_pref }};
{% endmacro %} {% endmacro %}
{# FIXME: massive cleanup required #} {# FIXME: massive cleanup required #}
{% for session in bird__bgp_sessions %} {% for name, session in bird__bgp_sessions.items() %}
{% for version in [4, 6] %} {% for version in [4, 6] %}
{% for direction in ["import", "export"] %} {% for direction in ["import", "export"] %}
filter bgp{{ version }}_{{ direction }}_{{ session.name }} { filter bgp{{ version }}_{{ direction }}_{{ name }} {
{% for filter in session[direction] %} {% for filter in session[direction] %}
{% set negate = filter.negate | default(False) %} {% set negate = filter.negate | default(False) %}
{% set networks = {% set networks =
@ -165,7 +165,7 @@ filter bgp{{ version }}_{{ direction }}_{{ session.name }} {
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{% for session in bird__bgp_sessions %} {% for name, session in bird__bgp_sessions.items() %}
{% for local_address in session.local.address %} {% for local_address in session.local.address %}
{% set version = {% set version =
local_address local_address
@ -174,7 +174,7 @@ filter bgp{{ version }}_{{ direction }}_{{ session.name }} {
session.remote.address session.remote.address
| ansible.utils.ipaddr(version=version) | ansible.utils.ipaddr(version=version)
| first %} | first %}
protocol bgp bgp{{ version }}_{{ session.name }} { protocol bgp bgp{{ version }}_{{ name }} {
local {{ local_address }} as {{ session.local.as }}; local {{ local_address }} as {{ session.local.as }};
neighbor {{ remote_address }} as {{ session.remote.as }}; neighbor {{ remote_address }} as {{ session.remote.as }};
{{ "ipv4" if version == 4 else "ipv6" }} { {{ "ipv4" if version == 4 else "ipv6" }} {
@ -184,8 +184,8 @@ protocol bgp bgp{{ version }}_{{ session.name }} {
{% if session.direct | default(False) %} {% if session.direct | default(False) %}
direct; direct;
{% endif %} {% endif %}
import filter bgp{{ version }}_import_{{ session.name }}; import filter bgp{{ version }}_import_{{ name }};
export filter bgp{{ version }}_export_{{ session.name }}; export filter bgp{{ version }}_export_{{ name }};
}; };
} }
{% endfor %} {% endfor %}