]>
Commit | Line | Data |
---|---|---|
1 | save('proc_net_dev', <<'/proc/net/dev'); | |
2 | eth0: | |
3 | eth1: | |
4 | eth2: | |
5 | eth3: | |
6 | eth4: | |
7 | eth5: | |
8 | /proc/net/dev | |
9 | ||
10 | r(load('brbase')); | |
11 | ||
12 | # | |
13 | # Variables used for the various interfaces: | |
14 | # | |
15 | ||
16 | my $ip = '192.168.0.2/24'; | |
17 | my $gw = '192.168.0.1'; | |
18 | my $svcnodeip = '239.192.105.237'; | |
19 | my $physdev = 'eth0'; | |
20 | my $remoteip1 = '192.168.0.3'; | |
21 | my $remoteip2 = '192.168.0.4'; | |
22 | ||
23 | # | |
24 | # Hunk for the default bridge of the 'brbase' configuration | |
25 | # | |
26 | ||
27 | my $vmbr0_part = <<"PART"; | |
28 | auto vmbr0 | |
29 | iface vmbr0 inet static | |
30 | address 10.0.0.2/24 | |
31 | gateway 10.0.0.1 | |
32 | bridge-ports eth0 | |
33 | bridge-stp off | |
34 | bridge-fd 0 | |
35 | PART | |
36 | chomp $vmbr0_part; | |
37 | ||
38 | # | |
39 | # Configure eth1 statically, store its expected interfaces hunk in $eth1_part | |
40 | # and test! | |
41 | # | |
42 | ||
43 | $config->{ifaces}->{eth1} = { | |
44 | type => 'eth', | |
45 | method => 'static', | |
46 | address => $ip, | |
47 | gateway => $gw, | |
48 | families => ['inet'], | |
49 | autostart => 1 | |
50 | }; | |
51 | ||
52 | my $eth1_part = <<"PART"; | |
53 | auto eth1 | |
54 | iface eth1 inet static | |
55 | address $ip | |
56 | gateway $gw | |
57 | PART | |
58 | chomp $eth1_part; | |
59 | ||
60 | expect load('loopback') . <<"CHECK"; | |
61 | source-directory interfaces.d | |
62 | ||
63 | iface eth0 inet manual | |
64 | ||
65 | $eth1_part | |
66 | ||
67 | iface eth2 inet manual | |
68 | ||
69 | iface eth3 inet manual | |
70 | ||
71 | iface eth4 inet manual | |
72 | ||
73 | iface eth5 inet manual | |
74 | ||
75 | $vmbr0_part | |
76 | ||
77 | CHECK | |
78 | ||
79 | # | |
80 | # Add a bond for eth2 & 3 and check the new output | |
81 | # | |
82 | ||
83 | $config->{ifaces}->{bond0} = { | |
84 | type => 'bond', | |
85 | mtu => 1400, | |
86 | slaves => 'eth2 eth3', | |
87 | bond_mode => '802.3ad', | |
88 | bond_xmit_hash_policy => 'layer3+4', | |
89 | bond_miimon => 100, | |
90 | method => 'manual', | |
91 | families => ['inet'], | |
92 | autostart => 1 | |
93 | }; | |
94 | my $bond0_part = <<"PART"; | |
95 | auto bond0 | |
96 | iface bond0 inet manual | |
97 | bond-slaves eth2 eth3 | |
98 | bond-miimon 100 | |
99 | bond-mode 802.3ad | |
100 | bond-xmit-hash-policy layer3+4 | |
101 | mtu 1400 | |
102 | PART | |
103 | chomp $bond0_part; | |
104 | ||
105 | expect load('loopback') . <<"CHECK"; | |
106 | source-directory interfaces.d | |
107 | ||
108 | iface eth0 inet manual | |
109 | ||
110 | $eth1_part | |
111 | ||
112 | auto eth2 | |
113 | iface eth2 inet manual | |
114 | ||
115 | auto eth3 | |
116 | iface eth3 inet manual | |
117 | ||
118 | iface eth4 inet manual | |
119 | ||
120 | iface eth5 inet manual | |
121 | ||
122 | $bond0_part | |
123 | ||
124 | $vmbr0_part | |
125 | ||
126 | CHECK | |
127 | ||
128 | # | |
129 | # Add vxlan1 and 2 | |
130 | # | |
131 | ||
132 | $config->{ifaces}->{vxlan1} = { | |
133 | type => 'vxlan', | |
134 | method => 'manual', | |
135 | families => ['inet'], | |
136 | 'vxlan-id' => 1, | |
137 | 'vxlan-svcnodeip' => $svcnodeip, | |
138 | 'vxlan-physdev' => $physdev, | |
139 | autostart => 1 | |
140 | }; | |
141 | ||
142 | $config->{ifaces}->{vxlan2} = { | |
143 | type => 'vxlan', | |
144 | method => 'manual', | |
145 | families => ['inet'], | |
146 | 'vxlan-id' => 2, | |
147 | 'vxlan-local-tunnelip' => $ip, | |
148 | autostart => 1 | |
149 | }; | |
150 | ||
151 | my $vxlan12_part = <<"PART"; | |
152 | auto vxlan1 | |
153 | iface vxlan1 inet manual | |
154 | vxlan-id 1 | |
155 | vxlan-svcnodeip $svcnodeip | |
156 | vxlan-physdev $physdev | |
157 | ||
158 | auto vxlan2 | |
159 | iface vxlan2 inet manual | |
160 | vxlan-id 2 | |
161 | vxlan-local-tunnelip $ip | |
162 | PART | |
163 | chomp $vxlan12_part; | |
164 | ||
165 | expect load('loopback') . <<"CHECK"; | |
166 | source-directory interfaces.d | |
167 | ||
168 | iface eth0 inet manual | |
169 | ||
170 | $eth1_part | |
171 | ||
172 | auto eth2 | |
173 | iface eth2 inet manual | |
174 | ||
175 | auto eth3 | |
176 | iface eth3 inet manual | |
177 | ||
178 | iface eth4 inet manual | |
179 | ||
180 | iface eth5 inet manual | |
181 | ||
182 | $bond0_part | |
183 | ||
184 | $vmbr0_part | |
185 | ||
186 | $vxlan12_part | |
187 | ||
188 | CHECK | |
189 | ||
190 | # | |
191 | # Add vxlan3 and 3 bridges using vxlan1..3 | |
192 | # | |
193 | ||
194 | $config->{ifaces}->{vmbr1} = { | |
195 | mtu => 1400, | |
196 | type => 'bridge', | |
197 | method => 'manual', | |
198 | families => ['inet'], | |
199 | bridge_stp => 'off', | |
200 | bridge_fd => 0, | |
201 | bridge_ports => 'vxlan1', | |
202 | bridge_vlan_aware => 'yes', | |
203 | autostart => 1 | |
204 | }; | |
205 | ||
206 | $config->{ifaces}->{vmbr2} = { | |
207 | type => 'bridge', | |
208 | method => 'manual', | |
209 | families => ['inet'], | |
210 | bridge_stp => 'off', | |
211 | bridge_fd => 0, | |
212 | bridge_ports => 'vxlan2', | |
213 | autostart => 1 | |
214 | }; | |
215 | ||
216 | $config->{ifaces}->{vmbr3} = { | |
217 | type => 'bridge', | |
218 | method => 'manual', | |
219 | families => ['inet'], | |
220 | bridge_stp => 'off', | |
221 | bridge_fd => 0, | |
222 | bridge_ports => 'vxlan3', | |
223 | bridge_vlan_aware => 'yes', | |
224 | bridge_vids => '2-10', | |
225 | autostart => 1 | |
226 | }; | |
227 | ||
228 | my $vmbr123_part = <<"PART"; | |
229 | auto vmbr1 | |
230 | iface vmbr1 inet manual | |
231 | bridge-ports vxlan1 | |
232 | bridge-stp off | |
233 | bridge-fd 0 | |
234 | bridge-vlan-aware yes | |
235 | bridge-vids 2-4094 | |
236 | mtu 1400 | |
237 | ||
238 | auto vmbr2 | |
239 | iface vmbr2 inet manual | |
240 | bridge-ports vxlan2 | |
241 | bridge-stp off | |
242 | bridge-fd 0 | |
243 | ||
244 | auto vmbr3 | |
245 | iface vmbr3 inet manual | |
246 | bridge-ports vxlan3 | |
247 | bridge-stp off | |
248 | bridge-fd 0 | |
249 | bridge-vlan-aware yes | |
250 | bridge-vids 2-10 | |
251 | PART | |
252 | chomp $vmbr123_part; | |
253 | ||
254 | $config->{ifaces}->{vxlan3} = { | |
255 | type => 'vxlan', | |
256 | method => 'manual', | |
257 | families => ['inet'], | |
258 | 'vxlan-id' => 3, | |
259 | 'vxlan-remoteip' => [$remoteip1, $remoteip2], | |
260 | 'bridge-access' => 3, | |
261 | autostart => 1 | |
262 | }; | |
263 | ||
264 | my $vx = $config->{ifaces}->{vxlan2}; | |
265 | $vx->{'bridge-learning'} = 'off'; | |
266 | $vx->{'bridge-arp-nd-suppress'} = 'on'; | |
267 | $vx->{'bridge-unicast-flood'} = 'off'; | |
268 | $vx->{'bridge-multicast-flood'} = 'off'; | |
269 | my $vxlan123_part = $vxlan12_part ."\n" . <<"PART"; | |
270 | bridge-arp-nd-suppress on | |
271 | bridge-learning off | |
272 | bridge-multicast-flood off | |
273 | bridge-unicast-flood off | |
274 | ||
275 | auto vxlan3 | |
276 | iface vxlan3 inet manual | |
277 | vxlan-id 3 | |
278 | vxlan-remoteip $remoteip1 | |
279 | vxlan-remoteip $remoteip2 | |
280 | bridge-access 3 | |
281 | PART | |
282 | chomp $vxlan123_part; | |
283 | ||
284 | expect load('loopback') . <<"CHECK"; | |
285 | source-directory interfaces.d | |
286 | ||
287 | iface eth0 inet manual | |
288 | ||
289 | $eth1_part | |
290 | ||
291 | auto eth2 | |
292 | iface eth2 inet manual | |
293 | ||
294 | auto eth3 | |
295 | iface eth3 inet manual | |
296 | ||
297 | iface eth4 inet manual | |
298 | ||
299 | iface eth5 inet manual | |
300 | ||
301 | $bond0_part | |
302 | ||
303 | $vmbr0_part | |
304 | ||
305 | $vmbr123_part | |
306 | ||
307 | $vxlan123_part | |
308 | ||
309 | CHECK | |
310 | ||
311 | # | |
312 | # Now add vlans on all types of interfaces: vmbr1, bond0 and eth1 | |
313 | # | |
314 | ||
315 | $config->{ifaces}->{'vmbr1.100'} = { | |
316 | type => 'vlan', | |
317 | mtu => 1300, | |
318 | method => 'manual', | |
319 | families => ['inet'], | |
320 | autostart => 1 | |
321 | }; | |
322 | ||
323 | $config->{ifaces}->{'bond0.100'} = { | |
324 | type => 'vlan', | |
325 | mtu => 1300, | |
326 | method => 'manual', | |
327 | families => ['inet'], | |
328 | 'vlan-protocol' => '802.1ad', | |
329 | autostart => 1 | |
330 | }; | |
331 | ||
332 | $config->{ifaces}->{'bond0.100.10'} = { | |
333 | type => 'vlan', | |
334 | mtu => 1300, | |
335 | method => 'manual', | |
336 | families => ['inet'], | |
337 | autostart => 1 | |
338 | }; | |
339 | ||
340 | $config->{ifaces}->{'eth1.100'} = { | |
341 | type => 'vlan', | |
342 | mtu => 1400, | |
343 | method => 'manual', | |
344 | families => ['inet'], | |
345 | autostart => 1 | |
346 | }; | |
347 | ||
348 | $config->{ifaces}->{'vmbr4'} = { | |
349 | mtu => 1200, | |
350 | type => 'bridge', | |
351 | method => 'manual', | |
352 | families => ['inet'], | |
353 | bridge_stp => 'off', | |
354 | bridge_fd => 0, | |
355 | bridge_ports => 'bond0.100', | |
356 | autostart => 1 | |
357 | }; | |
358 | ||
359 | $config->{ifaces}->{'vmbr5'} = { | |
360 | mtu => 1100, | |
361 | type => 'bridge', | |
362 | method => 'manual', | |
363 | families => ['inet'], | |
364 | bridge_stp => 'off', | |
365 | bridge_fd => 0, | |
366 | bridge_ports => 'vmbr4.99', | |
367 | autostart => 1 | |
368 | }; | |
369 | ||
370 | $config->{ifaces}->{vmbr6} = { | |
371 | ovs_mtu => 1400, | |
372 | type => 'OVSBridge', | |
373 | ovs_ports => 'bond1 ovsintvlan', | |
374 | method => 'manual', | |
375 | families => ['inet'], | |
376 | autostart => 1 | |
377 | }; | |
378 | ||
379 | $config->{ifaces}->{bond1} = { | |
380 | ovs_mtu => 1300, | |
381 | type => 'OVSBond', | |
382 | ovs_bridge => 'vmbr6', | |
383 | ovs_bonds => 'eth4 eth5', | |
384 | ovs_options => 'bond_mode=active-backup', | |
385 | method => 'manual', | |
386 | families => ['inet'], | |
387 | autostart => 1 | |
388 | }; | |
389 | ||
390 | $config->{ifaces}->{ovsintvlan} = { | |
391 | ovs_mtu => 1300, | |
392 | type => 'OVSIntPort', | |
393 | ovs_bridge => 'vmbr6', | |
394 | ovs_options => 'tag=14', | |
395 | method => 'manual', | |
396 | families => ['inet'], | |
397 | autostart => 1 | |
398 | }; | |
399 | ||
400 | expect load('loopback') . <<"CHECK"; | |
401 | source-directory interfaces.d | |
402 | ||
403 | iface eth0 inet manual | |
404 | ||
405 | $eth1_part | |
406 | ||
407 | auto eth2 | |
408 | iface eth2 inet manual | |
409 | ||
410 | auto eth3 | |
411 | iface eth3 inet manual | |
412 | ||
413 | auto eth4 | |
414 | iface eth4 inet manual | |
415 | ||
416 | auto eth5 | |
417 | iface eth5 inet manual | |
418 | ||
419 | auto eth1.100 | |
420 | iface eth1.100 inet manual | |
421 | mtu 1400 | |
422 | ||
423 | auto ovsintvlan | |
424 | iface ovsintvlan inet manual | |
425 | ovs_type OVSIntPort | |
426 | ovs_bridge vmbr6 | |
427 | ovs_mtu 1300 | |
428 | ovs_options tag=14 | |
429 | ||
430 | $bond0_part | |
431 | ||
432 | auto bond1 | |
433 | iface bond1 inet manual | |
434 | ovs_bonds eth4 eth5 | |
435 | ovs_type OVSBond | |
436 | ovs_bridge vmbr6 | |
437 | ovs_mtu 1300 | |
438 | ovs_options bond_mode=active-backup | |
439 | ||
440 | auto bond0.100 | |
441 | iface bond0.100 inet manual | |
442 | mtu 1300 | |
443 | vlan-protocol 802.1ad | |
444 | ||
445 | auto bond0.100.10 | |
446 | iface bond0.100.10 inet manual | |
447 | mtu 1300 | |
448 | ||
449 | $vmbr0_part | |
450 | ||
451 | $vmbr123_part | |
452 | ||
453 | auto vmbr4 | |
454 | iface vmbr4 inet manual | |
455 | bridge-ports bond0.100 | |
456 | bridge-stp off | |
457 | bridge-fd 0 | |
458 | mtu 1200 | |
459 | ||
460 | auto vmbr5 | |
461 | iface vmbr5 inet manual | |
462 | bridge-ports vmbr4.99 | |
463 | bridge-stp off | |
464 | bridge-fd 0 | |
465 | mtu 1100 | |
466 | ||
467 | auto vmbr6 | |
468 | iface vmbr6 inet manual | |
469 | ovs_type OVSBridge | |
470 | ovs_ports bond1 ovsintvlan | |
471 | ovs_mtu 1400 | |
472 | ||
473 | auto vmbr1.100 | |
474 | iface vmbr1.100 inet manual | |
475 | mtu 1300 | |
476 | ||
477 | $vxlan123_part | |
478 | ||
479 | CHECK | |
480 | ||
481 | # | |
482 | # Now check the new config for idempotency: | |
483 | # | |
484 | ||
485 | save('if', w()); | |
486 | r(load('if')); | |
487 | expect load('if'); | |
488 | ||
489 | # | |
490 | # Check a brbase with an ipv6 address on eth1 | |
491 | # | |
492 | ||
493 | r(load('brbase')); | |
494 | ||
495 | my $ip = 'fc05::2'; | |
496 | my $nm = '112'; | |
497 | my $gw = 'fc05::1'; | |
498 | ||
499 | $config->{ifaces}->{eth1} = { | |
500 | type => 'eth', | |
501 | method6 => 'static', | |
502 | address6 => $ip, | |
503 | netmask6 => $nm, | |
504 | gateway6 => $gw, | |
505 | families => ['inet6'], | |
506 | autostart => 1 | |
507 | }; | |
508 | ||
509 | expect load('loopback') . <<"CHECK"; | |
510 | source-directory interfaces.d | |
511 | ||
512 | iface eth0 inet manual | |
513 | ||
514 | auto eth1 | |
515 | iface eth1 inet6 static | |
516 | address $ip/$nm | |
517 | gateway $gw | |
518 | ||
519 | iface eth2 inet manual | |
520 | ||
521 | iface eth3 inet manual | |
522 | ||
523 | iface eth4 inet manual | |
524 | ||
525 | iface eth5 inet manual | |
526 | ||
527 | auto vmbr0 | |
528 | iface vmbr0 inet static | |
529 | address 10.0.0.2/24 | |
530 | gateway 10.0.0.1 | |
531 | bridge-ports eth0 | |
532 | bridge-stp off | |
533 | bridge-fd 0 | |
534 | ||
535 | CHECK | |
536 | ||
537 | save('if', w()); | |
538 | r(load('if')); | |
539 | expect load('if'); | |
540 | ||
541 | 1; |