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.
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
"""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"),
|
|
}
|