]> git.proxmox.com Git - pve-common.git/blame - 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
CommitLineData
c7c4208a
WB
1save('proc_net_dev', <<'/proc/net/dev');
2eth0:
3eth1:
ec0f5151
WB
4eth2:
5eth3:
c7c4208a
WB
6/proc/net/dev
7
8r(load('brbase'));
9
ec0f5151
WB
10#
11# Variables used for the various interfaces:
12#
13
378c6656 14my $ip = '192.168.0.2/24';
c7c4208a 15my $gw = '192.168.0.1';
95aa8788
AD
16my $svcnodeip = '239.192.105.237';
17my $physdev = 'eth0';
18my $remoteip1 = '192.168.0.3';
19my $remoteip2 = '192.168.0.4';
20
ec0f5151
WB
21#
22# Hunk for the default bridge of the 'brbase' configuration
23#
24
25my $vmbr0_part = <<"PART";
26auto vmbr0
27iface vmbr0 inet static
beedabb4
AD
28 address 10.0.0.2/24
29 gateway 10.0.0.1
ec0f5151
WB
30 bridge-ports eth0
31 bridge-stp off
32 bridge-fd 0
33PART
34chomp $vmbr0_part;
35
36#
37# Configure eth1 statically, store its expected interfaces hunk in $eth1_part
38# and test!
39#
c7c4208a
WB
40
41$config->{ifaces}->{eth1} = {
42 type => 'eth',
43 method => 'static',
44 address => $ip,
c7c4208a
WB
45 gateway => $gw,
46 families => ['inet'],
47 autostart => 1
48};
49
ec0f5151
WB
50my $eth1_part = <<"PART";
51auto eth1
52iface eth1 inet static
beedabb4
AD
53 address $ip
54 gateway $gw
ec0f5151
WB
55PART
56chomp $eth1_part;
57
58expect load('loopback') . <<"CHECK";
59source-directory interfaces.d
60
61iface eth0 inet manual
62
63$eth1_part
64
65iface eth2 inet manual
66
67iface eth3 inet manual
68
69$vmbr0_part
70
71CHECK
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,
0115696f
AD
84 method => 'manual',
85 families => ['inet'],
86 autostart => 1
87};
ec0f5151
WB
88my $bond0_part = <<"PART";
89auto bond0
90iface 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
96PART
97chomp $bond0_part;
0115696f 98
ec0f5151
WB
99expect load('loopback') . <<"CHECK";
100source-directory interfaces.d
101
102iface eth0 inet manual
103
104$eth1_part
105
106iface eth2 inet manual
107
108iface eth3 inet manual
109
110$bond0_part
111
112$vmbr0_part
113
114CHECK
115
116#
117# Add vxlan1 and 2
118#
119
120$config->{ifaces}->{vxlan1} = {
121 type => 'vxlan',
0115696f
AD
122 method => 'manual',
123 families => ['inet'],
ec0f5151
WB
124 'vxlan-id' => 1,
125 'vxlan-svcnodeip' => $svcnodeip,
126 'vxlan-physdev' => $physdev,
0115696f
AD
127 autostart => 1
128};
129
ec0f5151
WB
130$config->{ifaces}->{vxlan2} = {
131 type => 'vxlan',
0115696f
AD
132 method => 'manual',
133 families => ['inet'],
ec0f5151
WB
134 'vxlan-id' => 2,
135 'vxlan-local-tunnelip' => $ip,
0115696f
AD
136 autostart => 1
137};
138
ec0f5151
WB
139my $vxlan12_part = <<"PART";
140auto vxlan1
141iface vxlan1 inet manual
142 vxlan-id 1
143 vxlan-svcnodeip $svcnodeip
144 vxlan-physdev $physdev
145
146auto vxlan2
147iface vxlan2 inet manual
148 vxlan-id 2
149 vxlan-local-tunnelip $ip
150PART
151chomp $vxlan12_part;
152
153expect load('loopback') . <<"CHECK";
154source-directory interfaces.d
155
156iface eth0 inet manual
157
158$eth1_part
159
160iface eth2 inet manual
161
162iface eth3 inet manual
163
164$bond0_part
165
166$vmbr0_part
167
168$vxlan12_part
169
170CHECK
171
172#
173# Add vxlan3 and 3 bridges using vxlan1..3
174#
175
9a052564 176$config->{ifaces}->{vmbr1} = {
9b053d70 177 mtu => 1400,
9a052564
AD
178 type => 'bridge',
179 method => 'manual',
180 families => ['inet'],
ec0f5151 181 bridge_stp => 'off',
9a052564 182 bridge_fd => 0,
ec0f5151
WB
183 bridge_ports => 'vxlan1',
184 bridge_vlan_aware => 'yes',
9a052564
AD
185 autostart => 1
186};
187
9a052564
AD
188$config->{ifaces}->{vmbr2} = {
189 type => 'bridge',
190 method => 'manual',
191 families => ['inet'],
ec0f5151 192 bridge_stp => 'off',
9a052564 193 bridge_fd => 0,
ec0f5151 194 bridge_ports => 'vxlan2',
9a052564
AD
195 autostart => 1
196};
197
198$config->{ifaces}->{vmbr3} = {
199 type => 'bridge',
200 method => 'manual',
201 families => ['inet'],
ec0f5151 202 bridge_stp => 'off',
9a052564 203 bridge_fd => 0,
a70e9925 204 bridge_ports => 'vxlan3',
ec0f5151 205 bridge_vlan_aware => 'yes',
9a052564
AD
206 bridge_vids => '2-10',
207 autostart => 1
208};
209
ec0f5151
WB
210my $vmbr123_part = <<"PART";
211auto vmbr1
212iface 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
95aa8788 219
ec0f5151
WB
220auto vmbr2
221iface vmbr2 inet manual
222 bridge-ports vxlan2
223 bridge-stp off
224 bridge-fd 0
225
226auto vmbr3
227iface vmbr3 inet manual
a70e9925 228 bridge-ports vxlan3
ec0f5151
WB
229 bridge-stp off
230 bridge-fd 0
231 bridge-vlan-aware yes
232 bridge-vids 2-10
233PART
234chomp $vmbr123_part;
95aa8788
AD
235
236$config->{ifaces}->{vxlan3} = {
237 type => 'vxlan',
238 method => 'manual',
239 families => ['inet'],
240 'vxlan-id' => 3,
241 'vxlan-remoteip' => [$remoteip1, $remoteip2],
9a052564 242 'bridge-access' => 3,
95aa8788
AD
243 autostart => 1
244};
245
ec0f5151
WB
246my $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';
251my $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
257auto vxlan3
258iface vxlan3 inet manual
259 vxlan-id 3
260 vxlan-remoteip $remoteip1
261 vxlan-remoteip $remoteip2
262 bridge-access 3
263PART
264chomp $vxlan123_part;
265
266expect load('loopback') . <<"CHECK";
267source-directory interfaces.d
268
269iface eth0 inet manual
270
271$eth1_part
272
273iface eth2 inet manual
274
275iface eth3 inet manual
276
277$bond0_part
278
279$vmbr0_part
280
281$vmbr123_part
282
283$vxlan123_part
284
285CHECK
286
287#
288# Now add vlans on all types of interfaces: vmbr1, bond0 and eth1
289#
290
c4e56470
AD
291$config->{ifaces}->{'vmbr1.100'} = {
292 type => 'vlan',
9b053d70 293 mtu => 1300,
c4e56470
AD
294 method => 'manual',
295 families => ['inet'],
296 autostart => 1
297};
298
299$config->{ifaces}->{'bond0.100'} = {
8f5d56bf
AD
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'} = {
c4e56470 309 type => 'vlan',
9b053d70 310 mtu => 1300,
c4e56470
AD
311 method => 'manual',
312 families => ['inet'],
313 autostart => 1
314};
315
316$config->{ifaces}->{'eth1.100'} = {
317 type => 'vlan',
9b053d70 318 mtu => 1400,
c4e56470
AD
319 method => 'manual',
320 families => ['inet'],
321 autostart => 1
322};
95aa8788 323
968c90f1
AD
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
a70e9925
AD
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
c7c4208a
WB
346expect load('loopback') . <<"CHECK";
347source-directory interfaces.d
348
349iface eth0 inet manual
350
ec0f5151 351$eth1_part
c7c4208a 352
0115696f
AD
353iface eth2 inet manual
354
0115696f
AD
355iface eth3 inet manual
356
c4e56470
AD
357auto eth1.100
358iface eth1.100 inet manual
9b053d70 359 mtu 1400
c4e56470 360
ec0f5151 361$bond0_part
0115696f 362
c4e56470
AD
363auto bond0.100
364iface bond0.100 inet manual
9b053d70 365 mtu 1300
8f5d56bf
AD
366 vlan-protocol 802.1ad
367
368auto bond0.100.10
369iface bond0.100.10 inet manual
370 mtu 1300
c4e56470 371
ec0f5151 372$vmbr0_part
9a052564 373
ec0f5151 374$vmbr123_part
9a052564 375
968c90f1
AD
376auto vmbr4
377iface vmbr4 inet manual
378 bridge-ports bond0.100
379 bridge-stp off
380 bridge-fd 0
381 mtu 1200
382
a70e9925
AD
383auto vmbr5
384iface vmbr5 inet manual
385 bridge-ports vmbr4.99
386 bridge-stp off
387 bridge-fd 0
388 mtu 1100
389
c4e56470
AD
390auto vmbr1.100
391iface vmbr1.100 inet manual
9b053d70 392 mtu 1300
c4e56470 393
ec0f5151 394$vxlan123_part
95aa8788 395
c7c4208a
WB
396CHECK
397
ec0f5151
WB
398#
399# Now check the new config for idempotency:
400#
401
c7c4208a
WB
402save('if', w());
403r(load('if'));
404expect load('if');
405
ec0f5151
WB
406#
407# Check a brbase with an ipv6 address on eth1
408#
409
c7c4208a
WB
410r(load('brbase'));
411
412my $ip = 'fc05::2';
413my $nm = '112';
414my $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
c7c4208a
WB
426expect load('loopback') . <<"CHECK";
427source-directory interfaces.d
428
429iface eth0 inet manual
430
431auto eth1
432iface eth1 inet6 static
beedabb4
AD
433 address $ip
434 gateway $gw
c7c4208a 435
ec0f5151
WB
436iface eth2 inet manual
437
438iface eth3 inet manual
439
c7c4208a
WB
440auto vmbr0
441iface vmbr0 inet static
beedabb4
AD
442 address 10.0.0.2/24
443 gateway 10.0.0.1
1accc6da
AD
444 bridge-ports eth0
445 bridge-stp off
446 bridge-fd 0
c7c4208a
WB
447
448CHECK
449
450save('if', w());
451r(load('if'));
452expect load('if');
453
4541;