blob: 1ea18948d1e67c2d69bf6b30ecb612ba7774aa55 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
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 }};
}
}
}
|