Merge ~powersj/cloud-init:fix-arch-dns into cloud-init:master

Proposed by Joshua Powers
Status: Rejected
Rejected by: Scott Moser
Proposed branch: ~powersj/cloud-init:fix-arch-dns
Merge into: cloud-init:master
Diff against target: 93 lines (+59/-9)
2 files modified
cloudinit/distros/arch.py (+17/-9)
tests/unittests/test_distros/test_netctl.py (+42/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
cloud-init Commiters Pending
Review via email: mp+327914@code.launchpad.net

Commit message

archlinux: Fix empty dns on writing network config

cloud-init fails when dns-nameservers is None.

LP: #1663045

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:05e4261342dfbb6f5766450ecad4f2a6df929c06
https://jenkins.ubuntu.com/server/job/cloud-init-ci/78/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/78/rebuild

review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

Heres a bit larger change, but one that seems more generic.
I'd also like to add some tests for 'convert_netctl'.

http://paste.ubuntu.com/25164556/

Revision history for this message
Scott Moser (smoser) wrote :
Revision history for this message
Scott Moser (smoser) wrote :

I'll come back to this, but i put some stuff at
 https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+ref/bug/1663045-archlinux-empty-dns

which has a some unit tests too.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:6e47a2e039fbc0a8d6f02bad11762fb1edffae83
https://jenkins.ubuntu.com/server/job/cloud-init-ci/88/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/88/rebuild

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

PASSED: Continuous integration, rev:a682fa271e29ba5fb4b2ac67e8f7ed296cbc1ec9
https://jenkins.ubuntu.com/server/job/cloud-init-ci/90/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/90/rebuild

review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

I'm marking this rejected as I had opened up https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/328114 with some related work and unit tests with it.

I really hate how harsh 'rejected' sounds.

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/distros/arch.py b/cloudinit/distros/arch.py
2index b4c0ba7..03f997c 100644
3--- a/cloudinit/distros/arch.py
4+++ b/cloudinit/distros/arch.py
5@@ -61,10 +61,10 @@ class Distro(distros.Distro):
6 'Connection': 'ethernet',
7 'Interface': dev,
8 'IP': info.get('bootproto'),
9- 'Address': "('%s/%s')" % (info.get('address'),
10- info.get('netmask')),
11+ 'Address': "%s/%s" % (info.get('address'),
12+ info.get('netmask')),
13 'Gateway': info.get('gateway'),
14- 'DNS': str(tuple(info.get('dns-nameservers'))).replace(',', '')
15+ 'DNS': info.get('dns-nameservers', []),
16 }
17 util.write_file(net_fn, convert_netctl(net_cfg))
18 if info.get('auto'):
19@@ -174,12 +174,20 @@ class Distro(distros.Distro):
20
21
22 def convert_netctl(settings):
23- """Returns a settings string formatted for netctl."""
24- result = ''
25- if isinstance(settings, dict):
26- for k, v in settings.items():
27- result = result + '%s=%s\n' % (k, v)
28- return result
29+ """Given a dictionary, returns a string in netctl profile format.
30+
31+ https://git.archlinux.org/netctl.git/tree/docs/netctl.profile.5.txt
32+
33+ Note that the 'Special Quoting Rules' are not handled here"""
34+ result = []
35+ for key in sorted(settings):
36+ val = settings[key]
37+ if val is None:
38+ val = ""
39+ elif isinstance(val, (tuple, list)):
40+ val = "(" + ' '.join("'%s'" % v for v in val) + ")"
41+ result.append("%s=%s\n" % (key, val))
42+ return ''.join(result)
43
44
45 def convert_resolv_conf(settings):
46diff --git a/tests/unittests/test_distros/test_netctl.py b/tests/unittests/test_distros/test_netctl.py
47new file mode 100644
48index 0000000..d1670c3
49--- /dev/null
50+++ b/tests/unittests/test_distros/test_netctl.py
51@@ -0,0 +1,42 @@
52+# This file is part of cloud-init. See LICENSE file for license information.
53+
54+from cloudinit.distros.arch import convert_netctl as netctl
55+
56+from ..helpers import CiTestCase
57+
58+
59+NET_CFG_DHCP = '''
60+Interface=enp1s0
61+Connection=ethernet
62+IP=dhcp
63+'''
64+
65+NET_CFG_STATIC = '''
66+Interface=enp1s0
67+Connection=ethernet
68+IP=static
69+Address=('10.1.10.2/24')
70+Gateway=('10.1.10.1')
71+DNS=('10.1.10.1')
72+'''
73+
74+NET_CFG_BOND = '''
75+Description='Bond Interface'
76+Interface='bond0'
77+Connection=bond
78+BindsToInterfaces=('eth0' 'eth1')
79+IP=dhcp
80+IP6=stateless
81+'''
82+
83+
84+class TestNetctlDistro(CiTestCase):
85+ def test_basic_dhcp(self):
86+ """Simple dhcp config."""
87+ entries = {'Interface': 'enp1s0',
88+ 'Connection': 'ethernet',
89+ 'IP': 'DHCP'}
90+
91+ netctl(entries)
92+
93+# vi: ts=4 expandtab

Subscribers

People subscribed via source and target branches