]> git.proxmox.com Git - pve-common.git/blame - test/etc_network_interfaces/t.list-interfaces.pl
cgroup: cpu quota: fix resetting period length for v1
[pve-common.git] / test / etc_network_interfaces / t.list-interfaces.pl
CommitLineData
c7c4208a
WB
1# Assuming eth0..3 and eth100
2# eth0 is part of vmbr0, eth100 is part of the OVS bridge vmbr1
3# vmbr0 has ipv4 and ipv6, OVS only ipv4
4#
5# eth1..3 are completely un-configured as if the cards had just been physically
6# plugged in.
7# The expected behavior is to notice their existance and treat them as manually
8# configured interfaces.
9# Saving the file after reading would add the corresponding 'manual' lines.
10save('proc_net_dev', <<'/proc/net/dev');
11eth0:
12eth1:
13eth2:
14eth3:
15eth100:
16/proc/net/dev
17
18my %wanted = (
f110671d 19 vmbr0 => {
fa6e6946
TL
20 address => '192.168.1.2',
21 netmask => '24',
22 cidr => '192.168.1.2/24',
f110671d 23 gateway => '192.168.1.1',
fa6e6946
TL
24 address6 => 'fc05::1:1',
25 netmask6 => '112',
26 cidr6 => 'fc05::1:1/112',
f110671d
TL
27 },
28 vmbr1 => {
fa6e6946
TL
29 address => '10.0.0.5',
30 netmask => '24',
31 cidr => '10.0.0.5/24',
f110671d 32 },
e1b784f3
AD
33 eth2 => {
34 address => '172.16.0.1',
35 netmask => '24',
36 cidr => '172.16.0.1/24',
37 address6 => 'fc05::1:2',
38 netmask6 => '112',
39 cidr6 => 'fc05::1:2/112',
40 },
c7c4208a
WB
41);
42
43save('interfaces', <<"/etc/network/interfaces");
44auto lo
45iface lo inet loopback
46
47source-directory interfaces.d
48
49iface eth0 inet manual
50
e1b784f3
AD
51iface eth2 inet static
52 address $wanted{eth2}->{cidr}
53
54iface eth2 inet6 static
55 address $wanted{eth2}->{cidr6}
56
c7c4208a
WB
57allow-vmbr1 eth100
58iface eth100 inet manual
59 ovs_type OVSPort
60 ovs_bridge vmbr1
61
62auto vmbr0
63iface vmbr0 inet static
e1b784f3
AD
64 address $wanted{vmbr0}->{address}
65 netmask $wanted{vmbr0}->{netmask}
c7c4208a
WB
66 gateway $wanted{vmbr0}->{gateway}
67 bridge_ports eth0
68 bridge_stp off
69 bridge_fd 0
70
71iface vmbr0 inet6 static
e1b784f3
AD
72 address $wanted{vmbr0}->{address6}
73 netmask $wanted{vmbr0}->{netmask6}
c7c4208a
WB
74
75source-directory before-ovs.d
76
4ac94c72 77allow-ovs vmbr1
c7c4208a 78iface vmbr1 inet static
e1b784f3
AD
79 address $wanted{vmbr1}->{address}
80 netmask $wanted{vmbr1}->{netmask}
c7c4208a
WB
81 ovs_type OVSBridge
82 ovs_ports eth100
83
84source after-ovs
85
86/etc/network/interfaces
87
88r(load('interfaces'));
89save('2', w());
90
91my $ifaces = $config->{ifaces};
92
93# check defined interfaces
94defined($ifaces->{"eth$_"})
95 or die "missing interface: eth$_\n" foreach (0, 1, 2, 3, 100);
96
97# check configuration
98foreach my $ifname (keys %wanted) {
99 my $if = $wanted{$ifname};
100 $ifaces->{$ifname}->{$_} eq $if->{$_}
101 or die "unexpected $_ for interface $ifname: \""
102 . $ifaces->{$ifname}->{$_}
103 . "\", expected: \"$if->{$_}\"\n"
104 foreach (keys %$if);
105}
106
107my $ck = sub {
108 my ($i, $v, $e) = @_;
109 $ifaces->{$i}->{$v} eq $e
110 or die "$i variable $v: got \"$ifaces->{$i}->{$v}\", expected: $e\n";
111};
112$ck->('vmbr0', type => 'bridge');
113$ck->('vmbr1', type => 'OVSBridge');
114$ck->('vmbr1', ovs_type => 'OVSBridge');
115$ck->('vmbr1', ovs_ports => 'eth100');
116$ck->("eth$_", type => 'eth') foreach (0, 1, 2, 3);
117$ck->('eth100', type => 'OVSPort');
118$ck->('eth100', ovs_type => 'OVSPort');
119$ck->('eth100', ovs_bridge => 'vmbr1');
120
1801bdaa 121my @f100 = sort @{$ifaces->{vmbr0}->{families}};
c7c4208a 122
1801bdaa
DM
123die "invalid families defined for vmbr0"
124 if (scalar(@f100) != 2) || ($f100[0] ne 'inet') || ($f100[1] ne 'inet6');
125
c7c4208a
WB
126# idempotency
127r(w());
128expect load('2');
129
1301;