Merge ~darkmuggle-deactivatedaccount/cloud-init:master into cloud-init:master

Proposed by Ben Howard
Status: Merged
Approved by: Scott Moser
Approved revision: 87117ae805f2c9548f13259d13babc9b554e8258
Merged at revision: 3d97b29bd71b9de5fb14d8bd320c20545b88a81b
Proposed branch: ~darkmuggle-deactivatedaccount/cloud-init:master
Merge into: cloud-init:master
Diff against target: 56 lines (+26/-1)
2 files modified
cloudinit/sources/helpers/digitalocean.py (+1/-1)
tests/unittests/test_datasource/test_digitalocean.py (+25/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Scott Moser Needs Fixing
Review via email: mp+323273@code.launchpad.net

Description of the change

This change ignores the gateway setting on the private NIC. The was causing the default route to be set to the eth1 interface on reboot.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

i'm ok with this in general, but we should update unit tests to show this behavior (it is already in the config as i recall, but we are not checking the result deeply enough to verify).

review: Needs Fixing
87117ae... by Ben Howard

DigitalOcean: added test to ensure correct gateways are used.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/sources/helpers/digitalocean.py b/cloudinit/sources/helpers/digitalocean.py
2index 257989e..693f8d5 100644
3--- a/cloudinit/sources/helpers/digitalocean.py
4+++ b/cloudinit/sources/helpers/digitalocean.py
5@@ -162,7 +162,7 @@ def convert_network_configuration(config, dns_servers):
6 continue
7
8 sub_part = _get_subnet_part(raw_subnet)
9- if netdef in ('private', 'anchor_ipv4', 'anchor_ipv6'):
10+ if nic_type != "public" or "anchor" in netdef:
11 del sub_part['gateway']
12
13 subnets.append(sub_part)
14diff --git a/tests/unittests/test_datasource/test_digitalocean.py b/tests/unittests/test_datasource/test_digitalocean.py
15index a11166a..e97a679 100644
16--- a/tests/unittests/test_datasource/test_digitalocean.py
17+++ b/tests/unittests/test_datasource/test_digitalocean.py
18@@ -1,6 +1,8 @@
19 # Copyright (C) 2014 Neal Shrader
20 #
21 # Author: Neal Shrader <neal@digitalocean.com>
22+# Author: Ben Howard <bh@digitalocean.com>
23+# Author: Scott Moser <smoser@ubuntu.com>
24 #
25 # This file is part of cloud-init. See LICENSE file for license information.
26
27@@ -262,6 +264,29 @@ class TestNetworkConvert(TestCase):
28 print(json.dumps(subn, indent=3))
29 return subn
30
31+ def test_correct_gateways_defined(self):
32+ """test to make sure the eth0 ipv4 and ipv6 gateways are defined"""
33+ netcfg = self._get_networking()
34+ gateways = []
35+ for nic_def in netcfg.get('config'):
36+ if nic_def.get('type') != 'physical':
37+ continue
38+ for subn in nic_def.get('subnets'):
39+ if 'gateway' in subn:
40+ gateways.append(subn.get('gateway'))
41+
42+ # we should have two gateways, one ipv4 and ipv6
43+ self.assertEqual(len(gateways), 2)
44+
45+ # make that the ipv6 gateway is there
46+ (nic_def, meta_def) = self._get_nic_definition('public', 'eth0')
47+ ipv4_def = meta_def.get('ipv4')
48+ self.assertIn(ipv4_def.get('gateway'), gateways)
49+
50+ # make sure the the ipv6 gateway is there
51+ ipv6_def = meta_def.get('ipv6')
52+ self.assertIn(ipv6_def.get('gateway'), gateways)
53+
54 def test_public_interface_defined(self):
55 """test that the public interface is defined as eth0"""
56 (nic_def, meta_def) = self._get_nic_definition('public', 'eth0')

Subscribers

People subscribed via source and target branches