diff --git a/hooks/ceph.py b/hooks/ceph.py index b0d7be1..25d04e5 100644 --- a/hooks/ceph.py +++ b/hooks/ceph.py @@ -15,11 +15,13 @@ from charmhelpers.core.host import ( mkdir, service_restart, cmp_pkgrevno, + lsb_release ) from charmhelpers.core.hookenv import ( log, ERROR, WARNING, + cached ) from charmhelpers.contrib.storage.linux.utils import ( zap_disk, @@ -274,11 +276,20 @@ def upgrade_key_caps(key, caps): subprocess.check_call(cmd) +@cached +def systemd(): + return (lsb_release()['DISTRIB_CODENAME'] >= 'vivid') + + def bootstrap_monitor_cluster(secret): hostname = get_unit_hostname() path = '/var/lib/ceph/mon/ceph-{}'.format(hostname) done = '{}/done'.format(path) - upstart = '{}/upstart'.format(path) + if systemd(): + init_marker = '{}/systemd'.format(path) + else: + init_marker = '{}/upstart'.format(path) + keyring = '/var/lib/ceph/tmp/{}.mon.keyring'.format(hostname) if os.path.exists(done): @@ -300,10 +311,13 @@ def bootstrap_monitor_cluster(secret): with open(done, 'w'): pass - with open(upstart, 'w'): + with open(init_marker, 'w'): pass - service_restart('ceph-mon-all') + if systemd(): + service_restart('ceph-mon') + else: + service_restart('ceph-mon-all') except: raise finally: diff --git a/hooks/hooks.py b/hooks/hooks.py index 6c2e723..681c437 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -338,7 +338,10 @@ def upgrade_charm(): def start(): # In case we're being redeployed to the same machines, try # to make sure everything is running as soon as possible. - service_restart('ceph-mon-all') + if ceph.systemd(): + service_restart('ceph-mon') + else: + service_restart('ceph-mon-all') if ceph.is_bootstrapped(): ceph.start_osds(get_devices())