summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--cloudinit/distros/rhel.py12
-rw-r--r--packages/redhat/cloud-init.spec.in5
-rw-r--r--tests/unittests/test_handler/test_handler_set_hostname.py9
4 files changed, 17 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index d2fc2d69..63bb50ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
0.7.7:
- open 0.7.7
- Digital Ocean: add datasource for Digital Ocean. [Neal Shrader]
+ - expose uses_systemd as a distro function (fix rhel7)
0.7.6:
- open 0.7.6
- Enable vendordata on CloudSigma datasource (LP: #1303986)
diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py
index e8abf111..1a269e08 100644
--- a/cloudinit/distros/rhel.py
+++ b/cloudinit/distros/rhel.py
@@ -98,7 +98,7 @@ class Distro(distros.Distro):
rhel_util.update_sysconfig_file(self.network_conf_fn, net_cfg)
return dev_names
- def _dist_uses_systemd(self):
+ def uses_systemd(self):
# Fedora 18 and RHEL 7 were the first adopters in their series
(dist, vers) = util.system_info()['dist'][:2]
major = (int)(vers.split('.')[0])
@@ -106,7 +106,7 @@ class Distro(distros.Distro):
or (dist.startswith('Fedora') and major >= 18))
def apply_locale(self, locale, out_fn=None):
- if self._dist_uses_systemd():
+ if self.uses_systemd():
if not out_fn:
out_fn = self.systemd_locale_conf_fn
out_fn = self.systemd_locale_conf_fn
@@ -119,7 +119,7 @@ class Distro(distros.Distro):
rhel_util.update_sysconfig_file(out_fn, locale_cfg)
def _write_hostname(self, hostname, out_fn):
- if self._dist_uses_systemd():
+ if self.uses_systemd():
util.subp(['hostnamectl', 'set-hostname', str(hostname)])
else:
host_cfg = {
@@ -135,14 +135,14 @@ class Distro(distros.Distro):
return hostname
def _read_system_hostname(self):
- if self._dist_uses_systemd():
+ if self.uses_systemd():
host_fn = self.systemd_hostname_conf_fn
else:
host_fn = self.hostname_conf_fn
return (host_fn, self._read_hostname(host_fn))
def _read_hostname(self, filename, default=None):
- if self._dist_uses_systemd():
+ if self.uses_systemd():
(out, _err) = util.subp(['hostname'])
if len(out):
return out
@@ -163,7 +163,7 @@ class Distro(distros.Distro):
def set_timezone(self, tz):
tz_file = self._find_tz_file(tz)
- if self._dist_uses_systemd():
+ if self.uses_systemd():
# Currently, timedatectl complains if invoked during startup
# so for compatibility, create the link manually.
util.del_file(self.tz_local_fn)
diff --git a/packages/redhat/cloud-init.spec.in b/packages/redhat/cloud-init.spec.in
index 0e9862d8..75dd4d22 100644
--- a/packages/redhat/cloud-init.spec.in
+++ b/packages/redhat/cloud-init.spec.in
@@ -92,6 +92,11 @@ mkdir -p \$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d
cp -p tools/21-cloudinit.conf \
\$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf
+#if $systemd
+mkdir -p \$RPM_BUILD_ROOT/%{_unitdir}
+cp -p systemd/* \$RPM_BUILD_ROOT/%{_unitdir}
+#end if
+
%clean
rm -rf \$RPM_BUILD_ROOT
diff --git a/tests/unittests/test_handler/test_handler_set_hostname.py b/tests/unittests/test_handler/test_handler_set_hostname.py
index 03004ab9..e1530e30 100644
--- a/tests/unittests/test_handler/test_handler_set_hostname.py
+++ b/tests/unittests/test_handler/test_handler_set_hostname.py
@@ -37,10 +37,11 @@ class TestHostname(t_help.FilesystemMockingTestCase):
self.patchUtils(self.tmp)
cc_set_hostname.handle('cc_set_hostname',
cfg, cc, LOG, [])
- contents = util.load_file("/etc/sysconfig/network")
- n_cfg = ConfigObj(StringIO(contents))
- self.assertEquals({'HOSTNAME': 'blah.blah.blah.yahoo.com'},
- dict(n_cfg))
+ if not distro.uses_systemd():
+ contents = util.load_file("/etc/sysconfig/network")
+ n_cfg = ConfigObj(StringIO(contents))
+ self.assertEquals({'HOSTNAME': 'blah.blah.blah.yahoo.com'},
+ dict(n_cfg))
def test_write_hostname_debian(self):
cfg = {