-
Notifications
You must be signed in to change notification settings - Fork 58
/
srlinux.macro.j2
55 lines (54 loc) · 1.96 KB
/
srlinux.macro.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{% macro format_area(a) -%}
{{ '0.0.0.0' if not a else a | ipv4 }}
{%- endmacro %}
{% macro ospf_config(pid,af,vrf,ospf,vrf_interfaces) %}
- path: network-instance[name={{ vrf|default('default') }}]
val:
router-id: {{ ospf.router_id }}
protocols:
ospf:
instance:
- name: "{{ pid }}"
version: {{ 'ospf-v2' if af=='ipv4' else 'ospf-v3' }}
{% if af!='ipv4' %}
address-family: ipv6-unicast
{% endif %}
admin-state: enable
max-ecmp-paths: 64
{% if ldp is defined and ldp.igp_sync|default(True) %}
ldp-synchronization: { }
{% endif %}
{% if ospf.reference_bandwidth is defined %}
reference-bandwidth: {{ ospf.reference_bandwidth * 1000 }} # in kbps
{% endif %}
area:
{% if vrf=='default' %}
- area-id: {{ format_area(ospf.area) }}
interface:
- interface-name: system0.0
passive: True
{% endif %}
{% for l in vrf_interfaces if (l.vlan is not defined or l.vlan.mode|default('irb')!='bridge') and l.subif_index is not defined %}
{% set if_name_index = l.ifname.split('.') %}
{% set if_name = if_name_index[0] if l.type!='stub' else "lo0" %}
{% set if_index = if_name_index[1] if if_name_index|length > 1 else l.ifindex if l.type=='stub' else '0' %}
{% if 'ospf' not in l %}
# OSPF not configured on external interface {{ if_name }}
{% else %}
- area-id: {{ format_area(l.ospf.area) }}
interface:
- interface-name: {{ if_name }}.{{ if_index }}
{% if l.ospf.passive | default(False) %}
passive: True
{% endif %}
{% if l.ospf.network_type|default("") in ["broadcast","point-to-point"] %}
interface-type: "{{ l.ospf.network_type }}"
{% endif %}
failure-detection:
enable-bfd: {{ l.ospf.bfd|default(False) }}
{% if l.ospf.cost is defined %}
metric: {{ l.ospf.cost }}
{% endif %}
{% endif %}
{% endfor %}
{% endmacro %}