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
5 # eth1..3 are completely un-configured as if the cards had just been physically
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.
10 save
('proc_net_dev', <<'/proc/net/dev');
20 address
=> '192.168.1.2',
22 cidr
=> '192.168.1.2/24',
23 gateway
=> '192.168.1.1',
24 address6
=> 'fc05::1:1',
26 cidr6
=> 'fc05::1:1/112',
29 address
=> '10.0.0.5',
31 cidr
=> '10.0.0.5/24',
35 save
('interfaces', <<"/etc/network/interfaces");
37 iface lo inet loopback
39 source-directory interfaces
.d
41 iface eth0 inet manual
44 iface eth100 inet manual
49 iface vmbr0 inet static
52 gateway
$wanted{vmbr0
}->{gateway
}
57 iface vmbr0 inet6 static
61 source-directory before-ovs
.d
64 iface vmbr1 inet static
72 /etc/network
/interfaces
74 r
(load
('interfaces'));
77 my $ifaces = $config->{ifaces
};
79 # check defined interfaces
80 defined($ifaces->{"eth$_"})
81 or die "missing interface: eth$_\n" foreach (0, 1, 2, 3, 100);
84 foreach my $ifname (keys %wanted) {
85 my $if = $wanted{$ifname};
86 $ifaces->{$ifname}->{$_} eq $if->{$_}
87 or die "unexpected $_ for interface $ifname: \""
88 . $ifaces->{$ifname}->{$_}
89 . "\", expected: \"$if->{$_}\"\n"
95 $ifaces->{$i}->{$v} eq $e
96 or die "$i variable $v: got \"$ifaces->{$i}->{$v}\", expected: $e\n";
98 $ck->('vmbr0', type
=> 'bridge');
99 $ck->('vmbr1', type
=> 'OVSBridge');
100 $ck->('vmbr1', ovs_type
=> 'OVSBridge');
101 $ck->('vmbr1', ovs_ports
=> 'eth100');
102 $ck->("eth$_", type
=> 'eth') foreach (0, 1, 2, 3);
103 $ck->('eth100', type
=> 'OVSPort');
104 $ck->('eth100', ovs_type
=> 'OVSPort');
105 $ck->('eth100', ovs_bridge
=> 'vmbr1');
107 my @f100 = sort @{$ifaces->{vmbr0
}->{families
}};
109 die "invalid families defined for vmbr0"
110 if (scalar(@f100) != 2) || ($f100[0] ne 'inet') || ($f100[1] ne 'inet6');