Merge lp:~harlowja/cloud-init/fixed-rhel7 into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Joshua Harlow
Status: Merged
Merged at revision: 1029
Proposed branch: lp:~harlowja/cloud-init/fixed-rhel7
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 92 lines (+16/-10)
3 files modified
cloudinit/distros/rhel.py (+6/-6)
packages/redhat/cloud-init.spec.in (+5/-0)
tests/unittests/test_handler/test_handler_set_hostname.py (+5/-4)
To merge this branch: bzr merge lp:~harlowja/cloud-init/fixed-rhel7
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+238766@code.launchpad.net

Description of the change

Expose uses_systemd as a distro function

To post a comment you must log in.
lp:~harlowja/cloud-init/fixed-rhel7 updated
1027. By Joshua Harlow

Include the systemd config files

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/distros/rhel.py'
2--- cloudinit/distros/rhel.py 2014-02-03 22:03:14 +0000
3+++ cloudinit/distros/rhel.py 2014-10-17 20:28:21 +0000
4@@ -98,7 +98,7 @@
5 rhel_util.update_sysconfig_file(self.network_conf_fn, net_cfg)
6 return dev_names
7
8- def _dist_uses_systemd(self):
9+ def uses_systemd(self):
10 # Fedora 18 and RHEL 7 were the first adopters in their series
11 (dist, vers) = util.system_info()['dist'][:2]
12 major = (int)(vers.split('.')[0])
13@@ -106,7 +106,7 @@
14 or (dist.startswith('Fedora') and major >= 18))
15
16 def apply_locale(self, locale, out_fn=None):
17- if self._dist_uses_systemd():
18+ if self.uses_systemd():
19 if not out_fn:
20 out_fn = self.systemd_locale_conf_fn
21 out_fn = self.systemd_locale_conf_fn
22@@ -119,7 +119,7 @@
23 rhel_util.update_sysconfig_file(out_fn, locale_cfg)
24
25 def _write_hostname(self, hostname, out_fn):
26- if self._dist_uses_systemd():
27+ if self.uses_systemd():
28 util.subp(['hostnamectl', 'set-hostname', str(hostname)])
29 else:
30 host_cfg = {
31@@ -135,14 +135,14 @@
32 return hostname
33
34 def _read_system_hostname(self):
35- if self._dist_uses_systemd():
36+ if self.uses_systemd():
37 host_fn = self.systemd_hostname_conf_fn
38 else:
39 host_fn = self.hostname_conf_fn
40 return (host_fn, self._read_hostname(host_fn))
41
42 def _read_hostname(self, filename, default=None):
43- if self._dist_uses_systemd():
44+ if self.uses_systemd():
45 (out, _err) = util.subp(['hostname'])
46 if len(out):
47 return out
48@@ -163,7 +163,7 @@
49
50 def set_timezone(self, tz):
51 tz_file = self._find_tz_file(tz)
52- if self._dist_uses_systemd():
53+ if self.uses_systemd():
54 # Currently, timedatectl complains if invoked during startup
55 # so for compatibility, create the link manually.
56 util.del_file(self.tz_local_fn)
57
58=== modified file 'packages/redhat/cloud-init.spec.in'
59--- packages/redhat/cloud-init.spec.in 2014-02-10 20:48:41 +0000
60+++ packages/redhat/cloud-init.spec.in 2014-10-17 20:28:21 +0000
61@@ -92,6 +92,11 @@
62 cp -p tools/21-cloudinit.conf \
63 \$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf
64
65+#if $systemd
66+mkdir -p \$RPM_BUILD_ROOT/%{_unitdir}
67+cp -p systemd/* \$RPM_BUILD_ROOT/%{_unitdir}
68+#end if
69+
70 %clean
71 rm -rf \$RPM_BUILD_ROOT
72
73
74=== modified file 'tests/unittests/test_handler/test_handler_set_hostname.py'
75--- tests/unittests/test_handler/test_handler_set_hostname.py 2014-07-23 16:16:07 +0000
76+++ tests/unittests/test_handler/test_handler_set_hostname.py 2014-10-17 20:28:21 +0000
77@@ -37,10 +37,11 @@
78 self.patchUtils(self.tmp)
79 cc_set_hostname.handle('cc_set_hostname',
80 cfg, cc, LOG, [])
81- contents = util.load_file("/etc/sysconfig/network")
82- n_cfg = ConfigObj(StringIO(contents))
83- self.assertEquals({'HOSTNAME': 'blah.blah.blah.yahoo.com'},
84- dict(n_cfg))
85+ if not distro.uses_systemd():
86+ contents = util.load_file("/etc/sysconfig/network")
87+ n_cfg = ConfigObj(StringIO(contents))
88+ self.assertEquals({'HOSTNAME': 'blah.blah.blah.yahoo.com'},
89+ dict(n_cfg))
90
91 def test_write_hostname_debian(self):
92 cfg = {