def test_display_node_list_discovery_data(self): # This test displays a list of the nodes along with # the associated BMC, RMM, and OBM settings for the discovered compute nodes mondata = fit_common.rackhdapi("/api/2.0/nodes") nodes = mondata['json'] result = mondata['status'] if result == 200: # print "result" + str(result) # Display node info print "\nNumber of nodes found: " + str(len(nodes)) + "\n" i = 0 for node in nodes: i += 1 print "" nn = node["id"] print "Node {0}: {1}".format(str(i), nn) # Check type of node and display info nodetype = node['type'] if nodetype != "compute": print "Node Type: ", nodetype if nodetype == "enclosure": print "Node Name: ", node['name'] nodelist = test_api_utils.get_relations_for_node(nn) if nodelist: print "Nodes contained in this enclosure: ", nodelist else: print "No Nodes found in this enclosure" else: # If compute node, display BMC, RMM and IP info nodetype = test_api_utils.get_rackhd_nodetype(nn) print "Compute Node Type: ", nodetype enclosure = test_api_utils.get_relations_for_node(nn) if enclosure: print "In Enclosure: ", enclosure[0] else: print "Not associated with a monorail enclosure" # try to get the BMC info from the catalog monurl = "/api/2.0/nodes/" + nn + "/catalogs/bmc" mondata = fit_common.rackhdapi(monurl, action="get") catalog = mondata['json'] bmcresult = mondata['status'] print "BMC MAC Address", print "\tBMC IP Address", print "\tBMC IP Source", print "\tRMM MAC Address", print "\tRMM IP Address", print "\tRMM IP Source", print "\tOBM Host", print "\t\tOBM User" if bmcresult != 200: print "Error on catalog/bmc command", else: print catalog["data"]["MAC Address"], print "\t" + catalog["data"]["IP Address"], print "\t" + catalog["data"]["IP Address Source"], # Get RMM info from the catalog, if present rmmurl = "/api/2.0/nodes/" + nn + "/catalogs/rmm" rmmdata = fit_common.rackhdapi(rmmurl, action="get") rmmcatalog = rmmdata['json'] rmmresult = rmmdata['status'] if rmmresult != 200: print "\tNo RMM catalog entry.\t\t\t\t\t", else: print "\t" + rmmcatalog["data"].get( "MAC Address", "-"), print "\t" + rmmcatalog["data"].get("IP Address", "-"), print "\t" + rmmcatalog["data"].get( "IP Address Source", "-") + "\t", nodeurl = "/api/2.0/nodes/" + nn nodedata = fit_common.rackhdapi(nodeurl, action="get") nodeinfo = nodedata['json'] result = nodedata['status'] if result != 200: print "Error on node command" + nodeurl + ", http response: " + result else: # Check BMC IP vs OBM IP setting try: obmlist = nodeinfo["obmSettings"] except: print "ERROR: Node has no OBM settings configured" else: try: obmhost = obmlist[0]["config"]["host"] except: print "Invalid or empty OBM setting" else: print obmhost, print "\t" + obmlist[0]["config"].get( "user", "Error: No User defined!") else: print "Cannot get RackHD nodes from stack, http response code: ", result
def test99_display_node_list_discovery_data(self): # This test displays a list of the nodes along with # the associated BMC, RMM, and OBM settings for the discovered compute nodes fit_common.VERBOSITY = 1 # this is needed for suppressing debug messages to make reports readable mondata = fit_common.rackhdapi("/api/2.0/nodes") nodes = mondata['json'] result = mondata['status'] if result == 200: log.info_1(" NODE INVENTORY") log.info_1(" Number of nodes found: %s", str(len(nodes))) i = 0 for node in nodes: i += 1 nn = node["id"] log.info_1(" ************************") log.info_1(" Node %s: %s", str(i), nn) # Check type of node and display info nodetype = node['type'] if nodetype != "compute": log.info_1(" Node Type: %s ", nodetype) if nodetype == "enclosure": log.info_1(" Node Name: %s", node['name']) nodelist = test_api_utils.get_relations_for_node(nn) if nodelist: log.info_1(" Nodes contained in this enclosure: %s", nodelist) else: log.info_1(" No Nodes found in this enclosure") else: # If compute node, display BMC, RMM and IP info nodetype = test_api_utils.get_rackhd_nodetype(nn) log.info_1(" Compute Node Type: %s", nodetype) enclosure = test_api_utils.get_relations_for_node(nn) if enclosure: log.info_1(" In Enclosure: %s ", enclosure[0]) else: log.info_1(" Not associated with a monorail enclosure") # try to get the BMC info from the catalog monurl = "/api/2.0/nodes/" + nn + "/catalogs/bmc" mondata = fit_common.rackhdapi(monurl, action="get") catalog = mondata['json'] bmcresult = mondata['status'] if bmcresult != 200: log.info_1(" Error on catalog/bmc command") else: log.info_1(" BMC Mac: %s", catalog["data"]["MAC Address"]) log.info_1(" BMC IP Addr: %s", catalog["data"]["IP Address"]) log.info_1(" BMC IP Addr Src: %s", catalog["data"]["IP Address Source"]) # Get RMM info from the catalog, if present rmmurl = "/api/2.0/nodes/" + nn + "/catalogs/rmm" rmmdata = fit_common.rackhdapi(rmmurl, action="get") rmmcatalog = rmmdata['json'] rmmresult = rmmdata['status'] if rmmresult != 200: log.info_1(" No RMM catalog entry.") else: log.info_1(" RMM Mac: %s", rmmcatalog["data"].get("MAC Address", " ")) log.info_1(" RMM IP: %s", rmmcatalog["data"].get("IP Address", " ")) log.info_1(" RMM IP Addr source: %s", rmmcatalog["data"].get("IP Address Source", " ")) nodeurl = "/api/2.0/nodes/" + nn nodedata = fit_common.rackhdapi(nodeurl, action="get") nodeinfo = nodedata['json'] result = nodedata['status'] if result != 200: log.info_1(" Error on node commandi %s http response %s", nodeurl, result) else: # Check BMC IP vs OBM IP setting try: obmlist = nodeinfo["obms"] except: log.info_1(" ERROR: Node has no OBM settings configured") else: try: obmurl = obmlist[0]['ref'] obmdata = fit_common.rackhdapi(obmurl, action="get") except: log.info_1(" Invalid or empty OBM settings on Node") else: log.info_1(" obmhost: %s", obmdata['json']["config"].get("host", "Error: No Host in obmdata")) log.info_1(" obmuser: %s", obmdata['json']["config"].get("user", "Error: No User defined!")) else: log.info_1("Cannot get RackHD nodes from stack, http response code: %s", result)
def test_display_node_list_discovery_data(self): # This test displays a list of the nodes along with # the associated BMC, RMM, and OBM settings for the discovered compute nodes mondata = fit_common.rackhdapi("/api/1.1/nodes") nodes = mondata['json'] result = mondata['status'] if result == 200: #print "result" + str(result) # Display node info print "\nNumber of nodes found: "+str(len(nodes))+"\n" i = 0 for node in nodes: i += 1 print "" nn = node["id"] print "Node {0}: {1}".format(str(i), nn) # Check type of node and display info nodetype = node['type'] if nodetype != "compute": print "Node Type: ", nodetype if nodetype == "enclosure": print "Node Name: ", node['name'] nodelist = test_api_utils.get_relations_for_node(nn) if nodelist: print "Nodes contained in this enclosure: ", nodelist else: print "No Nodes found in this enclosure" else: # If compute node, display BMC, RMM and IP info nodetype = test_api_utils.get_rackhd_nodetype(nn) print "Compute Node Type: ", nodetype enclosure = test_api_utils.get_relations_for_node(nn) if enclosure: print "In Enclosure: ", enclosure[0] else: print "Not associated with a monorail enclosure" # try to get the BMC info from the catalog monurl = "/api/1.1/nodes/"+nn+"/catalogs/bmc" mondata = fit_common.rackhdapi(monurl, action="get") catalog = mondata['json'] bmcresult = mondata['status'] print "BMC MAC Address", print "\tBMC IP Address", print "\tBMC IP Source", print "\tRMM MAC Address", print "\tRMM IP Address", print "\tRMM IP Source", print "\tOBM Host", print "\t\tOBM User" if bmcresult != 200: print "Error on catalog/bmc command", else: print catalog["data"]["MAC Address"], print "\t" + catalog["data"]["IP Address"], print "\t" + catalog["data"]["IP Address Source"], # Get RMM info from the catalog, if present rmmurl = "/api/1.1/nodes/"+nn+"/catalogs/rmm" rmmdata = fit_common.rackhdapi(rmmurl, action="get") rmmcatalog = rmmdata['json'] rmmresult = rmmdata['status'] if rmmresult != 200: print "\tNo RMM catalog entry.\t\t\t\t\t", else: print "\t" + rmmcatalog["data"].get("MAC Address", "-"), print "\t" + rmmcatalog["data"].get("IP Address", "-"), print "\t" + rmmcatalog["data"].get("IP Address Source", "-") + "\t", nodeurl = "/api/1.1/nodes/"+nn nodedata = fit_common.rackhdapi(nodeurl, action="get") nodeinfo = nodedata['json'] result = nodedata['status'] if result != 200: print "Error on node command" + nodeurl + ", http response: " + result else: # Check BMC IP vs OBM IP setting try: obmlist = nodeinfo["obmSettings"] except: print "ERROR: Node has no OBM settings configured" else: try: obmhost = obmlist[0]["config"]["host"] except: print "Invalid or empty OBM setting" else: print obmhost, print "\t" + obmlist[0]["config"].get("user","Error: No User defined!") else: print "Cannot get RackHD nodes from stack, http response code: ", result