]> git.proxmox.com Git - pve-common.git/blob - 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
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
51 # Adding an interface to the bridge needs to add allow- lines:
52 update_iface('vmbr0', [], ovs_ports => 'eth1 eth2');
53 expect load('loopback') . <<"/etc/network/interfaces";
54 auto eth0
55 iface eth0 inet manual
56
57 auto eth1
58 allow-vmbr0 eth1
59 iface eth1 inet manual
60 ovs_type OVSPort
61 ovs_bridge vmbr0
62
63 auto eth2
64 allow-vmbr0 eth2
65 iface eth2 inet manual
66 ovs_type OVSPort
67 ovs_bridge vmbr0
68
69 iface eth3 inet manual
70
71 auto vmbr0
72 iface 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.
84 save('idem', w());
85 r(load('idem'));
86 expect 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!
91 update_iface('vmbr0', [], ovs_ports => 'eth1');
92 # eth2 is now autoremoved and thus loses its priority, so it appears after eth3
93 expect load('loopback') . <<"/etc/network/interfaces";
94 auto eth0
95 iface eth0 inet manual
96
97 allow-vmbr0 eth1
98 iface eth1 inet manual
99 ovs_type OVSPort
100 ovs_bridge vmbr0
101
102 iface eth3 inet manual
103
104 iface eth2 inet manual
105
106 auto vmbr0
107 iface 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
116 1;