First pass at STONITH support.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user