Browse Source

set interface and family MTUs; get mpls and iso ready

master
Marek Isalski 3 years ago
parent
commit
04380dc318
3 changed files with 68 additions and 17 deletions
  1. +30
    -3
      includes/junos-macros.j2
  2. +22
    -1
      includes/junos-v21-core-router/groups.j2
  3. +16
    -13
      includes/junos-v21-core-router/interfaces.j2

+ 30
- 3
includes/junos-macros.j2

@ -2,15 +2,42 @@
description "{% if interface.label %}{{ interface.label|replace('"','\\"') or "-" }}: {% endif %}{{ interface.description|replace('"','\\"') or "-" }}{% if interface.connected_endpoint %} ({{ interface.connected_endpoint.name|replace('"','\\"')|replace('.voneus.net','') }}{% if interface.connected_endpoint.device.name %} @ {{ interface.connected_endpoint.device.name|replace('.voneus.net','')|replace('"','\\"') }}{% endif %}){% endif %}{% if interface.cable %} via [{{ interface.cable.label.split("/")[-1] }}]{% endif %}{% if interface.link_peer %} to [{{ interface.link_peer.label or interface.link_peer.name }}{% if interface.link_peer.device %} @ {{ interface.link_peer.device.name.split("/")[-1]|replace('"','\\"')|replace('.voneus.net','') }}]{% endif %}{% endif %}" description "{% if interface.label %}{{ interface.label|replace('"','\\"') or "-" }}: {% endif %}{{ interface.description|replace('"','\\"') or "-" }}{% if interface.connected_endpoint %} ({{ interface.connected_endpoint.name|replace('"','\\"')|replace('.voneus.net','') }}{% if interface.connected_endpoint.device.name %} @ {{ interface.connected_endpoint.device.name|replace('.voneus.net','')|replace('"','\\"') }}{% endif %}){% endif %}{% if interface.cable %} via [{{ interface.cable.label.split("/")[-1] }}]{% endif %}{% if interface.link_peer %} to [{{ interface.link_peer.label or interface.link_peer.name }}{% if interface.link_peer.device %} @ {{ interface.link_peer.device.name.split("/")[-1]|replace('"','\\"')|replace('.voneus.net','') }}]{% endif %}{% endif %}"
{%- endmacro %} {%- endmacro %}
{%- macro interface_addresses(interface, interface_context) %}
{%- macro interface_common(interface, interface_context, mtu=True) %}
{%- if mtu and interface.mtu %}
mtu {{ interface.mtu }};
{%- endif %}
{%- endmacro %}
{%- macro interface_addresses(device, interface, interface_context, mtu=False) %}
family inet { family inet {
{%- if mtu and interface.mtu %}
mtu {{ interface.mtu }};
{%- endif %}
{%- for address in interface|get_addresses %}{% if address|ipv4 %} {%- for address in interface|get_addresses %}{% if address|ipv4 %}
address {{ address.address }}
address {{ address.address }}{% if address.address == device.primary_ip4.address %}{
primary;
preferred;
}{% endif %}
{%- endif %}{%- endfor %} {%- endif %}{%- endfor %}
} }
family inet6 { family inet6 {
{%- if mtu and interface.mtu %}
mtu {{ interface.mtu }};
{%- endif %}
{%- for address in interface|get_addresses %}{% if address|ipv6 %} {%- for address in interface|get_addresses %}{% if address|ipv6 %}
address {{ address.address }}
address {{ address.address }}{% if address.address == device.primary_ip6.address %}{
primary;
preferred;
}{% endif %}
{%- endif %}{%- endfor %} {%- endif %}{%- endfor %}
} }
{%- set tags = interface.tags|tags_to_map %}
{%- if 'core-isis-link' in tags %}
family iso;
family mpls;
{%- elif 'isis-loopback' in tags %}
family iso {
address {{ device.primary_ip4.address|ipv4_to_iso }};
}
{%- endif %}
{%- endmacro %} {%- endmacro %}

+ 22
- 1
includes/junos-v21-core-router/groups.j2

@ -28,6 +28,27 @@ groups {
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}
rfc-5735 {
routing-options {
martians {
128.0.0.0/16 orlonger allow;
191.255.0.0/16 orlonger allow;
223.255.255.0/24 orlonger allow;
}
}
routing-instances {
<*> {
routing-options {
martians {
128.0.0.0/16 orlonger allow;
191.255.0.0/16 orlonger allow;
223.255.255.0/24 orlonger allow;
}
}
}
}
}
} }
apply-groups [ {% for re in re_groups %}{{ re }}{% if not loop.last %} {% endif %}{% endfor %} ];
apply-groups [ {% for re in re_groups %}{{ re }} {% endfor %}rfc-5735 ];

+ 16
- 13
includes/junos-v21-core-router/interfaces.j2

@ -9,17 +9,18 @@ interfaces {
{%- endfor %} {%- endfor %}
{%- if '@' in interface.name %} {%- if '@' in interface.name %}
/* groups interface: {{ interface.name }} */
/* do not configure groups interface: {{ interface.name }} */
{%- elif interface.mgmt_only %} {%- elif interface.mgmt_only %}
/* management interface: {{ interface.name }} */
/* do not configure management-only interface: {{ interface.name }} */
{%- elif 'no-automation' in interface_tags %} {%- elif 'no-automation' in interface_tags %}
/* do not configure: {{ interface.name }} */
/* do not configure no-automation interface: {{ interface.name }} */
{% elif interface.lag %} {% elif interface.lag %}
{{ interface.name }} { {{ interface.name }} {
{{ macros.interface_description(interface, interface_context) }} {{ macros.interface_description(interface, interface_context) }}
{{ macros.interface_common(interface, interface_context, mtu=False) }}
gigether-options { gigether-options {
802.3ad {{ interface.lag.name }}; 802.3ad {{ interface.lag.name }};
} }
@ -27,6 +28,8 @@ interfaces {
{%- elif interface.name.startswith( 'lo' ) %} {%- elif interface.name.startswith( 'lo' ) %}
{{ interface.name }} { {{ interface.name }} {
{{ macros.interface_description(interface, interface_context) }} {{ macros.interface_description(interface, interface_context) }}
{{ macros.interface_common(interface, interface_context) }}
{%- for unit, subinterface in subinterfaces %} {%- for unit, subinterface in subinterfaces %}
unit {{ unit }} { unit {{ unit }} {
{%- if subinterface.untagged_vlan %} {%- if subinterface.untagged_vlan %}
@ -35,9 +38,9 @@ interfaces {
vlan-id {{ unit }}; vlan-id {{ unit }};
{%- endif %} {%- endif %}
{%- set subinterface_context = subinterface.tags|get_netbox_tags_contexts|contexts_merge_last %} {%- set subinterface_context = subinterface.tags|get_netbox_tags_contexts|contexts_merge_last %}
{# interface_vrf(subinterface, subinterface_context) #}
{# interface_common(subinterface, subinterface_context) #}
{{ macros.interface_addresses(subinterface, subinterface_context) }}
{{ macros.interface_description(subinterface, subinterface_context) }}
{{ macros.interface_common(subinterface, subinterface_context, mtu=False) }}
{{ macros.interface_addresses(device, subinterface, subinterface_context, mtu=False) }}
} }
{%- endfor %} {%- endfor %}
@ -49,7 +52,7 @@ interfaces {
link-speed 100g; link-speed 100g;
} }
{{ macros.interface_description(interface, interface_context) }} {{ macros.interface_description(interface, interface_context) }}
{# interface_common(interface, interface_context) #}
{{ macros.interface_common(interface, interface_context, mtu=True) }}
{%- elif interface.type.value != 'virtual' %} {%- elif interface.type.value != 'virtual' %}
{{ interface.name }} { {{ interface.name }} {
@ -57,9 +60,9 @@ interfaces {
{%- if not interface.mode or ( interface.mode.value == 'access' ) %} {%- if not interface.mode or ( interface.mode.value == 'access' ) %}
unit 0 { unit 0 {
{# interface_vrf(interface, interface_context) #}
{# interface_common(interface, interface_context) #}
{{ macros.interface_addresses(interface, interface_context) }}
{{ macros.interface_description(interface, interface_context) }}
{{ macros.interface_common(interface, interface_context, mtu=False) }}
{{ macros.interface_addresses(device, interface, interface_context, mtu=True) }}
} }
{%- elif interface.mode.value == 'tagged' %} {%- elif interface.mode.value == 'tagged' %}
vlan-tagging; vlan-tagging;
@ -79,9 +82,9 @@ interfaces {
vlan-id {{ unit }}; vlan-id {{ unit }};
{%- endif %} {%- endif %}
{%- set subinterface_context = subinterface.tags|get_netbox_tags_contexts|contexts_merge_last %} {%- set subinterface_context = subinterface.tags|get_netbox_tags_contexts|contexts_merge_last %}
{# interface_vrf(subinterface, subinterface_context) #}
{# interface_common(subinterface, subinterface_context) #}
{{ macros.interface_addresses(subinterface, subinterface_context) }}
{{ macros.interface_description(subinterface, subinterface_context) }}
{{ macros.interface_common(subinterface, subinterface_context, mtu=False) }}
{{ macros.interface_addresses(device, subinterface, subinterface_context, mtu=True) }}
} }
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}

Loading…
Cancel
Save