From 3d97b29bd71b9de5fb14d8bd320c20545b88a81b Mon Sep 17 00:00:00 2001 From: Ben Howard Date: Wed, 26 Apr 2017 14:07:53 -0600 Subject: DigitalOcean: remove routes except for the public interface. Previously, the datasource for DigitalOcean allowed for a gateway on each NIC. As a result, on Ubuntu 16.04, networking.service was broken. For 17.04 and later, Ubuntu _replaces_ the default gateway with the second gateway on 'ifup' after reboot. DigitalOcean is looking at changing the meta-data, however, this will result in another version of the meta-data JSON. LP: #1681531. --- .../unittests/test_datasource/test_digitalocean.py | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/unittests/test_datasource/test_digitalocean.py b/tests/unittests/test_datasource/test_digitalocean.py index a11166a9..e97a679a 100644 --- a/tests/unittests/test_datasource/test_digitalocean.py +++ b/tests/unittests/test_datasource/test_digitalocean.py @@ -1,6 +1,8 @@ # Copyright (C) 2014 Neal Shrader # # Author: Neal Shrader +# Author: Ben Howard +# Author: Scott Moser # # This file is part of cloud-init. See LICENSE file for license information. @@ -262,6 +264,29 @@ class TestNetworkConvert(TestCase): print(json.dumps(subn, indent=3)) return subn + def test_correct_gateways_defined(self): + """test to make sure the eth0 ipv4 and ipv6 gateways are defined""" + netcfg = self._get_networking() + gateways = [] + for nic_def in netcfg.get('config'): + if nic_def.get('type') != 'physical': + continue + for subn in nic_def.get('subnets'): + if 'gateway' in subn: + gateways.append(subn.get('gateway')) + + # we should have two gateways, one ipv4 and ipv6 + self.assertEqual(len(gateways), 2) + + # make that the ipv6 gateway is there + (nic_def, meta_def) = self._get_nic_definition('public', 'eth0') + ipv4_def = meta_def.get('ipv4') + self.assertIn(ipv4_def.get('gateway'), gateways) + + # make sure the the ipv6 gateway is there + ipv6_def = meta_def.get('ipv6') + self.assertIn(ipv6_def.get('gateway'), gateways) + def test_public_interface_defined(self): """test that the public interface is defined as eth0""" (nic_def, meta_def) = self._get_nic_definition('public', 'eth0') -- cgit v1.2.3