wait for 3 potential monitors to show up, and then try to configure the cluster
This commit is contained in:
parent
b89c608f26
commit
e0921c3a80
|
@ -8,6 +8,13 @@ options:
|
|||
default: /dev/sdb /dev/sdc /dev/sdd /dev/sde
|
||||
description: |
|
||||
the devices to format and set up as osd volumes
|
||||
monitor-count:
|
||||
type: int
|
||||
default: 3
|
||||
description: |
|
||||
how many nodes to wait for before trying to create the monitor cluster
|
||||
this number needs to be odd, and more than three is a waste except for
|
||||
very large clusters
|
||||
monitor-secret:
|
||||
type: string
|
||||
description: |
|
||||
|
|
|
@ -75,9 +75,42 @@ def get_mon_hosts():
|
|||
hosts.sort()
|
||||
return hosts
|
||||
|
||||
def bootstrap_monitor_cluster():
|
||||
hostname = os.uname()[1]
|
||||
done = "/var/lib/ceph/mon/ceph-%s/done" % hostname
|
||||
secret = utils.config_get('monitor-secret')
|
||||
keyring = "/var/lib/ceph/tmp/%s.mon.keyring" % hostname
|
||||
|
||||
try:
|
||||
with os.fdopen(os.open(done, os.O_WRONLY | os.O_CREAT | os.O_EXCL)) as d:
|
||||
try:
|
||||
subprocess.check_call(['ceph-authtool', keyring,
|
||||
'--create-keyring' '--name=mon.'
|
||||
"--add-key=" % secret,
|
||||
'--cap', 'mon', 'allow *'])
|
||||
|
||||
subprocess.check_call(['ceph-mon', '--mkfs',
|
||||
'-i', hostname,
|
||||
'--keyring', keyring])
|
||||
except:
|
||||
os.unlink(done)
|
||||
os.unlink(keyring)
|
||||
raise
|
||||
subprocess.check_call(['start', 'ceph-mon-all-starter'])
|
||||
except OSError:
|
||||
utils.juju_log('INFO', 'bootstrap_monitor_cluster: mon already initialized, getting on with life.')
|
||||
|
||||
def mon_relation():
|
||||
utils.juju_log('INFO', 'Begin mon-relation hook.')
|
||||
emit_cephconf()
|
||||
|
||||
moncount = utils.config_get('monitor-count')
|
||||
if len(get_mon_hosts()) == moncount:
|
||||
bootstrap_monitor_cluster()
|
||||
else:
|
||||
utils.juju_log('INFO',
|
||||
"Not enough mons (%d), punting." % len(get_mon_hosts()))
|
||||
|
||||
utils.juju_log('INFO', 'End mon-relation hook.')
|
||||
|
||||
def upgrade_charm():
|
||||
|
|
Loading…
Reference in New Issue