protocols { lldp { port-id-subtype interface-name; port-description-type interface-description; interface all; } } {# Find all networks related to this device and store it temporarly in the network dict for easy access later #} {%- set networks = {} %} {%- for network_name, network in v.distro_networks.items() %} {%- set device = network_name %} {%- if v.switches[device] and v.switches[device].distro_name == switch_name %} {%- set s = objects["public/switches"].switches[device] %} {%- set port = v.switches[device].distro_phy_port %} {%- if switch_name != 'd1.ring' %} {%- set ge0 = "-0/0/" ~ v.create_interface_ge0(port) %} {%- else %} {%- set ge0 = "-" ~ v.create_interface_vc(port) ~ "/0/" ~ v.create_interface_ge0(port) %} {%- endif %} {#- må bruke tags fra downstream switch -#} {%- set if_prefix = 'ge' -%} {%- if "multirate" in s.tags and "10g-copper" in s.tags -%} {%- set if_prefix = 'mge' -%} {%- elif "10g-uplink" in s.tags -%} {%- set if_prefix = 'xe' -%} {%- endif -%} {%- set ae = "ae" ~ v.create_interface_ae(port) %} {%- if switch_name == 'd1.ring' %} {% set ae = "ae{}".format(network.vlan) %} {%- endif %} {% do networks.update({ network_name: {'ae': "ae{}".format(network.vlan), 'fap_interface' : "{}{}".format(if_prefix, ge0), 'vlan_id': network.vlan }}) %} {% endif %} {% endfor %} {% for network_name, network in networks.items() %} event-options { policy {{ network.ae }}down { events snmp_trap_link_down; attributes-match { snmp_trap_link_down.interface-name matches "{{ network.ae }}$"; } then { change-configuration { retry count 10 interval 10; commands { "activate interfaces {{ network.fap_interface }} unit 0"; "deactivate interfaces {{ network.fap_interface }} ether-options"; } user-name tech; commit-options { log "Autoconfig-script: {{ network.ae }} went down so removed {{ network.fap_interface }} from bundle"; } } } } policy {{ network.ae }}up { events snmp_trap_link_up; attributes-match { snmp_trap_link_up.interface-name matches "{{ network.ae }}$"; } then { change-configuration { retry count 10 interval 10; commands { "deactivate interfaces {{ network.fap_interface }} unit 0"; "activate interfaces {{ network.fap_interface }} ether-options"; } user-name tech; commit-options { log "Autoconfig-script: {{ network.ae }} came up so added {{ network.fap_interface }} to bundle"; } } } } } {% endfor %} {# L2 VLANS-DELTAGERE #} vlans { {% for network_name, network in networks.items() %} {{ network_name }} { vlan-id {{ network.vlan_id }}; } {% endfor %} distro-mgmt { vlan-id 667; {% if "els-software" in v.switch_tags %} l3-interface irb.667; forwarding-options { dhcp-security { option-82 { circuit-id { prefix { host-name; } use-vlan-id; } } } } {% else %} l3-interface vlan.667; {% endif %} } edge-mgmt { vlan-id 666; } aps-mgmt { vlan-id 777; } ssid-the-gathering { vlan-id 778; } {% if switch_name == 'd1.ring' %} southcam { vlan-id 10; } tele-ipmi { vlan-id 11; } {% endif %} } {# ETHERNET SWITCHING OPTIONS #} {% if not "els-software" in v.switch_tags %} ethernet-switching-options { storm-control { {% for network_name, network in networks.items() %} interface {{ network.ae }}; {% endfor %} } secure-access-port { vlan edge-mgmt { dhcp-option82 { circuit-id { prefix hostname; use-vlan-id; } } } } } {% endif %} {# MGT-NETWORK #} interfaces { {% if "els-software" in v.switch_tags %} irb { {% else %} vlan { {% endif %} unit 667 { description "switch management"; family inet { filter { input mgmt-v4; } address {{ v.switches[switch_name]['mgmt_v4_addr'] }}/{{ v.switch_management_network['subnet4'] | cidr }}; } family inet6 { filter { input mgmt-v6; } address {{ v.switches[switch_name]['mgmt_v6_addr'] }}/{{ v.switch_management_network['subnet6'] | cidr }}; } } } } routing-options { rib inet.0 { static { route 0.0.0.0/0 next-hop {{ v.switch_management_network.gw4 }}; } } rib inet6.0 { static { route ::/0 next-hop {{ v.switch_management_network.gw6 }}; } } }