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