1 no warnings
'experimental::smartmatch';
3 # Assuming eth0..3 and eth100
4 # eth0 is part of vmbr0, eth100 is part of the OVS bridge vmbr1
5 # vmbr0 has ipv4 and ipv6, OVS only ipv4
7 # eth1..3 are completely un-configured as if the cards had just been physically
9 # The expected behavior is to notice their existance and treat them as manually
10 # configured interfaces.
11 # Saving the file after reading would add the corresponding 'manual' lines.
12 save
('proc_net_dev', <<'/proc/net/dev');
21 vmbr0
=> { address
=> '192.168.1.2',
22 netmask
=> '255.255.255.0',
23 gateway
=> '192.168.1.1',
24 address6
=> 'fc05::1:1',
26 vmbr1
=> { address
=> '10.0.0.5',
27 netmask
=> '255.255.255.0' }
30 save
('interfaces', <<"/etc/network/interfaces");
32 iface lo inet loopback
34 source-directory interfaces
.d
36 iface eth0 inet manual
39 iface eth100 inet manual
44 iface vmbr0 inet static
45 address
$wanted{vmbr0
}->{address
}
46 netmask
$wanted{vmbr0
}->{netmask
}
47 gateway
$wanted{vmbr0
}->{gateway
}
52 iface vmbr0 inet6 static
53 address
$wanted{vmbr0
}->{address6
}
54 netmask
$wanted{vmbr0
}->{netmask6
}
56 source-directory before-ovs
.d
59 iface vmbr1 inet static
60 address
$wanted{vmbr1
}->{address
}
61 netmask
$wanted{vmbr1
}->{netmask
}
67 /etc/network
/interfaces
69 r
(load
('interfaces'));
72 my $ifaces = $config->{ifaces
};
74 # check defined interfaces
75 defined($ifaces->{"eth$_"})
76 or die "missing interface: eth$_\n" foreach (0, 1, 2, 3, 100);
79 foreach my $ifname (keys %wanted) {
80 my $if = $wanted{$ifname};
81 $ifaces->{$ifname}->{$_} eq $if->{$_}
82 or die "unexpected $_ for interface $ifname: \""
83 . $ifaces->{$ifname}->{$_}
84 . "\", expected: \"$if->{$_}\"\n"
90 $ifaces->{$i}->{$v} eq $e
91 or die "$i variable $v: got \"$ifaces->{$i}->{$v}\", expected: $e\n";
93 $ck->('vmbr0', type
=> 'bridge');
94 $ck->('vmbr1', type
=> 'OVSBridge');
95 $ck->('vmbr1', ovs_type
=> 'OVSBridge');
96 $ck->('vmbr1', ovs_ports
=> 'eth100');
97 $ck->("eth$_", type
=> 'eth') foreach (0, 1, 2, 3);
98 $ck->('eth100', type
=> 'OVSPort');
99 $ck->('eth100', ovs_type
=> 'OVSPort');
100 $ck->('eth100', ovs_bridge
=> 'vmbr1');
102 my $f100 = $ifaces->{vmbr0
}->{families
};
103 die "invalid families defined for vmbr0: @$f100\n" unless [sort(@$f100)] ~~ ['inet', 'inet6'];