def eventDelete(bmcName): dbgPrint(dbgMed, "eventDelete") ipAddr = getIPAddress() if not ipAddr: printError("eventDelete") printExtraError("vlan004", "could not determine IP addr") return 1 path = "https://%s/redfish/v1/EventService/Subscriptions" % bmcName payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("eventDelete") printExtraError(label, msg) return 1 subCollection = json.loads(payload) count = 0 for subEntry in subCollection['Members']: path = "https://%s%s" % (bmcName, subEntry['@odata.id']) payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("eventDelete") printExtraError(label, msg) return 1 sub = json.loads(payload) if (sub['Context'] == "RFSubTest-%s-RFSubTest" % bmcName and sub['Destination'] == "https://%s/receiver" % ipAddr): count += 1 payload, label, msg = makeRedfishCall("DELETE", path) if not payload: printError("eventDelete") printExtraError(label, msg) return 1 dbgPrint(dbgMed, "%d subscriptions deleted for %s" % (count, bmcName)) printOK("eventDelete") return 0
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 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 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 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 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 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 eventSubscribe(bmcName): dbgPrint(dbgMed, "eventSubscribe") ipAddr = getIPAddress() if not ipAddr: printError("eventSubscribe") printExtraError("vlan004", "could not determine IP addr") return 1 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) sub = { 'Context': "RFSubTest-%s-RFSubTest" % bmcName, 'Destination': "https://%s/receiver" % ipAddr, 'Protocol': 'Redfish', } if response["@odata.type"] < "#EventService.v1_3_0.EventService": eventTypes = ["StatusChange"] sub['EventTypes'] = eventTypes path = "https://%s/redfish/v1/EventService/Subscriptions" % bmcName payload, label, msg = makeRedfishCall("POST", path, json.dumps(sub)) if not payload: printError("eventSubscribe") printExtraError(label, msg) return 1 printOK("eventSubscribe") return 0
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
def eventTest(bmcName): dbgPrint(dbgMed, "eventTest") global event hostPath = "https://" + bmcName path = hostPath + "/redfish/v1/Chassis" payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("telemetryPoll") printExtraError(label, msg) return 1 chassisList = json.loads(payload) chassis = chassisList['Members'][0] testEvent = {} path = hostPath + "/redfish/v1/EventService/Actions/EventService.SubmitTestEvent" if isGigabyte(chassis['@odata.id']): evID = randrange(10000, 99999) testEvent = { "EventTimestamp": "2020-05-26T23:04:09+02:00", "EventId": evID, "OriginOfCondition": "/redfish/v1/Chassis/Self", "MessageId": "PropertyValueNotInList", "MessageArgs": ["Lit", "IndicatorLED"], "Severity": "Warning" } elif isHPERiver(chassis['@odata.id']): testEvent = { 'EventID': 'Test Event', 'Severity': 'OK', 'EventType': 'StatusChange', 'OriginOfCondition': 'Test', 'EventTimestamp': str(datetime.datetime.now()), 'MessageArgs': [], 'Message': 'This is a test event', 'MessageId': 'TestMsg.v0' } elif isHPEMountain(chassis['@odata.id']): printInfo("eventValidate") printExtraInfo("Test Event", "Not supported") return 1 if httpd is None: startRedfishEventServer() payload, label, msg = makeRedfishCall("POST", path, json.dumps(testEvent)) if not payload: printError("eventValidate") printExtraError(label, msg) return 1 if event.wait(timeout=30): printOK("eventValidate") return 0 else: printError("eventValidate") printExtraError("event", "timed out waiting for Redfish test event") return 1
def telemetryPoll(bmcName): dbgPrint(dbgMed, "telemetryPoll") hostPath = "https://" + bmcName path = hostPath + "/redfish/v1/Chassis" payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("telemetryPoll") printExtraError(label, msg) return 1 chassisList = json.loads(payload) badResults = 0 for chassis in chassisList['Members']: chassisPath = hostPath + chassis['@odata.id'] path = chassisPath + "/Power" payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("telemetryPoll power") printExtraError(label, msg) return 1 Power = json.loads(payload) path = chassisPath + "/Thermal" payload, label, msg = makeRedfishCall("GET", path) if not payload: printError("telemetryPoll thermal") printExtraError(label, msg) return 1 Thermal = json.loads(payload) # Gigabyte # /Power # .PowerControl.PowerMetrics.AverageConsumedWatts # .Voltages[].ReadingVolts # /Thermal # .Fans[].Reading # .Temperatures[].ReadingCelsius if isGigabyte(chassis['@odata.id']): ret = checkAvgConsumedWatts(Power) if ret != 0: printError("telemetryPoll power") printExtraError(bmcName, "AverageConsumedWatts missing") badResults += 1 ret = checkVoltages(Power) if ret != 0: printError("telemetryPoll power") printExtraError(bmcName, "Voltages missing") badResults += 1 ret = checkFans(Thermal) if ret != 0: printError("telemetryPoll thermal") printExtraError(bmcName, "Fans missing") badResults += 1 ret = checkTemps(Thermal) if ret != 0: printError("telemetryPoll thermal") printExtraError(bmcName, "Temperatures missing") badResults += 1 # HPE - Mountain (we don't poll, but check what we can) # /Power # .Voltages[].ReadingVolts # /Thermal # .Temperatures[].ReadingCelsius if isHPEMountain(chassis['@odata.id']): ret = checkVoltages(Power) if ret != 0: printError("telemetryPoll power") printExtraError(bmcName, "Voltages missing") badResults += 1 ret = checkTemps(Thermal) if ret != 0: printError("telemetryPoll thermal") printExtraError(bmcName, "Temperatures missing") badResults += 1 # HPE - River # /Power # .PowerControl.PowerMetrics.AverageConsumedWatts # .PowerSupplies[].LineInputVoltage # /Thermal # .Fans[].Reading # .Temperatures[].ReadingCelsius if isHPERiver(chassis['@odata.id']): ret = checkAvgConsumedWatts(Power) if ret != 0: printError("telemetryPoll power") printExtraError(bmcName, "AverageConsumedWatts missing") badResults += 1 ret = checkLineVoltages(Power) if ret != 0: printError("telemetryPoll power") printExtraError(bmcName, "Voltages missing") badResults += 1 ret = checkFans(Thermal) if ret != 0: printError("telemetryPoll thermal") printExtraError(bmcName, "Fans missing") badResults += 1 ret = checkTemps(Thermal) if ret != 0: printError("telemetryPoll thermal") printExtraError(bmcName, "Temperatures missing") badResults += 1 if badResults == 0: printOK("telemetryPoll") return badResults