From 6211e9d3c8035a18c0b98197f15d4d70278d5152 Mon Sep 17 00:00:00 2001 From: Zhiwei-Dai Date: Fri, 6 Mar 2020 14:22:19 +0800 Subject: [PATCH] Compatibility fix of centos release version modified: ceph_deploy/hosts/centos/__init__.py Fix: https://tracker.ceph.com/issues/44365 Signed-off-by: Dai Zhiwei daizhiwei3@huawei.com Signed-off-by: luo rixin luorixin@huawei.com --- ceph_deploy/hosts/centos/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ceph_deploy/hosts/centos/__init__.py b/ceph_deploy/hosts/centos/__init__.py index daeae4c7..1f834011 100644 --- a/ceph_deploy/hosts/centos/__init__.py +++ b/ceph_deploy/hosts/centos/__init__.py @@ -18,6 +18,13 @@ def choose_init(module): Returns the name of a init system (upstart, sysvinit ...). """ + with open("/etc/rpm/macros.dist", 'r') as file: + lines = file.readlines() + for line in lines: + if 'centos' in line: + release_info = line.split()[1] + if release_info.isdigit() and int(release_info) >= 7: + return 'systemd' if module.normalized_release.int_major < 7: return 'sysvinit'