Esempio n. 1
0
def sync_start(partial_argv):
    argv = partial_argv[:]
    nodes = partial_argv[1:]
    config = corosync_setup(argv, True)
    for node in nodes:
        utils.setCorosyncConfig(node, config)
        utils.startCluster(node)
Esempio n. 2
0
def sync_start(partial_argv):
    argv = partial_argv[:]
    nodes = partial_argv[1:]
    config = corosync_setup(argv,True)
    for node in nodes:
        utils.setCorosyncConfig(node,config)
        utils.startCluster(node)
Esempio n. 3
0
def start_cluster(argv):
    if len(argv) > 0:
        for node in argv:
            utils.startCluster(node)
            return

    print "Starting Cluster..."
    if utils.is_rhel6():
        #   Verify that CMAN_QUORUM_TIMEOUT is set, if not, then we set it to 0
        retval, output = commands.getstatusoutput(
            'source /etc/sysconfig/cman ; [ -z "$CMAN_QUORUM_TIMEOUT" ]')
        if retval == 0:
            with open("/etc/sysconfig/cman", "a") as cman_conf_file:
                cman_conf_file.write("\nCMAN_QUORUM_TIMEOUT=0\n")

        output, retval = utils.run(["service", "cman", "start"])
        if retval != 0:
            print output
            utils.err("unable to start cman")
    else:
        output, retval = utils.run(["service", "corosync", "start"])
        if retval != 0:
            print output
            utils.err("unable to start corosync")
    output, retval = utils.run(["service", "pacemaker", "start"])
    if retval != 0:
        print output
        utils.err("unable to start pacemaker")
Esempio n. 4
0
def cluster_node(argv):
    if len(argv) != 2:
        usage.cluster()
        sys.exit(1)

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

    node = argv[1]
    status, output = utils.checkStatus(node)
    if status == 2:
        print "Error: pcsd is not running on %s" % node
        sys.exit(1)
    elif status == 3:
        print "Error: %s is not yet authenticated (try pcs cluster auth %s)" % (
            node, node)
        sys.exit(1)

    if add_node == True:
        corosync_conf = None
        for my_node in utils.getNodesFromCorosyncConf():
            retval, output = utils.addLocalNode(my_node, node)
            if retval != 0:
                print "Error: unable to add %s on %s - %s" % (node, my_node,
                                                              output.strip())
            else:
                print "%s: Corosync updated" % my_node
                corosync_conf = output
        if corosync_conf != None:
            utils.setCorosyncConfig(node, corosync_conf)
            utils.startCluster(node)
        else:
            print "Error: Unable to update any nodes"
            sys.exit(1)
    else:
        nodesRemoved = False
        output, retval = utils.run(["crm_node", "--force", "-R", node])

        for my_node in utils.getNodesFromCorosyncConf():
            retval, output = utils.removeLocalNode(my_node, node)
            if retval != 0:
                print "Error: unable to remove %s on %s - %s" % (
                    node, my_node, output.strip())
            else:
                if output[0] == 0:
                    print "%s: Corosync updated" % my_node
                    nodesRemoved = True
                else:
                    print "%s: Error executing command occured: %s" % (
                        my_node, "".join(output[1]))
        if nodesRemoved == False:
            print "Error: Unable to update any nodes"
            sys.exit(1)
Esempio n. 5
0
def sync_start(partial_argv, nodes):
    argv = partial_argv[:]
    config = corosync_setup(argv,True)
    for node in nodes:
        utils.setCorosyncConfig(node,config)
    print "Starting cluster on nodes: " + ", ".join(nodes) + "..."

    for node in nodes:
        utils.startCluster(node)
Esempio n. 6
0
def cluster_node(argv):
    if len(argv) != 2:
        usage.cluster();
        sys.exit(1)

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

    node = argv[1]
    status,output = utils.checkStatus(node)
    if status == 2:
        print "Error: pcsd is not running on %s" % node
        sys.exit(1)
    elif status == 3:
        print "Error: %s is not yet authenticated (try pcs cluster auth %s)" % (node, node)
        sys.exit(1)

    if add_node == True:
        corosync_conf = None
        for my_node in utils.getNodesFromCorosyncConf():
            retval, output = utils.addLocalNode(my_node,node)
            if retval != 0:
                print "Error: unable to add %s on %s - %s" % (node,my_node,output.strip())
            else:
                print "%s: Corosync updated" % my_node
                corosync_conf = output
        if corosync_conf != None:
            utils.setCorosyncConfig(node, corosync_conf)
            utils.startCluster(node)
        else:
            print "Error: Unable to update any nodes"
            sys.exit(1)
    else:
        nodesRemoved = False
        output, retval = utils.run(["crm_node", "--force","-R", node])

        for my_node in utils.getNodesFromCorosyncConf():
            retval, output = utils.removeLocalNode(my_node,node)
            if retval != 0:
                print "Error: unable to remove %s on %s - %s" % (node,my_node,output.strip())
            else:
                if output[0] == 0:
                    print "%s: Corosync updated" % my_node
                    nodesRemoved = True
                else:
                    print "%s: Error executing command occured: %s" % (my_node, "".join(output[1]))
        if nodesRemoved == False:
            print "Error: Unable to update any nodes"
            sys.exit(1)
Esempio n. 7
0
def start_cluster(argv):
    if len(argv) > 0:
        failure = False
        errors = ""
        for node in argv:
            (retval, err) =  utils.startCluster(node)
            if retval != 0:
                failure = True
                errors = errors + err+"\n"
        if failure:
            utils.err("unable to start all nodes\n" + errors.rstrip())
        return

    print "Starting Cluster..."
    if utils.is_rhel6():
#   Verify that CMAN_QUORUM_TIMEOUT is set, if not, then we set it to 0
        retval, output = commands.getstatusoutput('source /etc/sysconfig/cman ; [ -z "$CMAN_QUORUM_TIMEOUT" ]')
        if retval == 0:
            with open("/etc/sysconfig/cman", "a") as cman_conf_file:
                cman_conf_file.write("\nCMAN_QUORUM_TIMEOUT=0\n")

        output, retval = utils.run(["service", "cman","start"])
        if retval != 0:
            print output
            utils.err("unable to start cman")
    else:
        output, retval = utils.run(["service", "corosync","start"])
        if retval != 0:
            print output
            utils.err("unable to start corosync")
    output, retval = utils.run(["service", "pacemaker", "start"])
    if retval != 0:
        print output
        utils.err("unable to start pacemaker")
Esempio n. 8
0
def start_cluster(argv):
    if len(argv) > 0:
        for node in argv:
            utils.startCluster(node)
            return

    print "Starting Cluster...",
    output, retval = utils.run(["systemctl", "start","corosync.service"])
    print output,
    if retval != 0:
        print "Error: unable to start corosync"
        sys.exit(1)
    output, retval = utils.run(["systemctl", "start", "pacemaker.service"])
    print output,
    if retval != 0:
        print "Error: unable to start pacemaker"
        sys.exit(1)
Esempio n. 9
0
def start_cluster(argv):
    if len(argv) > 0:
        for node in argv:
            utils.startCluster(node)
            return

    print "Starting Cluster...",
    output, retval = utils.run(["systemctl", "start", "corosync.service"])
    print output,
    if retval != 0:
        print "Error: unable to start corosync"
        sys.exit(1)
    output, retval = utils.run(["systemctl", "start", "pacemaker.service"])
    print output,
    if retval != 0:
        print "Error: unable to start pacemaker"
        sys.exit(1)
Esempio n. 10
0
def start_cluster(argv):
    if len(argv) > 0:
        for node in argv:
            utils.startCluster(node)
            return

    print "Starting Cluster..."
    if utils.is_rhel6():
        output, retval = utils.run(["service", "cman","start"])
        if retval != 0:
            print output
            utils.err("unable to start cman")
    else:
        output, retval = utils.run(["service", "corosync","start"])
        if retval != 0:
            print output
            utils.err("unable to start corosync")
    output, retval = utils.run(["service", "pacemaker", "start"])
    if retval != 0:
        print output
        utils.err("unable to start pacemaker")
Esempio n. 11
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])
Esempio n. 12
0
def start_cluster_all():
    for node in utils.getNodesFromCorosyncConf():
        utils.startCluster(node)
Esempio n. 13
0
 def run(self):
     utils.startCluster(self.node)
Esempio n. 14
0
 def run(self):
     utils.startCluster(self.node)
Esempio n. 15
0
def start_cluster_all():
    for node in utils.getNodesFromCorosyncConf():
        utils.startCluster(node)