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