/usr/share/crmsh/scripts/init/init.py is in crmsh 2.2.0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #! /usr/bin/python
import crm_script
rc, _, err = crm_script.call(['crm', 'cluster', 'wait_for_startup', '30'])
if rc != 0:
crm_script.exit_fail("Cluster not responding")
def check_for_primitives():
rc, out, err = crm_script.call("crm configure show type:primitive | grep primitive", shell=True)
if rc == 0 and out:
return True
return False
if check_for_primitives():
crm_script.debug("Joined existing cluster - will not reconfigure")
crm_script.exit_ok(True)
try:
nodelist = crm_script.param('nodes')
if len(nodelist) < 3:
policy = 'ignore'
else:
policy = 'stop'
crm_script.save_template('./basic.cib.template',
'./basic.cib',
no_quorum_policy=policy)
except IOError, e:
crm_script.exit_fail("IO error: %s" % (str(e)))
except ValueError, e:
crm_script.exit_fail("Value error: %s" % (str(e)))
rc, _, err = crm_script.call(['crm', 'configure', 'load', 'replace', './basic.cib'])
if rc != 0:
crm_script.exit_fail("Failed to load CIB configuration: %s" % (err))
crm_script.exit_ok(True)
|