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.
65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
from napalm_redfish.parsers import parse_log_entry, parse_log_service
|
|
|
|
SYSTEM_LOG = "/redfish/v1/Systems/437XR1138R2/LogServices/Log1"
|
|
MANAGER_LOG = "/redfish/v1/Managers/BMC/LogServices/Log"
|
|
|
|
|
|
def test_log_service(rackmount):
|
|
ls = parse_log_service(rackmount(MANAGER_LOG))
|
|
assert ls == {
|
|
"id": "Log",
|
|
"name": "System Log Service",
|
|
"enabled": True,
|
|
"entries_path": MANAGER_LOG + "/Entries",
|
|
"max_records": 1000,
|
|
"overwrite_policy": "WrapsWhenFull",
|
|
"entry_type": None,
|
|
"state": "Enabled",
|
|
"health": "OK",
|
|
}
|
|
|
|
|
|
def test_log_service_sel():
|
|
entries = {"@odata.id": "/redfish/v1/Systems/1/LogServices/SEL/Entries"}
|
|
ls = parse_log_service({"Id": "SEL", "LogEntryType": "SEL", "Entries": entries})
|
|
assert ls["entry_type"] == "SEL"
|
|
assert ls["entries_path"] == "/redfish/v1/Systems/1/LogServices/SEL/Entries"
|
|
assert ls["enabled"] is None
|
|
|
|
|
|
def test_sel_entry(rackmount):
|
|
(first, second) = rackmount(SYSTEM_LOG + "/Entries")["Members"]
|
|
entry = parse_log_entry(first)
|
|
assert entry == {
|
|
"id": "1",
|
|
"created": "2012-03-07T14:44:00Z",
|
|
"severity": "Critical",
|
|
"message": "Temperature threshold exceeded",
|
|
"message_id": "0x592A28",
|
|
"message_args": [],
|
|
"entry_type": "SEL",
|
|
"entry_code": "Upper Critical - going high",
|
|
"sensor_type": "Temperature",
|
|
"sensor_number": 1,
|
|
"origin": "/redfish/v1/Chassis/1U/Thermal",
|
|
}
|
|
assert parse_log_entry(second)["sensor_number"] == 2
|
|
|
|
|
|
def test_event_entry(rackmount):
|
|
(entry,) = rackmount(MANAGER_LOG + "/Entries")["Members"]
|
|
parsed = parse_log_entry(entry)
|
|
assert parsed["entry_type"] == "Event"
|
|
assert parsed["message"] == "System May be Melting"
|
|
assert parsed["message_id"] == "Event.1.0.TempWayTooHot"
|
|
assert parsed["message_args"] == ["88"]
|
|
assert parsed["entry_code"] is None
|
|
|
|
|
|
def test_entry_minimal():
|
|
entry = parse_log_entry({"Id": "7", "Message": " Power supply AC lost \n"})
|
|
assert entry["message"] == "Power supply AC lost"
|
|
assert entry["created"] is None
|
|
assert entry["severity"] is None
|
|
assert entry["origin"] is None
|