Пример #1
0
def enable_cluster(argv):
    if len(argv) > 0:
        for node in argv:
            utils.enableCluster(node)
            return

    utils.enableServices()
Пример #2
0
def enable_cluster(argv):
    if len(argv) > 0:
        for node in argv:
            utils.enableCluster(node)
            return

    utils.enableServices()
Пример #3
0
def enable_cluster(argv):
    if len(argv) > 0:
        for node in argv:
            utils.enableCluster(node)
            return

    utils.run(["systemctl", "enable", "corosync.service"])
    utils.run(["systemctl", "enable", "pacemaker.service"])
Пример #4
0
def enable_cluster(argv):
    if len(argv) > 0:
        for node in argv:
            utils.enableCluster(node)
            return

    utils.run(["systemctl", "enable", "corosync.service"])
    utils.run(["systemctl", "enable", "pacemaker.service"])
Пример #5
0
def enable_cluster(argv):
    if len(argv) > 0:
        failure = False
        errors = ""
        for node in argv:
            (retval, err) = utils.enableCluster(node)
            if retval != 0:
                failure = True
                errors = errors + err+"\n"
        if failure:
            utils.err("unable to enable all nodes\n" + errors.rstrip())
        return

    utils.enableServices()
Пример #6
0
def enable_cluster(argv):
    if len(argv) > 0:
        failure = False
        errors = ""
        for node in argv:
            (retval, err) = utils.enableCluster(node)
            if retval != 0:
                failure = True
                errors = errors + err + "\n"
        if failure:
            utils.err("unable to enable all nodes\n" + errors.rstrip())
        return

    utils.enableServices()
Пример #7
0
def cluster_node(argv):
    if len(argv) != 2:
        usage.cluster();
        sys.exit(1)

    if argv[0] == "add":
        add_node = True
    elif argv[0] in ["remove","delete"]:
        add_node = False
    else:
        usage.cluster();
        sys.exit(1)

    node = argv[1]
    if "," in node:
        node0 = node.split(",")[0]
        node1 = node.split(",")[1]
    else:
        node0 = node
        node1 = None

    status,output = utils.checkAuthorization(node0)
    if status == 2:
        utils.err("pcsd is not running on %s" % node0)
    elif status == 3:
        utils.err(
            "%s is not yet authenticated (try pcs cluster auth %s)"
            % (node0, node0)
        )

    if add_node == True:
        if node1 is None and utils.need_ring1_address(utils.getCorosyncConf()):
            utils.err(
                "cluster is configured for RRP, "
                "you have to specify ring 1 address for the node"
            )
        elif (
            node1 is not None
            and
            not utils.need_ring1_address(utils.getCorosyncConf())
        ):
            utils.err(
                "cluster is not configured for RRP, "
                "you must not specify ring 1 address for the node"
            )
        corosync_conf = None
        (canAdd, error) =  utils.canAddNodeToCluster(node0)
        if not canAdd:
            utils.err("Unable to add '%s' to cluster: %s" % (node0, error))

        for my_node in utils.getNodesFromCorosyncConf():
            retval, output = utils.addLocalNode(my_node, node0, node1)
            if retval != 0:
                print >> sys.stderr, "Error: unable to add %s on %s - %s" % (node0, my_node, output.strip())
            else:
                print "%s: Corosync updated" % my_node
                corosync_conf = output
        if corosync_conf != None:
            utils.setCorosyncConfig(node0, corosync_conf)
            if "--enable" in utils.pcs_options:
                utils.enableCluster(node0)
            if "--start" in utils.pcs_options:
                utils.startCluster(node0)
        else:
            utils.err("Unable to update any nodes")
    else:
        nodesRemoved = False
        c_nodes = utils.getNodesFromCorosyncConf()
        destroy_cluster([node0])
        for my_node in c_nodes:
            if my_node == node0:
                continue
            retval, output = utils.removeLocalNode(my_node, node0)
            if retval != 0:
                print >> sys.stderr, "Error: unable to remove %s on %s - %s" % (node0,my_node,output.strip())
            else:
                if output[0] == 0:
                    print "%s: Corosync updated" % my_node
                    nodesRemoved = True
                else:
                    print >> sys.stderr, "%s: Error executing command occured: %s" % (my_node, "".join(output[1]))
        if nodesRemoved == False:
            utils.err("Unable to update any nodes")

        output, retval = utils.run(["crm_node", "--force", "-R", node0])
Пример #8
0
def enable_cluster_all():
    for node in utils.getNodesFromCorosyncConf():
        utils.enableCluster(node)
Пример #9
0
def enable_cluster_all():
    for node in utils.getNodesFromCorosyncConf():
        utils.enableCluster(node)