GeezerVison is showing github.com — add exitcode / distribution detection and remove export CGROUP_DAEMON… · DIMSI-IS/cloudstack@e44fc4a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: python/lib/cloudutils/serviceConfig.py +28-1Lines changed: 28 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
23 | 23 | import os |
24 | 24 | import shutil |
25 | 25 |
|
| 26 | +# exit() error constants |
| 27 | +Unknown = 0 |
| 28 | +CentOS6 = 1 |
| 29 | +CentOS7 = 2 |
| 30 | +Ubuntu = 3 |
| 31 | +RHEL6 = 4 |
| 32 | +RHEL7 = 5 |
| 33 | +distro = None |
| 34 | + |
| 35 | +#=================== DISTRIBUTION DETECTION ================= |
| 36 | +if os.path.exists("/etc/centos-release"): |
| 37 | + version = file("/etc/centos-release").readline() |
| 38 | + if version.find("CentOS release 6") != -1: |
| 39 | + distro = CentOS6 |
| 40 | + elif version.find("CentOS Linux release 7") != -1: |
| 41 | + distro = CentOS7 |
| 42 | +elif os.path.exists("/etc/redhat-release"): |
| 43 | + version = file("/etc/redhat-release").readline() |
| 44 | + if version.find("Red Hat Enterprise Linux Server release 6") != -1: |
| 45 | + distro = RHEL6 |
| 46 | + elif version.find("Red Hat Enterprise Linux Server 7") != -1: |
| 47 | + distro = RHEL7 |
| 48 | +elif os.path.exists("/etc/lsb-release") and "Ubuntu" in file("/etc/lsb-release").read(-1): distro = Ubuntu |
| 49 | +else: distro = Unknown |
| 50 | +#=================== DISTRIBUTION DETECTION ================= |
| 51 | + |
26 | 52 | class serviceCfgBase(object): |
27 | 53 | def __init__(self, syscfg): |
28 | 54 | self.status = None |
@@ -498,7 +524,8 @@ def config(self): |
498 | 524 | configureLibvirtConfig(self.syscfg.env.secure, self) |
499 | 525 |
|
500 | 526 | cfo = configFileOps("/etc/sysconfig/libvirtd", self) |
501 | | - cfo.addEntry("export CGROUP_DAEMON", "'cpu:/virt'") |
| 527 | + if distro in (CentOS6,RHEL6): |
| 528 | + cfo.addEntry("export CGROUP_DAEMON", "'cpu:/virt'") |
502 | 529 | cfo.addEntry("LIBVIRTD_ARGS", "-l") |
503 | 530 | cfo.save() |
504 | 531 |
|
|