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.
30 lines
998 B
Python
30 lines
998 B
Python
"""ServiceRoot: ``GET /redfish/v1/`` (readable without credentials)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Mapping
|
|
|
|
from .common import link, links, text
|
|
|
|
|
|
def parse_service_root(root: Mapping[str, Any]) -> dict[str, Any]:
|
|
"""Version, identity and top-level links of a Redfish service.
|
|
|
|
``vendor`` and ``product`` exist from ServiceRoot 1.5 on; ``oem_vendors`` (the keys under
|
|
``Oem``) is what older services offer for picking a quirk module.
|
|
"""
|
|
found = links(root)
|
|
sessions = link(root, "Links", "Sessions")
|
|
if sessions is not None:
|
|
found["Sessions"] = sessions
|
|
oem = root.get("Oem")
|
|
return {
|
|
"name": text(root.get("Name")),
|
|
"redfish_version": text(root.get("RedfishVersion")),
|
|
"uuid": text(root.get("UUID")),
|
|
"vendor": text(root.get("Vendor")),
|
|
"product": text(root.get("Product")),
|
|
"oem_vendors": sorted(oem) if isinstance(oem, Mapping) else [],
|
|
"links": found,
|
|
}
|