diff options
Diffstat (limited to 'examples/tg23/templates/juniper-distro-non-els.conf')
| -rw-r--r-- | examples/tg23/templates/juniper-distro-non-els.conf | 484 |
1 files changed, 484 insertions, 0 deletions
diff --git a/examples/tg23/templates/juniper-distro-non-els.conf b/examples/tg23/templates/juniper-distro-non-els.conf new file mode 100644 index 0000000..c96d8f7 --- /dev/null +++ b/examples/tg23/templates/juniper-distro-non-els.conf @@ -0,0 +1,484 @@ +{%- set switch_name = options["switch"] %} +{%- import "vars.conf" as v with context %} + +{% include "global.conf" %} + +{%- set floor_distros = [ + 'd1.floor', + 'd2.floor', + 'd3.floor', + 'd4.floor', + 'd5.floor', + 'd6.floor', + ] +%} + +{%- set all_networks = [] -%} +{%- set networks = {} -%} +{%- set vlans_on_ae = {} -%} + +{# SECTION: FIND AND UTSKUTT DISTROS #} +{%- for switchname, interface in v.device_tree[switch_name].items() -%} + {# {{ switchname }}: #} + {%- if "distro-utskutt" in v.switches2[switchname].tags -%} + {%- do all_networks.append(switchname) -%} + {%- if switchname in v.device_tree -%} + {%- for edge_switch_name, interface2 in v.device_tree[switchname].items() -%} + {# {{ edge_switch_name }} #} + {%- do all_networks.append(edge_switch_name) -%} + {%- endfor -%} + {%- endif -%} + {%- else -%} + {%- do all_networks.append(switchname) -%} + {%- endif -%} +{%- endfor -%} + +{# SECTION: FIND AND ADD INTERFACES #} +{%- for edge_network_name in all_networks -%} + {%- set net = v.distro_networks[edge_network_name] -%} + {%- set edge_device = objects["public/switches"].switches[edge_network_name] -%} + + {%- set port = v.device_tree[switch_name][edge_network_name] -%} + + {# dette er hvis kant nettverket er direkte på distro (ikke utskutt) #} + {%- set interfaces = {} -%} + {%- if edge_device.distro_name == switch_name -%} + {%- if switch_name in floor_distros -%} + {%- set ge0 = "-0/0/" ~ v.create_interface_ge0(port) -%} + {%- set ge1 = "-1/0/" ~ v.create_interface_ge0(port) -%} + {%- set ge2 = "-2/0/" ~ v.create_interface_ge0(port) -%} + {%- elif "distro-utskutt" in edge_device.tags -%} + {%- set fpc = v.create_interface_vc(port) -%} + {%- if fpc in ("1", "4") -%} {# FPC 1 and 4 is ex4600 #} + {%- set ge0 = "-" ~ v.create_interface_vc(port) ~ "/0/" ~ v.create_interface_ge0(port) -%} + {%- set ge1 = "-" ~ v.create_interface_vc(port) ~ "/0/" ~ v.create_interface_ge1(port) -%} + {%- else -%} + {%- set ge0 = "-" ~ v.create_interface_vc(port) ~ "/2/" ~ v.create_interface_ge0(port) -%} + {%- set ge1 = "-" ~ v.create_interface_vc(port) ~ "/2/" ~ v.create_interface_ge1(port) -%} + {%- endif -%} + {%- elif switch_name == 'd1.ring' -%} + {%- set ge0 = "-" ~ v.create_interface_vc(port) ~ "/0/" ~ v.create_interface_ge0(port) -%} + {%- set ge1 = "-" ~ v.create_interface_vc(port) ~ "/0/" ~ v.create_interface_ge1(port) -%} + {%- else -%} + {%- set ge0 = "-0/0/" ~ v.create_interface_ge0(port) -%} + {%- set ge1 = "-0/0/" ~ v.create_interface_ge1(port) -%} + {%- endif -%} + + {#- må bruke tags fra downstream switch -#} + {%- set if_prefix = 'ge' -%} + {%- if "multirate" in edge_device.tags and "10g-copper" in edge_device.tags -%} + {%- set if_prefix = 'mge' -%} + {%- elif "10g-uplink" in edge_device.tags -%} + {%- set if_prefix = 'xe' -%} + {%- endif -%} + + {%- set ae = "ae" ~ v.create_interface_ae(port) -%} + {%- if "distro-utskutt" in edge_device.tags -%} + {%- set ae = v.ustkutt_distro_ae[edge_network_name] -%} + {%- elif "distro-utskutt" in v.switch_tags -%} + {%- set ae = "ae{}".format(net.vlan) -%} + {%- elif switch_name not in floor_distros -%} + {%- set ae = "ae{}".format(net.vlan) -%} + {%- endif -%} + + {%- set interfaces = {'ge0': "{}{}".format(if_prefix, ge0), 'ge1': "{}{}".format(if_prefix, ge1), 'ge2': "{}{}".format(if_prefix, ge2)} -%} + + {%- else -%} + {% set ae = networks[v.switches[edge_network_name]['distro_name']]['ae'] -%} + {%- endif -%} + +{# SECTION: FIND AND ADD VLANS #} + {%- if ae not in vlans_on_ae -%} + {%- do vlans_on_ae.update({ae: []}) -%} + {%- endif -%} + {%- do vlans_on_ae[ae].append(edge_network_name) -%} + + {%- if "wifi" in edge_device.tags -%} + {%- do vlans_on_ae[ae].append("aps-mgmt") -%} + {%- do vlans_on_ae[ae].append("ssid-the-gathering") -%} + {% endif %} + {%- if "net-event-arena" in edge_device.tags -%} + {%- do vlans_on_ae[ae].append("event-arena") -%} + {%- endif -%} + {%- if "net-event-artnet" in edge_device.tags -%} + {%- do vlans_on_ae[ae].append("event-artnet") -%} + {%- endif -%} + {%- if "net-event-activities" in edge_device.tags -%} + {%- do vlans_on_ae[ae].append("event-activites") -%} + {%- endif -%} + {%- if "net-location-beredskap" in edge_device.tags -%} + {%- do vlans_on_ae[ae].append("location-beredskap") -%} + {%- endif -%} + + {# uggc Mapping edge '{{ edge_network_name }}' Downlink: {{ ae }} If:{{ interfaces }} Edge tags: {{ edge_device.tags }} Vlans on AE: {{ vlans_on_ae[ae] }} #} + {%- do networks.update({ edge_network_name: + {'l3_device': 'r1.tele', + 'ae' : ae, + 'vlan_id': net.vlan if net else none, + 'if_prefix' : if_prefix, + 'interfaces' : interfaces, + 'edge_switch_tags' : edge_device.tags, + 'distro' : switch_name + }}) + %} +{%- endfor %} + + +{# SECTION: JUNOS CONFIG#} +{%- if switch_name in floor_distros %} +interfaces { + interface-range aps { + {% if "multirate" in v.switch_tags %} + member-range mge-0/0/46 to mge-0/0/47; + member-range mge-1/0/46 to mge-1/0/47; + member-range mge-2/0/46 to mge-2/0/47; + description "C: AP - VLAN 777 untagged (mgmt) - VLAN 778 tagged"; + unit 0 { + family ethernet-switching { + port-mode trunk; + native-vlan-id 777; + vlan { + members [ ssid-the-gathering ]; + } + } + } + {% elif switch_name in floor_distros %} + member-range ge-0/0/36 to ge-0/0/47; + member-range ge-1/0/36 to ge-1/0/47; + member-range ge-2/0/36 to ge-2/0/47; + description "C: AP - VLAN 777 untagged (mgmt) - VLAN 778 tagged"; + unit 0 { + family ethernet-switching { + native-vlan-id 777; + port-mode trunk; + vlan { + members [ ssid-the-gathering ]; + } + } + } + {% endif %} + } +} +{%- endif %} + + +{# SECTION: JUNOS DOWNSTREAM-INTERFACES #} +interfaces { +{% for network_name, network in networks.items() %} +{% if network.distro == switch_name and network.interfaces|length > 0 %} + {{ network.interfaces['ge0'] }} { + description "G: {{ network_name }} {{ network.if_prefix }}-0/0/44 ({{ network.ae }})"; + {# This is due to FAP. One uplink to switch can't be in LAG since its + not configured on the other end. And for FAP to work it has to be able + to be able to get DHCP. Therefor, we check if the AE to switch is UP. + If it is not then we configure one link to not be in the LAG #} + {% if v.states[network.distro] is defined and v.states[network.distro].ifs[network.ae] is defined and v.states[network.distro].ifs[network.ae].live is defined %} + ether-options { + 802.3ad {{ network.ae }}; + } + inactive: unit 0 { + family ethernet-switching { + port-mode access; + vlan { + members edge-mgmt; + } + } + } + {% else %} + inactive: ether-options { + 802.3ad {{ network.ae }}; + } + unit 0 { + family ethernet-switching { + port-mode access; + vlan { + members edge-mgmt; + } + } + } + {% endif %} + } + {% if "2-uplinks" in network.edge_switch_tags or "3-uplinks" in network.edge_switch_tags %} + {{ network.interfaces['ge1'] }} { + description "G: {{ network_name }} {{ network.if_prefix }}-0/0/45 ({{ network.ae }})"; + ether-options { + 802.3ad {{ network.ae }}; + } + } + {% endif %} + {% if "3-uplinks" in network.edge_switch_tags %} + {{ network.interfaces['ge2'] }} { + description "G: {{ network_name }} {{ network.if_prefix }}-0/0/46 ({{ network.ae }})"; + ether-options { + 802.3ad {{ network.ae }}; + } + } + {% endif %} + {{ network.ae }} { + description "B: {{ network_name }} ae0"; + aggregated-ether-options { + lacp { + active; + } + } + unit 0 { + family ethernet-switching { + port-mode trunk; + vlan { + members [ edge-mgmt {% if "distro-utskutt" in network.edge_switch_tags %} distro-mgmt {% endif %} {% for net in vlans_on_ae[network.ae] %}{% if net == network_name and "distro-utskutt" in network.edge_switch_tags %}{% else %}{{ net }} {% endif %}{% endfor %} ]; + } + } + } + } +{% endif %} +{% endfor %} +} + +{# SECTION: JUNOS CORE-INTERFACES #} +interfaces { + {{ v.distrodata[switch_name]['if1'] }} { + description "G: {{v.distrodata[switch_name]['uplink_device']}} {{ v.distrodata[switch_name]['remote_phy1'] }} (ae0)"; + ether-options { + 802.3ad ae0; + } + } + {{ v.distrodata[switch_name]['if2'] }} { + description "G: {{v.distrodata[switch_name]['uplink_device']}} {{ v.distrodata[switch_name]['remote_phy2'] }} (ae0)"; + ether-options { + 802.3ad ae0; + } + } + ae0 { + description "B: {{v.distrodata[switch_name]['uplink_device']}} {{ v.distrodata[switch_name]['remote_ae'] }}"; + aggregated-ether-options { + lacp { + active; + } + } + unit 0 { + family ethernet-switching { + port-mode trunk; + vlan { + members all; + } + } + } + } +} + +event-options { +{% for network_name, network in networks.items() %} +{% if network.distro == switch_name and network.interfaces|length > 0 %} + 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.interfaces['ge0'] }} unit 0"; + "deactivate interfaces {{ network.interfaces['ge0'] }} ether-options"; + } + user-name tech; + commit-options { + log "Autoconfig-script: {{ network.ae }} went down so removed {{ network.interfaces['ge0'] }} 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.interfaces['ge0'] }} unit 0"; + "activate interfaces {{ network.interfaces['ge0'] }} ether-options"; + } + user-name tech; + commit-options { + log "Autoconfig-script: {{ network.ae }} came up so added {{ network.interfaces['ge0'] }} to bundle"; + } + } + } + } + {% endif %} +{% endfor %} +} +vlans { + {% if switch_name == 'd1.ring' %} + southcam { + vlan-id 10; + } + tele-ipmi { + vlan-id 11; + } + {% endif %} + {% if switch_name not in floor_distros %} + event-arena { + vlan-id 3000; + } + event-artnet { + vlan-id 3001; + } + event-activites { + vlan-id 3002; + } + location-beredskap { + vlan-id 3003; + } + {% endif %} + edge-mgmt { + vlan-id 666; + } + distro-mgmt { + vlan-id 667; + l3-interface vlan.667; + } +{% for network_name, network in networks.items() %} +{%- if network.vlan_id is not none %} + {{ network_name }} { + vlan-id {{ network.vlan_id }}; + } +{% endif %} +{% endfor %} + aps-mgmt { + vlan-id 777; + } + ssid-the-gathering { + vlan-id 778; + } +} + +protocols { + lldp { + port-id-subtype interface-name; + port-description-type interface-description; + interface all; + } +} + +interfaces { + vlan { + 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 }}; + } + } + } + +protocols { + rstp { + {% if "distro-utskutt" in v.switch_tags %} + bridge-priority 4k; + {% else %} + bridge-priority 8k; + {% endif %} + } +} + +ethernet-switching-options { + storm-control { + {% for network_name, network in networks.items() %} + {%- if network.ae is defined %} + interface {{ network.ae }}; + {% endif %} + {% endfor %} + } + secure-access-port { + vlan edge-mgmt { + dhcp-option82 { + circuit-id { + prefix hostname; + use-vlan-id; + } + } + } + } +} + + +{# some static ports on d1.ring #} +{% if switch_name == 'd1.ring' %} +interfaces { + ge-0/0/23 { + description "C: southcam - VLAN 10 (static-ip)"; + unit 0 { + family ethernet-switching { + vlan { + members southcam; + } + } + } + } + ge-5/0/22 { + description "C: bamsemums-ipmi - VLAN 11"; + unit 0 { + family ethernet-switching { + vlan { + members tele-ipmi; + } + } + } + } + ge-5/0/23 { + description "C: krokodille-ipmi - VLAN 11"; + unit 0 { + family ethernet-switching { + vlan { + members tele-ipmi; + } + } + } + } +} +{% endif %} + +{% if v.vc_config[switch_name] %} +virtual-chassis { + preprovisioned; + vcp-snmp-statistics; +{% for member in v.vc_config[switch_name] %} + member {{ loop.index-1 }} { + serial-number {{ member.sn }}; + {% if member.re %} + role routing-engine; + {% else %} + role line-card; + {% endif %} + {% if member.loc is defined %} + location {{ member.loc }}; + {% endif %} + } +{% endfor %} +} +{% endif %}
\ No newline at end of file |
