Add parsers for the Redfish resources in redfish-map.md

Pure functions for ServiceRoot, ComputerSystem (facts, power state, reset action and ActionInfo), Processors, Memory, Storage/Drives/SimpleStorage, Chassis Thermal and Power as well as ThermalSubsystem/PowerSubsystem/Sensors (with environment_sources to pick whichever exists), Manager, EthernetInterfaces, ManagerNetworkProtocol, accounts, firmware inventory and log services/entries.
This commit is contained in:
Christian Manivong committed 2026-10-12 23:42:14 +00:00
1 parent 8998e1342e
commit cab1c84cba
18 files changed
+1926

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
"""LogServices and their entries (the SEL lives under Systems or Managers, by vendor)."""
from __future__ import annotations
from typing import Any, Mapping
from .common import boolean, integer, link, status, text
def parse_log_service(service: Mapping[str, Any]) -> dict[str, Any]:
"""One member of ``.../LogServices``."""
state, health = status(service)
return {
"id": text(service.get("Id")),
"name": text(service.get("Name")),
"enabled": boolean(service.get("ServiceEnabled")),
"entries_path": link(service, "Entries"),
"max_records": integer(service.get("MaxNumberOfRecords")),
"overwrite_policy": text(service.get("OverWritePolicy")),
"entry_type": text(service.get("LogEntryType")),
"state": state,
"health": health,
}
def parse_log_entry(entry: Mapping[str, Any]) -> dict[str, Any]:
"""One LogEntry (SEL record or Redfish event)."""
args = entry.get("MessageArgs")
return {
"id": text(entry.get("Id")),
"created": text(entry.get("Created")),
"severity": text(entry.get("Severity")),
"message": text(entry.get("Message")),
"message_id": text(entry.get("MessageId")),
"message_args": [str(a) for a in args] if isinstance(args, list) else [],
"entry_type": text(entry.get("EntryType")),
"entry_code": text(entry.get("EntryCode")),
"sensor_type": text(entry.get("SensorType")),
"sensor_number": integer(entry.get("SensorNumber")),
"origin": link(entry, "Links", "OriginOfCondition"),
}