]> git.proxmox.com Git - pve-common.git/blame - test/etc_network_interfaces/t.ovs_bridge_allow.pl
importing etc_network_interfaces tests
[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
42auto vmbr0
43iface vmbr0 inet static
44 address $ip
45 netmask $nm
46 gateway $gw
47 ovs_type OVSBridge
48
49/etc/network/interfaces
50
51# Adding an interface to the bridge needs to add allow- lines:
52update_iface('vmbr0', [], ovs_ports => 'eth1 eth2');
53expect load('loopback') . <<"/etc/network/interfaces";
54auto eth0
55iface eth0 inet manual
56
57auto eth1
58allow-vmbr0 eth1
59iface eth1 inet manual
60 ovs_type OVSPort
61 ovs_bridge vmbr0
62
63auto eth2
64allow-vmbr0 eth2
65iface eth2 inet manual
66 ovs_type OVSPort
67 ovs_bridge vmbr0
68
69iface eth3 inet manual
70
71auto vmbr0
72iface vmbr0 inet static
73 address $ip
74 netmask $nm
75 gateway $gw
76 ovs_type OVSBridge
77 ovs_ports eth1 eth2
78
79/etc/network/interfaces
80
81# Idempotency - make sure "allow-$BRIDGE $IFACE" don't get duplicated
82# they're stripped from $config->{options} at load-time since they're
83# auto-generated when writing OVSPorts.
84save('idem', w());
85r(load('idem'));
86expect load('idem');
87
88# Removing an ovs_port also has to remove the corresponding allow- line!
89# Also remember that adding interfaces to the ovs bridge removed their
90# autostart property, so eth2 is now without an autostart!
91update_iface('vmbr0', [], ovs_ports => 'eth1');
92# eth2 is now autoremoved and thus loses its priority, so it appears after eth3
93expect load('loopback') . <<"/etc/network/interfaces";
94auto eth0
95iface eth0 inet manual
96
97allow-vmbr0 eth1
98iface eth1 inet manual
99 ovs_type OVSPort
100 ovs_bridge vmbr0
101
102iface eth3 inet manual
103
104iface eth2 inet manual
105
106auto vmbr0
107iface vmbr0 inet static
108 address $ip
109 netmask $nm
110 gateway $gw
111 ovs_type OVSBridge
112 ovs_ports eth1
113
114/etc/network/interfaces
115
1161;