Exemple #1
0
def run_corosync():
    # create corosync.conf

    nodelist = crm_script.output(2).keys()
    nodelist_txt = ""
    for i, node in enumerate(nodelist):
        nodelist_txt += """
    node {
        ring0_addr: %s
        nodeid: %s
    }
""" % (node, i + 1)

    quorum_txt = ""
    if len(nodelist) == 1:
        quorum_txt = ''
    if len(nodelist) == 2:
        quorum_txt = """    two_node: 1
"""
    else:
        quorum_txt = """    provider: corosync_votequorum
    expected_votes: %s
""" % ((len(nodelist) / 2) + 1)

    try:
        crm_script.save_template('./corosync.conf.template',
                                 '/etc/corosync/corosync.conf',
                                 bindnetaddr=make_bindnetaddr(),
                                 mcastaddr=crm_script.param('mcastaddr'),
                                 mcastport=crm_script.param('mcastport'),
                                 transport=crm_script.param('transport'),
                                 nodelist=nodelist_txt,
                                 quorum=quorum_txt)
    except Exception, e:
        crm_script.exit_fail(str(e))
Exemple #2
0
def run_corosync():
    # create corosync.conf

    nodelist = crm_script.output(1).keys()
    nodelist_txt = ""
    for i, node in enumerate(nodelist):
        nodelist_txt += """
    node {
        ring0_addr: %s
        nodeid: %s
    }
""" % (node, i + 1)

    quorum_txt = ""
    if len(nodelist) == 1:
        quorum_txt = ''
    if len(nodelist) == 2:
        quorum_txt = """    two_node: 1
"""
    else:
        quorum_txt = """    provider: corosync_votequorum
    expected_votes: %s
""" % ((len(nodelist) / 2) + 1)

    try:
        crm_script.save_template('./corosync.conf.template',
                                 '/etc/corosync/corosync.conf',
                                 bindnetaddr=make_bindnetaddr(),
                                 mcastaddr=crm_script.param('mcastaddr'),
                                 mcastport=crm_script.param('mcastport'),
                                 transport=crm_script.param('transport'),
                                 nodelist=nodelist_txt,
                                 quorum=quorum_txt)
    except Exception, e:
        crm_script.exit_fail(str(e))
Exemple #3
0
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')
    crm_script.save_template('./basic.cib.template',
                             './basic.cib')
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)
Exemple #4
0
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)
Exemple #5
0
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')
    crm_script.save_template('./basic.cib.template', './basic.cib')
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)
Exemple #6
0
        "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)