From e44fc4af68c6df56398c854121c892208733bc6e Mon Sep 17 00:00:00 2001 From: Sven Vogel <5433844+svenvogel@users.noreply.github.com> Date: Wed, 7 Nov 2018 21:22:20 +0100 Subject: [PATCH] add exitcode / distribution detection and remove export CGROUP_DAEMON for RHEL7/CentOS7 (#2896) * task/add distribution detection, remove export CGROUP_DAEMON='cpu:/virt' * taks/add exit values * change exit codes * split redhat and centos / change ubuntu to /etc/lsb-release file * turn around centos and rhel, we need first check for centos then rhel * set variable distro to None --- python/lib/cloudutils/serviceConfig.py | 29 +++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/python/lib/cloudutils/serviceConfig.py b/python/lib/cloudutils/serviceConfig.py index 2b27868db05..994c822ca01 100755 --- a/python/lib/cloudutils/serviceConfig.py +++ b/python/lib/cloudutils/serviceConfig.py @@ -23,6 +23,32 @@ from configFileOps import configFileOps import os import shutil +# exit() error constants +Unknown = 0 +CentOS6 = 1 +CentOS7 = 2 +Ubuntu = 3 +RHEL6 = 4 +RHEL7 = 5 +distro = None + +#=================== DISTRIBUTION DETECTION ================= +if os.path.exists("/etc/centos-release"): + version = file("/etc/centos-release").readline() + if version.find("CentOS release 6") != -1: + distro = CentOS6 + elif version.find("CentOS Linux release 7") != -1: + distro = CentOS7 +elif os.path.exists("/etc/redhat-release"): + version = file("/etc/redhat-release").readline() + if version.find("Red Hat Enterprise Linux Server release 6") != -1: + distro = RHEL6 + elif version.find("Red Hat Enterprise Linux Server 7") != -1: + distro = RHEL7 +elif os.path.exists("/etc/lsb-release") and "Ubuntu" in file("/etc/lsb-release").read(-1): distro = Ubuntu +else: distro = Unknown +#=================== DISTRIBUTION DETECTION ================= + class serviceCfgBase(object): def __init__(self, syscfg): self.status = None @@ -498,7 +524,8 @@ class libvirtConfigRedhat(serviceCfgBase): configureLibvirtConfig(self.syscfg.env.secure, self) cfo = configFileOps("/etc/sysconfig/libvirtd", self) - cfo.addEntry("export CGROUP_DAEMON", "'cpu:/virt'") + if distro in (CentOS6,RHEL6): + cfo.addEntry("export CGROUP_DAEMON", "'cpu:/virt'") cfo.addEntry("LIBVIRTD_ARGS", "-l") cfo.save()