summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Howard <bh@digitalocean.com>2017-04-26 14:07:53 -0600
committerScott Moser <smoser@ubuntu.com>2017-05-19 17:14:20 -0400
commit3d97b29bd71b9de5fb14d8bd320c20545b88a81b (patch)
tree0a2290ecd08c1b49a69107468eae9305171c68e7 /tests
parentd059d480c3a5bbeb3bb2e8ff2350f85d64721c11 (diff)
downloadvyos-cloud-init-3d97b29bd71b9de5fb14d8bd320c20545b88a81b.tar.gz
vyos-cloud-init-3d97b29bd71b9de5fb14d8bd320c20545b88a81b.zip
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_datasource/test_digitalocean.py25
1 files changed, 25 insertions, 0 deletions
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 <neal@digitalocean.com>
+# Author: Ben Howard <bh@digitalocean.com>
+# Author: Scott Moser <smoser@ubuntu.com>
#
# 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')