]>
Commit | Line | Data |
---|---|---|
936218b8 WB |
1 | use strict; |
2 | ||
3 | my $ip = '192.168.0.100'; | |
4 | my $nm = '255.255.255.0'; | |
5 | my $gw = '192.168.0.1'; | |
6 | ||
7 | # replace proc_net_dev with one with a bunch of interfaces | |
8 | save('proc_net_dev', <<'/proc/net/dev'); | |
9 | eth0: | |
10 | eth1: | |
11 | eth2: | |
12 | eth3: | |
13 | /proc/net/dev | |
14 | ||
15 | r(''); | |
16 | ||
17 | new_iface('vmbr0', 'OVSBridge', | |
18 | [ { family => 'inet', | |
19 | address => $ip, | |
20 | netmask => $nm, | |
21 | gateway => $gw } ], | |
22 | autostart => 1); | |
23 | ||
24 | update_iface('eth0', [], autostart => 1); | |
25 | update_iface('eth1', [], autostart => 1); | |
26 | update_iface('eth2', [], autostart => 1); | |
27 | #update_iface('eth3', [], autostart => 1); | |
28 | ||
29 | # Check the bridge and eth interfaces | |
30 | expect load('loopback') . <<"/etc/network/interfaces"; | |
31 | auto eth0 | |
32 | iface eth0 inet manual | |
33 | ||
34 | auto eth1 | |
35 | iface eth1 inet manual | |
36 | ||
37 | auto eth2 | |
38 | iface eth2 inet manual | |
39 | ||
40 | iface eth3 inet manual | |
41 | ||
42 | auto vmbr0 | |
43 | iface vmbr0 inet static | |
44 | address $ip | |
45 | netmask $nm | |
46 | gateway $gw | |
47 | ovs_type OVSBridge | |
48 | ||
49 | /etc/network/interfaces | |
50 | ||
21d32c95 WB |
51 | # Adding an interface to the bridge needs to add allow- lines and remove |
52 | # its autostart property. | |
936218b8 WB |
53 | update_iface('vmbr0', [], ovs_ports => 'eth1 eth2'); |
54 | expect load('loopback') . <<"/etc/network/interfaces"; | |
55 | auto eth0 | |
56 | iface eth0 inet manual | |
57 | ||
936218b8 WB |
58 | allow-vmbr0 eth1 |
59 | iface eth1 inet manual | |
60 | ovs_type OVSPort | |
61 | ovs_bridge vmbr0 | |
62 | ||
936218b8 WB |
63 | allow-vmbr0 eth2 |
64 | iface eth2 inet manual | |
65 | ovs_type OVSPort | |
66 | ovs_bridge vmbr0 | |
67 | ||
68 | iface eth3 inet manual | |
69 | ||
70 | auto vmbr0 | |
71 | iface vmbr0 inet static | |
72 | address $ip | |
73 | netmask $nm | |
74 | gateway $gw | |
75 | ovs_type OVSBridge | |
76 | ovs_ports eth1 eth2 | |
77 | ||
78 | /etc/network/interfaces | |
79 | ||
80 | # Idempotency - make sure "allow-$BRIDGE $IFACE" don't get duplicated | |
81 | # they're stripped from $config->{options} at load-time since they're | |
82 | # auto-generated when writing OVSPorts. | |
83 | save('idem', w()); | |
84 | r(load('idem')); | |
85 | expect load('idem'); | |
86 | ||
87 | # Removing an ovs_port also has to remove the corresponding allow- line! | |
88 | # Also remember that adding interfaces to the ovs bridge removed their | |
89 | # autostart property, so eth2 is now without an autostart! | |
90 | update_iface('vmbr0', [], ovs_ports => 'eth1'); | |
91 | # eth2 is now autoremoved and thus loses its priority, so it appears after eth3 | |
92 | expect load('loopback') . <<"/etc/network/interfaces"; | |
93 | auto eth0 | |
94 | iface eth0 inet manual | |
95 | ||
96 | allow-vmbr0 eth1 | |
97 | iface eth1 inet manual | |
98 | ovs_type OVSPort | |
99 | ovs_bridge vmbr0 | |
100 | ||
101 | iface eth3 inet manual | |
102 | ||
103 | iface eth2 inet manual | |
104 | ||
105 | auto vmbr0 | |
106 | iface vmbr0 inet static | |
107 | address $ip | |
108 | netmask $nm | |
109 | gateway $gw | |
110 | ovs_type OVSBridge | |
111 | ovs_ports eth1 | |
112 | ||
113 | /etc/network/interfaces | |
114 | ||
115 | 1; |