summaryrefslogtreecommitdiff
path: root/cloudinit/distros/__init__.py
diff options
context:
space:
mode:
authorLars Kellogg-Stedman <lars@redhat.com>2015-06-02 16:27:57 -0400
committerLars Kellogg-Stedman <lars@redhat.com>2015-06-02 16:27:57 -0400
commit04a5edaa33d6a7e64f95c04eceaa82eec12cb237 (patch)
tree06e83581c2d60fd9c1d72810cab7f4638d5a0a29 /cloudinit/distros/__init__.py
parent5a8f6c82da94ab87f21b39dc30a0e85ddbc85216 (diff)
downloadvyos-cloud-init-04a5edaa33d6a7e64f95c04eceaa82eec12cb237.tar.gz
vyos-cloud-init-04a5edaa33d6a7e64f95c04eceaa82eec12cb237.zip
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) LP: #1461201
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r--cloudinit/distros/__init__.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index e0cce670..8a947867 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -27,6 +27,7 @@ from six import StringIO
import abc
import os
import re
+import stat
from cloudinit import importer
from cloudinit import log as logging
@@ -89,6 +90,13 @@ class Distro(object):
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()