]>
Commit | Line | Data |
---|---|---|
c7c4208a WB |
1 | save('proc_net_dev', <<'/proc/net/dev'); |
2 | eth0: | |
3 | eth1: | |
4 | /proc/net/dev | |
5 | ||
6 | my $ip = '192.168.0.2'; | |
7 | my $nm = '255.255.255.0'; | |
8 | my $gw = '192.168.0.1'; | |
9 | my $ip6 = 'fc05::2'; | |
10 | my $nm6 = '112'; | |
11 | my $gw6 = 'fc05::1'; | |
12 | ||
13 | # Load | |
14 | r(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 | |
28 | expect load('loopback') . <<"CHECK"; | |
29 | source-directory interfaces.d | |
30 | ||
31 | iface eth0 inet manual | |
32 | ||
33 | auto eth1 | |
34 | iface eth1 inet static | |
35 | address $ip | |
36 | netmask $nm | |
37 | gateway $gw | |
38 | ||
39 | auto vmbr0 | |
40 | iface vmbr0 inet static | |
41 | address 10.0.0.2 | |
42 | netmask 255.255.255.0 | |
43 | gateway 10.0.0.1 | |
1accc6da AD |
44 | bridge-ports eth0 |
45 | bridge-stp off | |
46 | bridge-fd 0 | |
c7c4208a WB |
47 | |
48 | CHECK | |
49 | ||
50 | # Reload then modify | |
51 | save('ipv4', w()); | |
52 | r(load('ipv4')); | |
53 | expect 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 | |
64 | my $final = load('loopback') . <<"CHECK"; | |
65 | source-directory interfaces.d | |
66 | ||
67 | iface eth0 inet manual | |
68 | ||
69 | auto eth1 | |
70 | iface eth1 inet static | |
71 | address $ip | |
72 | netmask $nm | |
73 | gateway $gw | |
74 | ||
75 | iface eth1 inet6 static | |
76 | address $ip6 | |
77 | netmask $nm6 | |
78 | gateway $gw6 | |
79 | ||
80 | auto vmbr0 | |
81 | iface vmbr0 inet static | |
82 | address 10.0.0.2 | |
83 | netmask 255.255.255.0 | |
84 | gateway 10.0.0.1 | |
1accc6da AD |
85 | bridge-ports eth0 |
86 | bridge-stp off | |
87 | bridge-fd 0 | |
c7c4208a WB |
88 | |
89 | CHECK | |
90 | expect $final; | |
91 | ||
92 | save('both', w()); | |
93 | r(load('both')); | |
94 | expect load('both'); | |
95 | ||
96 | # Reload ipv4 and replace instead of modifying | |
97 | r(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 | }; | |
112 | expect $final; | |
113 | r(w()); | |
114 | expect $final; | |
115 | ||
116 | 1; |