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)
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)
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])