First pass at STONITH support.

This commit is contained in:
Adam Gandelman
2013-01-24 13:24:09 -08:00
parent ec0748635a
commit cba1d3c816
4 changed files with 149 additions and 0 deletions

View File

@@ -293,6 +293,37 @@ def configure_cluster():
cmd = 'crm resource cleanup %s' % res_name
pcmk.commit(cmd)
if utils.config_get('stonith_enabled') in ['true', 'True']:
utils.juju_log('INFO', 'Configuring STONITH for all nodes in cluster.')
# configure stontih resources for all nodes in cluster.
# note: this is totally provider dependent and requires
# access to the MAAS API endpoint, using endpoint and credentials
# set in config.
url = utils.config_get('maas_url')
creds = utils.config_get('maas_credentials')
if None in [url, creds]:
utils.juju_log('ERROR', 'maas_url and maas_credentials must be set'\
' in config to enable STONITH.')
maas = maas.MAASHelper(url, creds)
nodes = maas.list_nodes()
if not nodes:
utils.juju_log('ERROR', 'Could not obtain node inventory from '\
'MAAS @ %s.' % url)
sys.exit(1)
hosts = get_cluster_nodes()
for host in hosts:
rsc, constraint = pcmk.maas_stonith_primitive(nodes, host)
if not rsc:
utils.juju_log('ERROR',
'Failed to determine STONITH primitive for node'\
' %s' % host)
cmd = 'crm -F configure %s' % rsc
pcmk.commit(cmd)
if constraint:
cmd = 'crm -F configure %s' % constraint
pcmk.commit(cmd)
for rel_id in utils.relation_ids('ha'):
utils.relation_set(rid=rel_id,
clustered="yes")