19
19
utils.juju_log('INFO', 'Begin install hook.')
20
20
utils.configure_source()
21
utils.install('corosync', 'pacemaker', 'python-netaddr')
21
utils.install('corosync', 'pacemaker', 'python-netaddr', 'ipmitool')
22
22
utils.juju_log('INFO', 'End install hook.')
301
306
with open(HAMARKER, 'w') as marker:
302
307
marker.write('done')
309
def configure_stonith():
310
if utils.config_get('stonith_enabled') not in ['true', 'True']:
313
if not os.path.exists(HAMARKER):
314
utils.juju_log('INFO',
315
'HA not yet configured, skipping STONITH config.')
318
utils.juju_log('INFO', 'Configuring STONITH for all nodes in cluster.')
319
# configure stontih resources for all nodes in cluster.
320
# note: this is totally provider dependent and requires
321
# access to the MAAS API endpoint, using endpoint and credentials
323
url = utils.config_get('maas_url')
324
creds = utils.config_get('maas_credentials')
325
if None in [url, creds]:
326
utils.juju_log('ERROR', 'maas_url and maas_credentials must be set'\
327
' in config to enable STONITH.')
330
maas = MAAS.MAASHelper(url, creds)
331
nodes = maas.list_nodes()
333
utils.juju_log('ERROR', 'Could not obtain node inventory from '\
337
cluster_nodes = pcmk.list_nodes()
338
for node in cluster_nodes:
339
rsc, constraint = pcmk.maas_stonith_primitive(nodes, node)
341
utils.juju_log('ERROR',
342
'Failed to determine STONITH primitive for node'\
346
rsc_name = rsc.split(' ')[1]
347
if not pcmk.is_resource_present(rsc_name):
348
utils.juju_log('INFO', 'Creating new STONITH primitive %s.' %\
350
cmd = 'crm -F configure %s' % rsc
353
cmd = 'crm -F configure %s' % constraint
356
utils.juju_log('INFO', 'STONITH primitive already exists '\
359
cmd = "crm configure property stonith-enabled=true"
305
363
def ha_relation_departed():
306
364
# TODO: Fin out which node is departing and put it in standby mode.