def resources_status(argv): info_dom = utils.getClusterState() print "Resources:" resources = info_dom.getElementsByTagName("resources") if resources.length == 0: utils.err("no resources section found") for resource in resources[0].getElementsByTagName("resource"): nodes = resource.getElementsByTagName("node") node_line = "" if nodes.length > 0: for node in nodes: node_line += node.getAttribute("name") + " " print "", resource.getAttribute("id"), print "(" + resource.getAttribute("resource_agent") + ")", print "- " + resource.getAttribute("role") + " " + node_line
def resources_status(argv): info_dom = utils.getClusterState() print("Resources:") resources = info_dom.getElementsByTagName("resources") if resources.length == 0: utils.err("no resources section found") for resource in resources[0].getElementsByTagName("resource"): nodes = resource.getElementsByTagName("node") node_line = "" if nodes.length > 0: for node in nodes: node_line += node.getAttribute("name") + " " print("", resource.getAttribute("id"), end=' ') print("(" + resource.getAttribute("resource_agent") + ")", end=' ') print("- " + resource.getAttribute("role") + " " + node_line)
def resources_status(argv): info_dom = utils.getClusterState() print "Resources:" groups = {} nongroup_resources = [] resources = info_dom.getElementsByTagName("resources") if resources.length == 0: print "Error: No resources section found" sys.exit(1) for resource in resources[0].getElementsByTagName("resource"): nodes = resource.getElementsByTagName("node") node_line = "" if nodes.length > 0: for node in nodes: node_line += node.getAttribute("name") + " " print "", resource.getAttribute("id"), print "(" + resource.getAttribute("resource_agent") + ")", print "- " + resource.getAttribute("role") + " " + node_line
def nodes_status(argv): if len(argv) == 1 and argv[0] == "pacemaker-id": for node_id, node_name in utils.getPacemakerNodesID().items(): print("{0} {1}".format(node_id, node_name)) return if len(argv) == 1 and argv[0] == "corosync-id": for node_id, node_name in utils.getCorosyncNodesID().items(): print("{0} {1}".format(node_id, node_name)) return if len(argv) == 1 and (argv[0] == "config"): corosync_nodes = utils.getNodesFromCorosyncConf() pacemaker_nodes = utils.getNodesFromPacemaker() print("Corosync Nodes:") print("", end=' ') for node in corosync_nodes: print(node.strip(), end=' ') print("") print("Pacemaker Nodes:") print("", end=' ') for node in pacemaker_nodes: print(node.strip(), end=' ') return if len(argv) == 1 and (argv[0] == "corosync" or argv[0] == "both"): all_nodes = utils.getNodesFromCorosyncConf() online_nodes = utils.getCorosyncActiveNodes() offline_nodes = [] for node in all_nodes: if node in online_nodes: next else: offline_nodes.append(node) online_nodes.sort() offline_nodes.sort() print("Corosync Nodes:") print(" Online:", end=' ') for node in online_nodes: print(node, end=' ') print("") print(" Offline:", end=' ') for node in offline_nodes: print(node, end=' ') print("") if argv[0] != "both": sys.exit(0) info_dom = utils.getClusterState() nodes = info_dom.getElementsByTagName("nodes") if nodes.length == 0: utils.err("No nodes section found") onlinenodes = [] offlinenodes = [] standbynodes = [] for node in nodes[0].getElementsByTagName("node"): if node.getAttribute("online") == "true": if node.getAttribute("standby") == "true": standbynodes.append(node.getAttribute("name")) else: onlinenodes.append(node.getAttribute("name")) else: offlinenodes.append(node.getAttribute("name")) print("Pacemaker Nodes:") print(" Online:", end=' ') for node in onlinenodes: print(node, end=' ') print("") print(" Standby:", end=' ') for node in standbynodes: print(node, end=' ') print("") print(" Offline:", end=' ') for node in offlinenodes: print(node, end=' ') print("")
def nodes_status(argv): if len(argv) == 1 and (argv[0] == "config"): corosync_nodes = utils.getNodesFromCorosyncConf() pacemaker_nodes = utils.getNodesFromPacemaker() print "Corosync Nodes:" print "", for node in corosync_nodes: print node.strip(), print "" print "Pacemaker Nodes:" print "", for node in pacemaker_nodes: print node.strip(), return if len(argv) == 1 and (argv[0] == "corosync" or argv[0] == "both"): all_nodes = utils.getNodesFromCorosyncConf() online_nodes = utils.getCorosyncActiveNodes() offline_nodes = [] for node in all_nodes: if node in online_nodes: next else: offline_nodes.append(node) online_nodes.sort() offline_nodes.sort() print "Corosync Nodes:" print " Online:", for node in online_nodes: print node, print "" print " Offline:", for node in offline_nodes: print node, print "" if argv[0] != "both": sys.exit(0) info_dom = utils.getClusterState() nodes = info_dom.getElementsByTagName("nodes") if nodes.length == 0: utils.err("No nodes section found") onlinenodes = [] offlinenodes = [] standbynodes = [] for node in nodes[0].getElementsByTagName("node"): if node.getAttribute("online") == "true": if node.getAttribute("standby") == "true": standbynodes.append(node.getAttribute("name")) else: onlinenodes.append(node.getAttribute("name")) else: offlinenodes.append(node.getAttribute("name")) print "Pacemaker Nodes:" print " Online:", for node in onlinenodes: print node, print "" print " Standby:", for node in standbynodes: print node, print "" print " Offline:", for node in offlinenodes: print node, print ""
def nodes_status(argv): if len(argv) == 1 and (argv[0] == "config"): corosync_nodes = utils.getNodesFromCorosyncConf() pacemaker_nodes = utils.getNodesFromPacemaker() print "Corosync Nodes:" print "", for node in corosync_nodes: print node.strip(), print "" print "Pacemaker Nodes:" print "", for node in pacemaker_nodes: print node.strip(), return if len(argv) == 1 and (argv[0] == "corosync" or argv[0] == "both"): all_nodes = utils.getNodesFromCorosyncConf() online_nodes = utils.getCorosyncActiveNodes() offline_nodes = [] for node in all_nodes: if node in online_nodes: next else: offline_nodes.append(node) online_nodes.sort() offline_nodes.sort() print "Corosync Nodes:" print " Online:", for node in online_nodes: print node, print "" print " Offline:", for node in offline_nodes: print node, print "" if argv[0] != "both": sys.exit(0) info_dom = utils.getClusterState() nodes = info_dom.getElementsByTagName("nodes") if nodes.length == 0: print "Error: No nodes section found" sys.exit(1) onlinenodes = [] offlinenodes = [] standbynodes = [] for node in nodes[0].getElementsByTagName("node"): if node.getAttribute("online") == "true": if node.getAttribute("standby") == "true": standbynodes.append(node.getAttribute("name")) else: onlinenodes.append(node.getAttribute("name")) else: offlinenodes.append(node.getAttribute("name")) print "Pacemaker Nodes:" print " Online:", for node in onlinenodes: print node, print "" print " Standby:", for node in standbynodes: print node, print "" print " Offline:", for node in offlinenodes: print node, print ""
def nodes_status(argv): if len(argv) == 1 and argv[0] == "pacemaker-id": for node_id, node_name in utils.getPacemakerNodesID().items(): print("{0} {1}".format(node_id, node_name)) return if len(argv) == 1 and argv[0] == "corosync-id": for node_id, node_name in utils.getCorosyncNodesID().items(): print("{0} {1}".format(node_id, node_name)) return if len(argv) == 1 and (argv[0] == "config"): corosync_nodes = utils.getNodesFromCorosyncConf() pacemaker_nodes = utils.getNodesFromPacemaker() print("Corosync Nodes:") if corosync_nodes: print(" " + " ".join(corosync_nodes)) print("Pacemaker Nodes:") if pacemaker_nodes: print(" " + " ".join(pacemaker_nodes)) return if len(argv) == 1 and (argv[0] == "corosync" or argv[0] == "both"): all_nodes = utils.getNodesFromCorosyncConf() online_nodes = utils.getCorosyncActiveNodes() offline_nodes = [] for node in all_nodes: if node in online_nodes: next else: offline_nodes.append(node) online_nodes.sort() offline_nodes.sort() print("Corosync Nodes:") print(" ".join([" Online:"] + online_nodes)) print(" ".join([" Offline:"] + offline_nodes)) if argv[0] != "both": sys.exit(0) info_dom = utils.getClusterState() nodes = info_dom.getElementsByTagName("nodes") if nodes.length == 0: utils.err("No nodes section found") onlinenodes = [] offlinenodes = [] standbynodes = [] maintenancenodes = [] remote_onlinenodes = [] remote_offlinenodes = [] remote_standbynodes = [] remote_maintenancenodes = [] for node in nodes[0].getElementsByTagName("node"): node_name = node.getAttribute("name") node_remote = node.getAttribute("type") == "remote" if node.getAttribute("online") == "true": if node.getAttribute("standby") == "true": if node_remote: remote_standbynodes.append(node_name) else: standbynodes.append(node_name) elif node.getAttribute("maintenance") == "true": if node_remote: remote_maintenancenodes.append(node_name) else: maintenancenodes.append(node_name) else: if node_remote: remote_onlinenodes.append(node_name) else: onlinenodes.append(node_name) else: if node_remote: remote_offlinenodes.append(node_name) else: offlinenodes.append(node_name) print("Pacemaker Nodes:") print(" ".join([" Online:"] + onlinenodes)) print(" ".join([" Standby:"] + standbynodes)) print(" ".join([" Maintenance:"] + maintenancenodes)) print(" ".join([" Offline:"] + offlinenodes)) print("Pacemaker Remote Nodes:") print(" ".join([" Online:"] + remote_onlinenodes)) print(" ".join([" Standby:"] + remote_standbynodes)) print(" ".join([" Maintenance:"] + remote_maintenancenodes)) print(" ".join([" Offline:"] + remote_offlinenodes))
def nodes_status(argv): #print("rrr 02011 nodes_status") with open("/python.out", "a") as myfile: myfile.write("rrr 02011 nodes_status") if len(argv) == 1 and argv[0] == "pacemaker-id": for node_id, node_name in utils.getPacemakerNodesID().items(): print "{0} {1}".format(node_id, node_name) return if len(argv) == 1 and argv[0] == "corosync-id": for node_id, node_name in utils.getCorosyncNodesID().items(): print "{0} {1}".format(node_id, node_name) return if len(argv) == 1 and (argv[0] == "config"): corosync_nodes = utils.getNodesFromCorosyncConf() pacemaker_nodes = utils.getNodesFromPacemaker() print "Corosync Nodes:" print "", for node in corosync_nodes: print node.strip(), print "" print "Pacemaker Nodes:" print "", for node in pacemaker_nodes: print node.strip(), return if len(argv) == 1 and (argv[0] == "corosync" or argv[0] == "both"): all_nodes = utils.getNodesFromCorosyncConf() online_nodes = utils.getCorosyncActiveNodes() offline_nodes = [] for node in all_nodes: if node in online_nodes: next else: offline_nodes.append(node) online_nodes.sort() offline_nodes.sort() print "Corosync Nodes:" print " Online:", for node in online_nodes: print node, print "" print " Offline:", for node in offline_nodes: print node, print "" if argv[0] != "both": sys.exit(0) info_dom = utils.getClusterState() nodes = info_dom.getElementsByTagName("nodes") if nodes.length == 0: utils.err("No nodes section found") onlinenodes = [] offlinenodes = [] standbynodes = [] for node in nodes[0].getElementsByTagName("node"): if node.getAttribute("online") == "true": if node.getAttribute("standby") == "true": standbynodes.append(node.getAttribute("name")) else: onlinenodes.append(node.getAttribute("name")) else: offlinenodes.append(node.getAttribute("name")) print "Pacemaker Nodes:" print " Online:", for node in onlinenodes: print node, print "" print " Standby:", for node in standbynodes: print node, print "" print " Offline:", for node in offlinenodes: print node, print ""