]>
Commit | Line | Data |
---|---|---|
c7c4208a WB |
1 | # Assuming eth0..3 and eth100 |
2 | # eth0 is part of vmbr0, eth100 is part of the OVS bridge vmbr1 | |
3 | # vmbr0 has ipv4 and ipv6, OVS only ipv4 | |
4 | # | |
5 | # eth1..3 are completely un-configured as if the cards had just been physically | |
6 | # plugged in. | |
7 | # The expected behavior is to notice their existance and treat them as manually | |
8 | # configured interfaces. | |
9 | # Saving the file after reading would add the corresponding 'manual' lines. | |
10 | save('proc_net_dev', <<'/proc/net/dev'); | |
11 | eth0: | |
12 | eth1: | |
13 | eth2: | |
14 | eth3: | |
15 | eth100: | |
16 | /proc/net/dev | |
17 | ||
18 | my %wanted = ( | |
19 | vmbr0 => { address => '192.168.1.2', | |
20 | netmask => '255.255.255.0', | |
21 | gateway => '192.168.1.1', | |
22 | address6 => 'fc05::1:1', | |
23 | netmask6 => '112' }, | |
24 | vmbr1 => { address => '10.0.0.5', | |
25 | netmask => '255.255.255.0' } | |
26 | ); | |
27 | ||
28 | save('interfaces', <<"/etc/network/interfaces"); | |
29 | auto lo | |
30 | iface lo inet loopback | |
31 | ||
32 | source-directory interfaces.d | |
33 | ||
34 | iface eth0 inet manual | |
35 | ||
36 | allow-vmbr1 eth100 | |
37 | iface eth100 inet manual | |
38 | ovs_type OVSPort | |
39 | ovs_bridge vmbr1 | |
40 | ||
41 | auto vmbr0 | |
42 | iface vmbr0 inet static | |
43 | address $wanted{vmbr0}->{address} | |
44 | netmask $wanted{vmbr0}->{netmask} | |
45 | gateway $wanted{vmbr0}->{gateway} | |
46 | bridge_ports eth0 | |
47 | bridge_stp off | |
48 | bridge_fd 0 | |
49 | ||
50 | iface vmbr0 inet6 static | |
51 | address $wanted{vmbr0}->{address6} | |
52 | netmask $wanted{vmbr0}->{netmask6} | |
53 | ||
54 | source-directory before-ovs.d | |
55 | ||
56 | auto vmbr1 | |
57 | iface vmbr1 inet static | |
58 | address $wanted{vmbr1}->{address} | |
59 | netmask $wanted{vmbr1}->{netmask} | |
60 | ovs_type OVSBridge | |
61 | ovs_ports eth100 | |
62 | ||
63 | source after-ovs | |
64 | ||
65 | /etc/network/interfaces | |
66 | ||
67 | r(load('interfaces')); | |
68 | save('2', w()); | |
69 | ||
70 | my $ifaces = $config->{ifaces}; | |
71 | ||
72 | # check defined interfaces | |
73 | defined($ifaces->{"eth$_"}) | |
74 | or die "missing interface: eth$_\n" foreach (0, 1, 2, 3, 100); | |
75 | ||
76 | # check configuration | |
77 | foreach my $ifname (keys %wanted) { | |
78 | my $if = $wanted{$ifname}; | |
79 | $ifaces->{$ifname}->{$_} eq $if->{$_} | |
80 | or die "unexpected $_ for interface $ifname: \"" | |
81 | . $ifaces->{$ifname}->{$_} | |
82 | . "\", expected: \"$if->{$_}\"\n" | |
83 | foreach (keys %$if); | |
84 | } | |
85 | ||
86 | my $ck = sub { | |
87 | my ($i, $v, $e) = @_; | |
88 | $ifaces->{$i}->{$v} eq $e | |
89 | or die "$i variable $v: got \"$ifaces->{$i}->{$v}\", expected: $e\n"; | |
90 | }; | |
91 | $ck->('vmbr0', type => 'bridge'); | |
92 | $ck->('vmbr1', type => 'OVSBridge'); | |
93 | $ck->('vmbr1', ovs_type => 'OVSBridge'); | |
94 | $ck->('vmbr1', ovs_ports => 'eth100'); | |
95 | $ck->("eth$_", type => 'eth') foreach (0, 1, 2, 3); | |
96 | $ck->('eth100', type => 'OVSPort'); | |
97 | $ck->('eth100', ovs_type => 'OVSPort'); | |
98 | $ck->('eth100', ovs_bridge => 'vmbr1'); | |
99 | ||
1801bdaa | 100 | my @f100 = sort @{$ifaces->{vmbr0}->{families}}; |
c7c4208a | 101 | |
1801bdaa DM |
102 | die "invalid families defined for vmbr0" |
103 | if (scalar(@f100) != 2) || ($f100[0] ne 'inet') || ($f100[1] ne 'inet6'); | |
104 | ||
c7c4208a WB |
105 | # idempotency |
106 | r(w()); | |
107 | expect load('2'); | |
108 | ||
109 | 1; |