Installs openstack|ceph-resource-agents before trying to configure any otherwise it causes error
Checks whether the services are running and started before trying to cleanup. If they are don't do anything.
This commit is contained in:
parent
6a62b338a1
commit
65ebf18da3
|
@ -197,6 +197,13 @@ def configure_cluster():
|
|||
'Related to {} ha services'.format(len(relids)))
|
||||
return
|
||||
|
||||
if True in [ra.startswith('ocf:openstack')
|
||||
for ra in resources.itervalues()]:
|
||||
utils.install('openstack-resource-agents')
|
||||
if True in [ra.startswith('ocf:ceph')
|
||||
for ra in resources.itervalues()]:
|
||||
utils.install('ceph-resource-agents')
|
||||
|
||||
utils.juju_log('INFO', 'Configuring and restarting corosync')
|
||||
emit_corosync_conf()
|
||||
restart_corosync()
|
||||
|
@ -215,13 +222,6 @@ def configure_cluster():
|
|||
utils.juju_log('INFO', 'Configuring Resources')
|
||||
utils.juju_log('INFO', str(resources))
|
||||
|
||||
if True in [ra.startswith('ocf:openstack')
|
||||
for ra in resources.itervalues()]:
|
||||
utils.install('openstack-resource-agents')
|
||||
if True in [ra.startswith('ocf:ceph')
|
||||
for ra in resources.itervalues()]:
|
||||
utils.install('ceph-resource-agents')
|
||||
|
||||
for res_name, res_type in resources.iteritems():
|
||||
# disable the service we are going to put in HA
|
||||
if res_type.split(':')[0] == "lsb":
|
||||
|
@ -288,17 +288,18 @@ def configure_cluster():
|
|||
utils.juju_log('INFO', '%s' % cmd)
|
||||
|
||||
for res_name, res_type in resources.iteritems():
|
||||
# TODO: This should first check that the resources is running
|
||||
if len(init_services) != 0 and res_name in init_services:
|
||||
# If the resource is in HA already, and it is a service, restart
|
||||
# the pcmk resource as the config file might have changed by the
|
||||
# principal charm
|
||||
cmd = 'crm resource restart %s' % res_name
|
||||
pcmk.commit(cmd)
|
||||
# Just in case, cleanup the resources to ensure they get started
|
||||
# in case they failed for some unrelated reason.
|
||||
cmd = 'crm resource cleanup %s' % res_name
|
||||
pcmk.commit(cmd)
|
||||
# Checks that the resources are running and started.
|
||||
if not pcmk.crm_res_running(res_name):
|
||||
# If the resource is in HA already, and it is a service, restart
|
||||
# the pcmk resource as the config file might have changed by the
|
||||
# principal charm
|
||||
#cmd = 'crm resource restart %s' % res_name
|
||||
#pcmk.commit(cmd)
|
||||
# Just in case, cleanup the resources to ensure they get started
|
||||
# in case they failed for some unrelated reason.
|
||||
cmd = 'crm resource cleanup %s' % res_name
|
||||
pcmk.commit(cmd)
|
||||
|
||||
for rel_id in utils.relation_ids('ha'):
|
||||
utils.relation_set(rid=rel_id,
|
||||
|
|
|
@ -53,6 +53,13 @@ def crm_opt_exists(opt_name):
|
|||
return True
|
||||
return False
|
||||
|
||||
def crm_res_running(opt_name):
|
||||
(status, output) = commands.getstatusoutput("crm resource status %s" % opt_name)
|
||||
show_re = re.compile('NOT running')
|
||||
opt = show_re.search(output)
|
||||
if opt:
|
||||
return False
|
||||
return True
|
||||
|
||||
def list_nodes():
|
||||
cmd = ['crm', 'node', 'list']
|
||||
|
|
Loading…
Reference in New Issue