sonic-buildimage/dockers/docker-fpm-frr/frr/common/functions.conf.j2
Tamer Ahmed 6754635010 [cfggen] Make Jinja2 Template Python 3 Compatible
Jinja2 templates rendered using Python 3 interpreter, are required
to conform with Python 3 new semantics.

singed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
2020-09-30 07:07:43 -07:00

36 lines
938 B
Django/Jinja

{% macro get_ipv4_loopback_address(interfaces, loopbackname) -%}
{% set L = namespace(ip=None) %}
{% for name, prefix in interfaces|pfx_filter %}
{% if name == loopbackname %}
{% if prefix | ipv4 %}
{% set L.ip = prefix %}
{% endif %}
{% endif %}
{% endfor %}
{{ L.ip }}
{%- endmacro %}
{% macro get_ipv6_loopback_address(interfaces, loopbackname) -%}
{% set L = namespace(ip=None) %}
{% for name, prefix in interfaces|pfx_filter %}
{% if name == loopbackname %}
{% if prefix | ipv6 %}
{% set L.ip = prefix %}
{% endif %}
{% endif %}
{% endfor %}
{{ L.ip }}
{%- endmacro %}
{% macro get_vnet_interfaces(interfaces) -%}
{% set L = namespace(intfs=[]) %}
{% set vnet_intfs = [] %}
{% for (key, metadata) in interfaces.items() %}
{% if "vnet_name" in metadata %}
{% set vnet_intfs = vnet_intfs.append(key) %}
{% endif %}
{% endfor %}
{% set L.intfs = vnet_intfs %}
{{ L.intfs }}
{%- endmacro %}