Detect and configure mons correctly for systemd ubuntu

This commit is contained in:
James Page 2015-03-23 17:40:42 +00:00
parent ce8970106c
commit 11b989dc38
2 changed files with 21 additions and 4 deletions

View File

@ -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:

View File

@ -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())