diff --git a/juniper-macros.j2 b/juniper-macros.j2 index 9b9552a..3e8cf10 100644 --- a/juniper-macros.j2 +++ b/juniper-macros.j2 @@ -112,91 +112,91 @@ chassis { {%- endmacro %} -{% macro interfaceconfig(interface,rack = None) -%} -{% if not ('-' in interface.name) or interface.description or interface.lag or interface.ip_addresses.count() or interface.connected_endpoints or interface.mode or interface.tagged_vlans.all() or interface.untagged_vlan %} +{%- macro interfaceconfig(interface,rack = None) -%} +{%- if not ('-' in interface.name) or interface.description or interface.lag or interface.ip_addresses.count() or interface.connected_endpoints or interface.mode or interface.tagged_vlans.all() or interface.untagged_vlan %} {{ interface.name }} { -{% if interface.description %} +{%- if interface.description %} description "{{ interface.description }}"; -{% endif %} -{% if interface.mtu and not interface.lag %} +{%- endif %} +{%- if interface.mtu and not interface.lag %} mtu {{ interface.mtu }}; -{% endif %} -{% if interface.device.role.name in ['Provide Core'] %} +{%- endif %} +{%- if interface.device.role.name in ['Provide Core'] %} flexible-vlan-tagging; native-vlan-id 1; encapsulation flexible-ethernet-services; -{% endif %} -{% if interface.lag %} +{%- endif %} +{%- if interface.lag %} ether-options { 802.3ad {{ interface.lag.name }}; } -{% endif %} -{% if interface.name.startswith('ae') %} -{% if interface.custom_field_data['esi_lag'] %} +{%- endif %} +{%- if interface.name.startswith('ae') %} +{%- if interface.custom_field_data['esi_lag'] %} esi { auto-derive { lacp; } all-active; } -{% endif %} +{%- endif %} aggregated-ether-options { lacp { periodic fast; -{% if interface.custom_field_data['system_id'] %} +{%- if interface.custom_field_data['system_id'] %} system-id {{ interface.custom_field_data['system_id'] }}; -{% elif interface.custom_field_data['esi_lag'] %} +{%- elif interface.custom_field_data['esi_lag'] %} system-id 00:00:{{ '%02d' % rack|int }}:{% if interface.name[2:]|int < 99 %}{{ '%02d' % interface.name[2:]|int }}{% else %}{{ '%02x' % interface.name[2:]|int }}{% endif %}:00:01; -{% endif %} +{%- endif %} } } -{% endif %} -{% if interface.ip_addresses.count() > 0 %} +{%- endif %} +{%- if interface.ip_addresses.count() > 0 %} unit 0 { -{% if (interface.connected_endpoints) and (interface.connected_endpoints[0].device.role.name == 'Provider Core') %} +{%- if (interface.connected_endpoints) and (interface.connected_endpoints[0].device.role.name == 'Provider Core') %} vlan-id 1; -{% endif %} +{%- endif %} family inet { {% if interface.ip_addresses.first().status == 'reserved' %}inactive: {% endif %}address {{ interface.ip_addresses.first().address }}; } } -{% endif %} -{% if interface.device.role.name in ['Leaf','Spine'] %} -{% if interface.mode != '' %} +{%- endif %} +{%- if interface.device.role.name in ['Leaf','Spine'] %} +{%- if interface.mode != '' %} unit 0 { family ethernet-switching { -{% if interface.mode=='ACCESS' %} +{%- if interface.mode=='ACCESS' %} interface-mode access; vlan { members {{ interface.untagged_vlan.vid }}; } -{% elif interface.mode=='TAGGED' %} +{%- elif interface.mode=='TAGGED' %} interface-mode trunk; vlan { members [ {% for vlan in interface.tagged_vlans %}{{ vlan.vid }} {% endfor %}]; } -{% elif interface.mode=='TAGGED_ALL' %} +{%- elif interface.mode=='TAGGED_ALL' %} interface-mode trunk; vlan { members [ all ]; } -{% endif %} +{%- endif %} storm-control default; } } -{% elif interface.device.role.name in ['Provider Core'] and interface.connected_endpoints %} -{% if interface.connected_endpoints[0].device.role.name in ['Provider Edge'] %} -{% for vlan in interface.tagged_vlans %} +{%- elif interface.device.role.name in ['Provider Core'] and interface.connected_endpoints %} +{%- if interface.connected_endpoints[0].device.role.name in ['Provider Edge'] %} +{%- for vlan in interface.tagged_vlans %} unit {{ vlan.vid }} { encapsulation vlan-vpls; vlan-id {{ vlan.vid }}; } -{% endfor %} -{% endif %} -{% endif %} -{% endif %} +{%- endfor %} +{%- endif %} +{%- endif %} +{%- endif %} } -{% endif %} +{%- endif %} {%- endmacro %} {% macro interfacesection(device,vlans) %}