interfaces {
|
|
|
|
{%- for interface, subinterfaces in device|get_interfaces|subinterfaces(".") %}
|
|
{%- set interface_context = interface.tags|get_netbox_tags_contexts|contexts_merge_last %}
|
|
|
|
{%- set interface_tags = [] %}
|
|
{%- for tag in interface.tags %}
|
|
{%- do interface_tags.append(tag.slug) %}
|
|
{%- endfor %}
|
|
|
|
{%- if '@' in interface.name %}
|
|
/* do not configure groups interface: {{ interface.name }} */
|
|
|
|
{%- elif interface.mgmt_only %}
|
|
/* do not configure management-only interface: {{ interface.name }} */
|
|
|
|
{%- elif 'no-automation' in interface_tags %}
|
|
/* do not configure no-automation interface: {{ interface.name }} */
|
|
|
|
{% elif interface.lag %}
|
|
{{ interface.name }} {
|
|
{{ macros.interface_description(interface, interface_context) }}
|
|
{{ macros.interface_common(interface, interface_context, mtu=False) }}
|
|
gigether-options {
|
|
802.3ad {{ interface.lag.name }};
|
|
}
|
|
|
|
{%- elif interface.name.startswith( 'lo' ) %}
|
|
{{ interface.name }} {
|
|
{{ macros.interface_description(interface, interface_context) }}
|
|
{{ macros.interface_common(interface, interface_context) }}
|
|
|
|
{%- for unit, subinterface in subinterfaces %}
|
|
unit {{ unit }} {
|
|
{%- if subinterface.untagged_vlan %}
|
|
vlan-id {{ subinterface.untagged_vlan.vid }};
|
|
{%- elif unit|int %}
|
|
vlan-id {{ unit }};
|
|
{%- endif %}
|
|
{%- set subinterface_context = subinterface.tags|get_netbox_tags_contexts|contexts_merge_last %}
|
|
{{ macros.interface_description(subinterface, subinterface_context) }}
|
|
{{ macros.interface_common(subinterface, subinterface_context, mtu=False) }}
|
|
{{ macros.interface_addresses(device, subinterface, subinterface_context, mtu=False) }}
|
|
}
|
|
{%- endfor %}
|
|
|
|
{%- elif interface.type.value == 'lag' %}
|
|
{{ interface.name }} {
|
|
vlan-tagging;
|
|
aggregated-ether-options {
|
|
minimum-links 1;
|
|
link-speed 100g;
|
|
}
|
|
{{ macros.interface_description(interface, interface_context) }}
|
|
{{ macros.interface_common(interface, interface_context, mtu=True) }}
|
|
|
|
{%- elif interface.type.value != 'virtual' %}
|
|
{{ interface.name }} {
|
|
{{ macros.interface_description(interface) }}
|
|
|
|
{%- if not interface.mode or ( interface.mode.value == 'access' ) %}
|
|
unit 0 {
|
|
{{ 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' %}
|
|
vlan-tagging;
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if ( not interface.mgmt_only ) and ( 'no-automation' not in interface_tags ) and ( '@' not in interface.name ) %}
|
|
{%- for tagged_vlan in interface.tagged_vlans %}{%- endfor %}
|
|
|
|
{%- if interface.mode.value == 'tagged' %}
|
|
{%- for unit, subinterface in subinterfaces %}
|
|
unit {{ unit }} {
|
|
{%- if subinterface.untagged_vlan %}
|
|
vlan-id {{ subinterface.untagged_vlan.vid }};
|
|
{%- elif unit|int %}
|
|
vlan-id {{ unit }};
|
|
{%- endif %}
|
|
{%- set subinterface_context = subinterface.tags|get_netbox_tags_contexts|contexts_merge_last %}
|
|
{{ macros.interface_description(subinterface, subinterface_context) }}
|
|
{{ macros.interface_common(subinterface, subinterface_context, mtu=False) }}
|
|
{{ macros.interface_addresses(device, subinterface, subinterface_context, mtu=True) }}
|
|
}
|
|
{%- endfor %}
|
|
{%- endif %}
|
|
}
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
fxp0 {
|
|
unit 0;
|
|
}
|
|
}
|