def checkRedfishURIs(bmcName): dbgPrint(dbgMed, "checkRedfishURIs") hostPath = "https://" + bmcName badResults = 0 for entry in URIData: path = hostPath + entry[URI] dbgPrint(dbgMed, "checkRedfishURIs checking " + path) payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("checkRedfishURIs") printExtraError(label, msg) badResults += 1 continue response = json.loads(payload) idx = 1 while idx < len(entry): e = entry[idx] badResults += validateField("checkRedfishURIs", entry[URI], e[FIELD], response, e[TYPE]) idx += 1 if badResults == 0: printOK("checkRedfishURIs") return badResults
def checkRedfishEventService(bmcName): dbgPrint(dbgMed, "checkRedfishEventService") badResults = 0 path = "https://" + bmcName + "/redfish/v1/EventService" dbgPrint(dbgMed, "checkRedfishEventService checking " + path) payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("checkRedfishEventService") printExtraError(label, msg) return 1 response = json.loads(payload) checkURIs = [] if response["@odata.type"] < "#EventService.v1_3_0.EventService": checkURIs = eventServiceURIs_pre_1_3 else: checkURIs = eventServiceURIs_1_3 for check in checkURIs: badResults += validateField("checkRedfishEventService", "/redfish/v1/EventService", check[FIELD], response, check[TYPE]) if badResults == 0: printOK("checkRedfishEventService") return badResults
def checkRedfishSystemsMemoryDimms(bmcName, dimmURI): fname = "checkRedfishSystemsMemoryDimms" dbgPrint(dbgMed, fname) badResults = 0 path = "https://" + bmcName + dimmURI dbgPrint(dbgMed, fname + " checking " + path) payload, label, msg = makeRedfishCall("GET", path) if payload: mResponse = json.loads(payload) if "Status" in mResponse: if mResponse["Status"]["State"] != "Absent": for check in dimmURIs: badResults += validateField(fname, dimmURI, check[FIELD], mResponse, check[TYPE]) else: printInfo(fname) printExtraInfo(dimmURI, "Not present") else: printError(fname) printExtraError(label, msg) badResults += 1 return badResults
def checkRedfishSystemsProcessors(bmcName, procURI): fname = "checkRedfishSystemsProcessors" dbgPrint(dbgMed, fname) badResults = 0 path = "https://" + bmcName + procURI dbgPrint(dbgMed, fname + " checking " + path) payload, label, msg = makeRedfishCall("GET", path) if payload: mResponse = json.loads(payload) for check in memoryURIs: badResults += validateField(fname, procURI, check[FIELD], mResponse, check[TYPE]) if check[FIELD] == "Members" and check[FIELD] in mResponse: for member in mResponse[check[FIELD]]: badResults += checkRedfishSystemsProcessorsCPU( bmcName, member["@odata.id"]) else: printError(fname) printExtraError(label, msg) badResults += 1 return badResults
def checkRedfishUpdateService(bmcName): fname = "checkRedfishUpdateService" dbgPrint(dbgMed, fname) badResults = 0 path = "https://" + bmcName + "/redfish/v1/UpdateService" dbgPrint(dbgMed, fname + " checking " + path) payload, label, msg = makeRedfishCall("GET", path) if not payload: printError(fname) printExtraError(label, msg) return 1 response = json.loads(payload) # Check Actions structure aField = response["Actions"]["#UpdateService.SimpleUpdate"] for e in actionFields: badResults += validateField(fname, "/redfish/v1/UpdateService", e[FIELD], aField, e[TYPE]) badResults += checkRedfishFirmwareInventory(bmcName, response["FirmwareInventory"]["@odata.id"]) if badResults == 0: printOK(fname) return badResults
def checkRedfishChassis(bmcName): dbgPrint(dbgMed, "checkRedfishChassis") badResults = 0 path = "https://" + bmcName + "/redfish/v1/Chassis" dbgPrint(dbgMed, "checkRedfishChassis checking " + path) payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("checkRedfishChassis") printExtraError(label, msg) return 1 response = json.loads(payload) if "Members" not in response: printError("checkRedfishChassis") printExtraError(path + " .Members", "missing") return 1 for member in response["Members"]: path = "https://" + bmcName + member["@odata.id"] dbgPrint(dbgMed, "checkRedfishChassis checking " + path) payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("checkRedfishChassis") printExtraError(label, msg) badResults += 1 continue mResponse = json.loads(payload) if ("ChassisType" in mResponse and (mResponse["ChassisType"] == "Enclosure" or mResponse["ChassisType"] == "RackMount")): for check in chassisURIs: badResults += validateField("checkRedfishChassis", member["@odata.id"], check[FIELD], mResponse, check[TYPE]) else: printInfo("checkRedfishChassis") printExtraInfo("Skipping " + member["@odata.id"], "URI is for a " + mResponse["ChassisType"]) if badResults == 0: printOK("checkRedfishChassis") return badResults
def checkRedfishSystems(bmcName): fname = "checkRedfishSystems" dbgPrint(dbgMed, fname) badResults = 0 path = "https://" + bmcName + "/redfish/v1/Systems" dbgPrint(dbgMed, fname + " checking " + path) payload, label, msg = makeRedfishCall("GET", path) if not payload: printError(fname) printExtraError(label, msg) return 1 response = json.loads(payload) if "Members" not in response: printError(fname) printExtraError(path + " .Members", "missing") return 1 for member in response["Members"]: path = "https://" + bmcName + member["@odata.id"] dbgPrint(dbgMed, fname + " checking " + path) payload, label, msg = makeRedfishCall("GET", path) if not payload: printError(fname) printExtraError(label, msg) badResults += 1 continue mResponse = json.loads(payload) for check in systemsURIs: badResults += validateField(fname, member["@odata.id"], check[FIELD], mResponse, check[TYPE]) if check[FIELD] == "Memory" and check[FIELD] in mResponse: badResults += checkRedfishSystemsMemory( bmcName, mResponse[check[FIELD]]["@odata.id"]) if check[FIELD] == "Processors" and check[FIELD] in mResponse: badResults += checkRedfishSystemsProcessors( bmcName, mResponse[check[FIELD]]["@odata.id"]) if badResults == 0: printOK(fname) return badResults
def checkRedfishManagers(bmcName): dbgPrint(dbgMed, "checkRedfishManagers") badResults = 0 path = "https://" + bmcName + "/redfish/v1/Managers" dbgPrint(dbgMed, "checkRedfishManagers checking " + path) payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("checkRedfishManagers") printExtraError(label, msg) return 1 response = json.loads(payload) if "Members" not in response: printError("checkRedfishManagers") printExtraError(path + " .Members", "missing") return 1 for member in response["Members"]: path = "https://" + bmcName + member["@odata.id"] dbgPrint(dbgMed, "checkRedfishManagers checking " + path) payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("checkRedfishManagers") printExtraError(label, msg) badResults += 1 continue mResponse = json.loads(payload) for check in managerURIs: badResults += validateField("checkRedfishManagers", member["@odata.id"], check[FIELD], mResponse, check[TYPE]) if badResults == 0: printOK("checkRedfishManagers") return badResults
def checkRedfishSystemsProcessorsCPU(bmcName, cpuURI): fname = "checkRedfishSystemsProcessorsCPU" dbgPrint(dbgMed, fname) badResults = 0 path = "https://" + bmcName + cpuURI dbgPrint(dbgMed, fname + " checking " + path) payload, label, msg = makeRedfishCall("GET", path) if payload: mResponse = json.loads(payload) for check in cpuURIs: badResults += validateField(fname, cpuURI, check[FIELD], mResponse, check[TYPE]) else: printError(fname) printExtraError(label, msg) badResults += 1 return badResults
def checkRedfishFirmwareInventoryComp(bmcName, fwURI): fname = "checkRedfishFirmwareInventoryComp" dbgPrint(dbgMed, fname) badResults = 0 path = "https://" + bmcName + fwURI dbgPrint(dbgMed, fname + " checking " + path) payload, label, msg = makeRedfishCall("GET", path) if payload: mResponse = json.loads(payload) for check in fwInvFields: badResults += validateField(fname, fwURI, check[FIELD], mResponse, check[TYPE]) else: printError(fname) printExtraError(label, msg) badResults += 1 return badResults
def checkRedfishFirmwareInventory(bmcName, fwURI): fname = "checkRedfishFirmwareInventory" dbgPrint(dbgMed, fname) badResults = 0 path = "https://" + bmcName + fwURI dbgPrint(dbgMed, fname + " checking " + path) payload, label, msg = makeRedfishCall("GET", path) if payload: response = json.loads(payload) badResults += validateField(fname, fwURI, "Members", response, list) if "Members" in response: for member in response["Members"]: badResults += checkRedfishFirmwareInventoryComp(bmcName, member["@odata.id"]) else: printError(fname) printExtraError(label, msg) badResults += 1 return badResults