]> git.proxmox.com Git - pve-common.git/blame - test/etc_network_interfaces/t.update_network.pl
SectionConfig:write_config: sort options by key name
[pve-common.git] / test / etc_network_interfaces / t.update_network.pl
CommitLineData
c7c4208a
WB
1save('proc_net_dev', <<'/proc/net/dev');
2eth0:
3eth1:
4/proc/net/dev
5
6my $ip = '192.168.0.2';
7my $nm = '255.255.255.0';
8my $gw = '192.168.0.1';
9my $ip6 = 'fc05::2';
10my $nm6 = '112';
11my $gw6 = 'fc05::1';
12
13# Load
14r(load('brbase'));
15
16# Create eth1
17$config->{ifaces}->{eth1} = {
18 type => 'eth',
19 method => 'static',
20 address => $ip,
21 netmask => $nm,
22 gateway => $gw,
23 families => ['inet'],
24 autostart => 1
25};
26
27# Check
28expect load('loopback') . <<"CHECK";
29source-directory interfaces.d
30
31iface eth0 inet manual
32
33auto eth1
34iface eth1 inet static
35 address $ip
36 netmask $nm
37 gateway $gw
38
39auto vmbr0
40iface vmbr0 inet static
41 address 10.0.0.2
42 netmask 255.255.255.0
43 gateway 10.0.0.1
44 bridge_ports eth0
45 bridge_stp off
46 bridge_fd 0
47
48CHECK
49
50# Reload then modify
51save('ipv4', w());
52r(load('ipv4'));
53expect load('ipv4');
54
55$config->{ifaces}->{eth1}->{$_->[0]} = $_->[1] foreach (
56 [ method6 => 'static' ],
57 [ address6 => $ip6 ],
58 [ netmask6 => $nm6 ],
59 [ gateway6 => $gw6 ],
60 [ families => ['inet', 'inet6'] ]
61);
62
63# Check
64my $final = load('loopback') . <<"CHECK";
65source-directory interfaces.d
66
67iface eth0 inet manual
68
69auto eth1
70iface eth1 inet static
71 address $ip
72 netmask $nm
73 gateway $gw
74
75iface eth1 inet6 static
76 address $ip6
77 netmask $nm6
78 gateway $gw6
79
80auto vmbr0
81iface vmbr0 inet static
82 address 10.0.0.2
83 netmask 255.255.255.0
84 gateway 10.0.0.1
85 bridge_ports eth0
86 bridge_stp off
87 bridge_fd 0
88
89CHECK
90expect $final;
91
92save('both', w());
93r(load('both'));
94expect load('both');
95
96# Reload ipv4 and replace instead of modifying
97r(load('ipv4'));
98
99$config->{ifaces}->{eth1} = {
100 type => 'eth',
101 method => 'static',
102 address => $ip,
103 netmask => $nm,
104 gateway => $gw,
105 method6 => 'static',
106 address6 => $ip6,
107 netmask6 => $nm6,
108 gateway6 => $gw6,
109 families => ['inet', 'inet6'],
110 autostart => 1
111};
112expect $final;
113r(w());
114expect $final;
115
1161;