cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #00695
[Merge] lp:~larsks/cloud-init/fix-systemd-detection into lp:cloud-init
Lars Kellogg-Stedman has proposed merging lp:~larsks/cloud-init/fix-systemd-detection into lp:cloud-init.
Requested reviews:
cloud init development team (cloud-init-dev)
Related bugs:
Bug #1461201 in cloud-init: "Check for systemd (in distros/rhel.py) is fragile"
https://bugs.launchpad.net/cloud-init/+bug/1461201
For more details, see:
https://code.launchpad.net/~larsks/cloud-init/fix-systemd-detection/+merge/260885
check for systemd using sd_booted() semantics
The existing cloud-init code determines if systemd is in use by looking at the
distribution name and version. This is prone to error because:
- RHEL derivatives other than CentOS (e.g., Scientific Linux) will fail this test, and
- Distributions that are not derived from RHEL also use systemd
This patch makes cloud-init use the same logic that is used in systemd's
sd_booted() method
(http://www.freedesktop.org/software/systemd/man/sd_booted.html)
--
Your team cloud init development team is requested to review the proposed merge of lp:~larsks/cloud-init/fix-systemd-detection into lp:cloud-init.
=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py 2015-05-19 15:21:34 +0000
+++ cloudinit/distros/__init__.py 2015-06-02 20:30:42 +0000
@@ -27,6 +27,7 @@
import abc
import os
import re
+import stat
from cloudinit import importer
from cloudinit import log as logging
@@ -89,6 +90,13 @@
self._write_hostname(writeable_hostname, self.hostname_conf_fn)
self._apply_hostname(writeable_hostname)
+ def uses_systemd(self):
+ try:
+ res = os.lstat('/run/systemd/system')
+ return stat.S_ISDIR(res.st_mode)
+ except:
+ return False
+
@abc.abstractmethod
def package_command(self, cmd, args=None, pkgs=None):
raise NotImplementedError()
=== modified file 'cloudinit/distros/rhel.py'
--- cloudinit/distros/rhel.py 2015-05-15 20:28:24 +0000
+++ cloudinit/distros/rhel.py 2015-06-02 20:30:42 +0000
@@ -111,14 +111,6 @@
rhel_util.update_sysconfig_file(self.network_conf_fn, net_cfg)
return dev_names
- 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])
- return ((dist.startswith('Red Hat Enterprise Linux') and major >= 7)
- or (dist.startswith('CentOS Linux') and major >= 7)
- or (dist.startswith('Fedora') and major >= 18))
-
def apply_locale(self, locale, out_fn=None):
if self.uses_systemd():
if not out_fn:
Follow ups