]> git.proxmox.com Git - pve-common.git/blame_incremental - test/etc_network_interfaces/t.create_network.pl
interfaces: support stanzas without types/methods
[pve-common.git] / test / etc_network_interfaces / t.create_network.pl
... / ...
CommitLineData
1save('proc_net_dev', <<'/proc/net/dev');
2eth0:
3eth1:
4eth2:
5eth3:
6eth4:
7eth5:
8/proc/net/dev
9
10r(load('brbase'));
11
12#
13# Variables used for the various interfaces:
14#
15
16my $ip = '192.168.0.2/24';
17my $gw = '192.168.0.1';
18my $svcnodeip = '239.192.105.237';
19my $physdev = 'eth0';
20my $remoteip1 = '192.168.0.3';
21my $remoteip2 = '192.168.0.4';
22
23#
24# Hunk for the default bridge of the 'brbase' configuration
25#
26
27my $vmbr0_part = <<"PART";
28auto vmbr0
29iface 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
35PART
36chomp $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
52my $eth1_part = <<"PART";
53auto eth1
54iface eth1 inet static
55 address $ip
56 gateway $gw
57PART
58chomp $eth1_part;
59
60expect load('loopback') . <<"CHECK";
61source-directory interfaces.d
62
63iface eth0 inet manual
64
65$eth1_part
66
67iface eth2 inet manual
68
69iface eth3 inet manual
70
71iface eth4 inet manual
72
73iface eth5 inet manual
74
75$vmbr0_part
76
77CHECK
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};
94my $bond0_part = <<"PART";
95auto bond0
96iface 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
102PART
103chomp $bond0_part;
104
105expect load('loopback') . <<"CHECK";
106source-directory interfaces.d
107
108iface eth0 inet manual
109
110$eth1_part
111
112auto eth2
113iface eth2 inet manual
114
115auto eth3
116iface eth3 inet manual
117
118iface eth4 inet manual
119
120iface eth5 inet manual
121
122$bond0_part
123
124$vmbr0_part
125
126CHECK
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
151my $vxlan12_part = <<"PART";
152auto vxlan1
153iface vxlan1 inet manual
154 vxlan-id 1
155 vxlan-svcnodeip $svcnodeip
156 vxlan-physdev $physdev
157
158auto vxlan2
159iface vxlan2 inet manual
160 vxlan-id 2
161 vxlan-local-tunnelip $ip
162PART
163chomp $vxlan12_part;
164
165expect load('loopback') . <<"CHECK";
166source-directory interfaces.d
167
168iface eth0 inet manual
169
170$eth1_part
171
172auto eth2
173iface eth2 inet manual
174
175auto eth3
176iface eth3 inet manual
177
178iface eth4 inet manual
179
180iface eth5 inet manual
181
182$bond0_part
183
184$vmbr0_part
185
186$vxlan12_part
187
188CHECK
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
228my $vmbr123_part = <<"PART";
229auto vmbr1
230iface 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
238auto vmbr2
239iface vmbr2 inet manual
240 bridge-ports vxlan2
241 bridge-stp off
242 bridge-fd 0
243
244auto vmbr3
245iface 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
251PART
252chomp $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
264my $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';
269my $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
275auto vxlan3
276iface vxlan3 inet manual
277 vxlan-id 3
278 vxlan-remoteip $remoteip1
279 vxlan-remoteip $remoteip2
280 bridge-access 3
281PART
282chomp $vxlan123_part;
283
284expect load('loopback') . <<"CHECK";
285source-directory interfaces.d
286
287iface eth0 inet manual
288
289$eth1_part
290
291auto eth2
292iface eth2 inet manual
293
294auto eth3
295iface eth3 inet manual
296
297iface eth4 inet manual
298
299iface eth5 inet manual
300
301$bond0_part
302
303$vmbr0_part
304
305$vmbr123_part
306
307$vxlan123_part
308
309CHECK
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
400expect load('loopback') . <<"CHECK";
401source-directory interfaces.d
402
403iface eth0 inet manual
404
405$eth1_part
406
407auto eth2
408iface eth2 inet manual
409
410auto eth3
411iface eth3 inet manual
412
413auto eth4
414iface eth4 inet manual
415
416auto eth5
417iface eth5 inet manual
418
419auto eth1.100
420iface eth1.100 inet manual
421 mtu 1400
422
423auto ovsintvlan
424iface 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
432auto bond1
433iface 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
440auto bond0.100
441iface bond0.100 inet manual
442 mtu 1300
443 vlan-protocol 802.1ad
444
445auto bond0.100.10
446iface bond0.100.10 inet manual
447 mtu 1300
448
449$vmbr0_part
450
451$vmbr123_part
452
453auto vmbr4
454iface vmbr4 inet manual
455 bridge-ports bond0.100
456 bridge-stp off
457 bridge-fd 0
458 mtu 1200
459
460auto vmbr5
461iface vmbr5 inet manual
462 bridge-ports vmbr4.99
463 bridge-stp off
464 bridge-fd 0
465 mtu 1100
466
467auto vmbr6
468iface vmbr6 inet manual
469 ovs_type OVSBridge
470 ovs_ports bond1 ovsintvlan
471 ovs_mtu 1400
472
473auto vmbr1.100
474iface vmbr1.100 inet manual
475 mtu 1300
476
477$vxlan123_part
478
479CHECK
480
481#
482# Now check the new config for idempotency:
483#
484
485save('if', w());
486r(load('if'));
487expect load('if');
488
489#
490# Check a brbase with an ipv6 address on eth1
491#
492
493r(load('brbase'));
494
495my $ip = 'fc05::2';
496my $nm = '112';
497my $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
509expect load('loopback') . <<"CHECK";
510source-directory interfaces.d
511
512iface eth0 inet manual
513
514auto eth1
515iface eth1 inet6 static
516 address $ip/$nm
517 gateway $gw
518
519iface eth2 inet manual
520
521iface eth3 inet manual
522
523iface eth4 inet manual
524
525iface eth5 inet manual
526
527auto vmbr0
528iface 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
535CHECK
536
537save('if', w());
538r(load('if'));
539expect load('if');
540
5411;