From f1d44b20cd2d6e507199aad6d682ffeaf5e8a573 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Tue, 13 Aug 2013 09:10:27 -0400 Subject: [PATCH] better use of distro.init - thanks Mark Kirkwood! Signed-off-by: Alfredo Deza --- ceph_deploy/hosts/__init__.py | 1 + ceph_deploy/hosts/common.py | 7 +------ ceph_deploy/hosts/debian/mon/create.py | 6 ++++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ceph_deploy/hosts/__init__.py b/ceph_deploy/hosts/__init__.py index 182684b..3cbd011 100644 --- a/ceph_deploy/hosts/__init__.py +++ b/ceph_deploy/hosts/__init__.py @@ -40,6 +40,7 @@ def get(hostname, fallback=None): module.release = release module.codename = codename module.sudo_conn = sudo_conn + module.init = lsb.choose_init(distro, codename) return module diff --git a/ceph_deploy/hosts/common.py b/ceph_deploy/hosts/common.py index f5e3b8a..d17cf71 100644 --- a/ceph_deploy/hosts/common.py +++ b/ceph_deploy/hosts/common.py @@ -31,12 +31,7 @@ def mon_create(distro, logger, args, monitor_keyring, hostname): logger.debug('remote hostname: %s' % hostname) path = paths.mon.path(args.cluster, hostname) done_path = paths.mon.done(args.cluster, hostname) - if distro.name.lower() == 'ubuntu': - init = 'upstart' - else: - init = 'sysvinit' - - init_path = paths.mon.init(args.cluster, hostname, init) + init_path = paths.mon.init(args.cluster, hostname, distro.init) configuration = conf.load(args) conf_data = StringIO() diff --git a/ceph_deploy/hosts/debian/mon/create.py b/ceph_deploy/hosts/debian/mon/create.py index 1a849c5..e317ba3 100644 --- a/ceph_deploy/hosts/debian/mon/create.py +++ b/ceph_deploy/hosts/debian/mon/create.py @@ -6,7 +6,7 @@ def create(distro, logger, args, monitor_keyring): hostname = distro.sudo_conn.modules.socket.gethostname().split('.')[0] common.mon_create(distro, logger, args, monitor_keyring, hostname) - if distro.name.lower() == 'ubuntu': + if distro.init == 'upstart': # Ubuntu uses upstart check_call( distro.sudo_conn, logger, @@ -19,7 +19,7 @@ def create(distro, logger, args, monitor_keyring): ], ) - else: # Debian doesn't use initctl + elif distro.init == 'sysvinit': # Debian uses sysvinit service = common.which_service(distro.sudo_conn, logger) check_call( @@ -32,3 +32,5 @@ def create(distro, logger, args, monitor_keyring): 'mon.{hostname}'.format(hostname=hostname) ], ) + else: + raise RuntimeError('create cannot use init %s' % distro.init) -- 2.47.3