]> git.proxmox.com Git - pve-common.git/blame - test/etc_network_interfaces/t.ovs_bridge_allow.pl
network_interfaces: use allow-ovs for OVSBridge
[pve-common.git] / test / etc_network_interfaces / t.ovs_bridge_allow.pl
CommitLineData
936218b8
WB
1use strict;
2
3my $ip = '192.168.0.100';
4my $nm = '255.255.255.0';
5my $gw = '192.168.0.1';
6
7# replace proc_net_dev with one with a bunch of interfaces
8save('proc_net_dev', <<'/proc/net/dev');
9eth0:
10eth1:
11eth2:
12eth3:
13/proc/net/dev
14
15r('');
16
17new_iface('vmbr0', 'OVSBridge',
18 [ { family => 'inet',
19 address => $ip,
20 netmask => $nm,
21 gateway => $gw } ],
22 autostart => 1);
23
24update_iface('eth0', [], autostart => 1);
25update_iface('eth1', [], autostart => 1);
26update_iface('eth2', [], autostart => 1);
27#update_iface('eth3', [], autostart => 1);
28
29# Check the bridge and eth interfaces
30expect load('loopback') . <<"/etc/network/interfaces";
31auto eth0
32iface eth0 inet manual
33
34auto eth1
35iface eth1 inet manual
36
37auto eth2
38iface eth2 inet manual
39
40iface eth3 inet manual
41
4ac94c72 42allow-ovs vmbr0
936218b8
WB
43iface 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
53update_iface('vmbr0', [], ovs_ports => 'eth1 eth2');
54expect load('loopback') . <<"/etc/network/interfaces";
55auto eth0
56iface eth0 inet manual
57
936218b8
WB
58allow-vmbr0 eth1
59iface eth1 inet manual
60 ovs_type OVSPort
61 ovs_bridge vmbr0
62
936218b8
WB
63allow-vmbr0 eth2
64iface eth2 inet manual
65 ovs_type OVSPort
66 ovs_bridge vmbr0
67
68iface eth3 inet manual
69
4ac94c72 70allow-ovs vmbr0
936218b8
WB
71iface 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.
83save('idem', w());
84r(load('idem'));
85expect 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!
90update_iface('vmbr0', [], ovs_ports => 'eth1');
91# eth2 is now autoremoved and thus loses its priority, so it appears after eth3
92expect load('loopback') . <<"/etc/network/interfaces";
93auto eth0
94iface eth0 inet manual
95
96allow-vmbr0 eth1
97iface eth1 inet manual
98 ovs_type OVSPort
99 ovs_bridge vmbr0
100
101iface eth3 inet manual
102
103iface eth2 inet manual
104
4ac94c72 105allow-ovs vmbr0
936218b8
WB
106iface 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
1151;