Files
Christian Manivong 09029ca0a4 style: ruff format and the lint rules of the driver standard
Mechanical: ruff format, and ruff check --fix with the rule set every NAPALM
driver uses (E, F, I, UP, B at line length 100, Python 3.10). Mapping and
Iterable come from collections.abc, imports are sorted. What ruff cannot
fix comes in the next commit.
2026-10-23 08:39:45 +02:00

31 lines
1.0 KiB
Python

"""ServiceRoot: ``GET /redfish/v1/`` (readable without credentials)."""
from __future__ import annotations
from collections.abc import Mapping
from typing import Any
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,
}