If I force cloud-init to render netplan (via cloud-config) then things work out better. A small adjustment is needed to the network unittest for parsing ip route output.
=== modified file 'tests/vmtests/test_network.py'
--- tests/vmtests/test_network.py 2017-08-02 15:46:35 +0000
+++ tests/vmtests/test_network.py 2017-08-31 20:42:12 +0000
@@ -30,6 +30,7 @@
cp -av /etc/network/interfaces .
cp -av /etc/network/interfaces.d .
cp /etc/resolv.conf .
+ systemd-resolve --status 2>/dev/null |tee systemd-resolvd.status
cp -av /etc/udev/rules.d/70-persistent-net.rules . ||:
ip -o route show | tee ip_route_show
ip -6 -o route show | tee ip_6_route_show
@@ -48,6 +49,7 @@
mkdir -p etc_netplan
cp -av /etc/netplan/* ./etc_netplan/ ||:
networkctl |tee networkctl
+ ls -1 /sys/class/net/ | xargs -i networkctl status {} | tee nctl.status
mkdir -p run_systemd_network
cp -a /run/systemd/network/* ./run_systemd_network/ ||:
cp -a /run/systemd/netif ./run_systemd_netif ||:
@@ -285,13 +287,16 @@ ip_route_show = self.load_collect_file("ip_route_show") logger.debug("ip route show:\n{}".format(ip_route_show))
for line in [line for line in ip_route_show.split('\n')
- if 'src' in line]:
+ if 'src' in line and 'default' not in line]:
m = re.search(r'^(?P<network>\S+)\sdev\s' + r'(?P<devname>\S+)\s+' +
- r'proto kernel\s+scope link' +
+ r'proto\s(?P<proto>\S+)\s+scope link' + r'\s+src\s(?P<src_ip>\S+)', line)
- route_info = m.groupdict('')
+ try:
+ route_info = m.groupdict('')
+ except Exception:
+ print('Failed to match ip_route_show line:\n%s' % line) logger.debug(route_info)
If I force cloud-init to render netplan (via cloud-config) then things work out better. A small adjustment is needed to the network unittest for parsing ip route output.
=== modified file 'tests/ vmtests/ test_network. py' test_network. py 2017-08-02 15:46:35 +0000 test_network. py 2017-08-31 20:42:12 +0000 interfaces . interfaces. d . resolvd. status rules.d/ 70-persistent- net.rules . ||: network/ * ./run_systemd_ network/ ||:
ip_route_ show = self.load_ collect_ file("ip_ route_show" )
logger. debug(" ip route show:\n{ }".format( ip_route_ show)) show.split( '\n') r'^(?P< network> \S+)\sdev\ s' +
r' (?P<devname> \S+)\s+ ' + s(?P<proto> \S+)\s+ scope link' +
r' \s+src\ s(?P<src_ ip>\S+) ',
line)
logger. debug(route_ info)
--- tests/vmtests/
+++ tests/vmtests/
@@ -30,6 +30,7 @@
cp -av /etc/network/
cp -av /etc/network/
cp /etc/resolv.conf .
+ systemd-resolve --status 2>/dev/null |tee systemd-
cp -av /etc/udev/
ip -o route show | tee ip_route_show
ip -6 -o route show | tee ip_6_route_show
@@ -48,6 +49,7 @@
mkdir -p etc_netplan
cp -av /etc/netplan/* ./etc_netplan/ ||:
networkctl |tee networkctl
+ ls -1 /sys/class/net/ | xargs -i networkctl status {} | tee nctl.status
mkdir -p run_systemd_network
cp -a /run/systemd/
cp -a /run/systemd/netif ./run_systemd_netif ||:
@@ -285,13 +287,16 @@
for line in [line for line in ip_route_
- if 'src' in line]:
+ if 'src' in line and 'default' not in line]:
m = re.search(
- r'proto kernel\s+scope link' +
+ r'proto\
- route_info = m.groupdict('')
+ try:
+ route_info = m.groupdict('')
+ except Exception:
+ print('Failed to match ip_route_show line:\n%s' % line)