driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 59s
driver / test (3.12) (pull_request) Successful in 1m1s
driver / test (3.13) (pull_request) Successful in 53s
driver / lowest (pull_request) Successful in 28s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 54s
CI / driver (pull_request) Successful in 2m25s
driver / publish (pull_request) Skipped
textfsm 2.1.1 (2026-11-10, through napalm) installs a top-level package "tests" into site-packages. It shadows this repo's tests directory, which is no package, so "from tests.conftest import ..." found textfsm's and test_bmc_driver.py and test_x10_redfish.py failed to import: every test run on CI fails since that release, main included. The helpers are imported as conftest and test_ipmi, the way test_driver.py already does; pytest puts tests/ on the path for them.
109 lines
3.6 KiB
Python
109 lines
3.6 KiB
Python
"""RedfishDriver against a recording of a real Supermicro X10DRL-i (BMC 3.91, Redfish 1.0.1).
|
|
|
|
Recorded 2026-10-17 with an SFT-OOB-LIC license only: the service root and most resources
|
|
answer, but ``Systems/1/Storage`` and ``UpdateService`` want the DCMS license as well (403,
|
|
``OemLicenseNotPassed``). Serial numbers, UUIDs, MACs, addresses, the host name and the SNMP
|
|
communities are scrubbed. ``STATUS.json`` lists the paths that did not answer 200; their
|
|
files hold the error body the BMC sent.
|
|
"""
|
|
|
|
import json
|
|
|
|
import pytest
|
|
from conftest import BASE_URL, FIXTURES, MockupServer
|
|
from napalm_device_types import models
|
|
|
|
from napalm_redfish import RedfishDriver
|
|
|
|
MOCKUP = "supermicro-x10drl-i-3.91/redfish"
|
|
REFUSED = json.loads((FIXTURES / MOCKUP / "STATUS.json").read_text())
|
|
|
|
|
|
@pytest.fixture
|
|
def x10(http):
|
|
server = MockupServer(http, MOCKUP)
|
|
for path, status in REFUSED.items():
|
|
body = json.loads(
|
|
(FIXTURES / MOCKUP / path[len("/redfish/v1/") :] / "index.json").read_text()
|
|
)
|
|
server.override("GET", path, status, body)
|
|
return server
|
|
|
|
|
|
@pytest.fixture
|
|
def driver(x10):
|
|
d = RedfishDriver(
|
|
BASE_URL.removeprefix("https://"), "netork", "secret", optional_args={"verify_ssl": False}
|
|
)
|
|
d.open()
|
|
yield d
|
|
d.close()
|
|
|
|
|
|
def test_the_facts_name_the_board_not_super_server(driver):
|
|
facts = driver.get_facts()
|
|
assert facts["vendor"] == "Supermicro"
|
|
# Systems/1 says "Super Server"; the board is its PartNumber and the chassis model.
|
|
assert facts["model"] == "X10DRL-i"
|
|
assert facts["os_version"] == "3.91"
|
|
assert facts["serial_number"] == "ZM000S000001"
|
|
|
|
|
|
def test_the_inventory_survives_the_storage_it_may_not_read(driver):
|
|
inv = driver.get_hardware_inventory()
|
|
assert set(inv) == set(models.HardwareInventoryDict.__annotations__)
|
|
assert inv["model"] == "X10DRL-i"
|
|
assert inv["system_uuid"] == "00000000-0000-0000-0000-00005e00534c"
|
|
assert len(inv["cpus"]) == 2
|
|
assert len(inv["memory"]) == 8
|
|
assert inv["drives"] == []
|
|
|
|
|
|
def test_the_firmware_comes_from_the_manager_and_the_system_without_updateservice(driver):
|
|
assert driver.get_firmware_inventory() == [
|
|
{"name": "BMC", "version": "3.91", "updateable": None},
|
|
{"name": "BIOS", "version": "3.1c", "updateable": None},
|
|
]
|
|
|
|
|
|
def test_the_missing_license_is_named_with_what_it_withholds(driver):
|
|
assert driver.get_device_warnings() == [
|
|
{
|
|
"code": "bmc_license_partial",
|
|
"meta": {"licenses": "DCMS", "parts": ["drives", "firmware inventory"]},
|
|
}
|
|
]
|
|
|
|
|
|
def test_the_power_actions_are_the_ones_the_bmc_advertises(driver):
|
|
assert driver.get_power_state() == {
|
|
"state": "On",
|
|
"actions": ["GracefulShutdown", "ForceOff", "GracefulRestart", "ForceRestart"],
|
|
}
|
|
|
|
|
|
def test_the_protocols_report_ipmi_over_lan_on(driver):
|
|
protocols = driver.get_management_protocols()
|
|
assert protocols["ipmi"] == {"enabled": True, "port": 623}
|
|
assert protocols["https"] == {"enabled": True, "port": 443}
|
|
|
|
|
|
def test_the_sensors_and_the_event_log_read(driver):
|
|
env = driver.get_environment()
|
|
assert len(env["temperature"]) == 19
|
|
assert len(env["fans"]) == 4
|
|
assert isinstance(driver.get_event_log(limit=5), list)
|
|
|
|
|
|
# ── licenses as facts (#1111) ───────────────────────────────────────────
|
|
|
|
|
|
def test_the_missing_license_is_a_fact_with_what_it_withholds(driver):
|
|
assert driver.get_licenses() == [
|
|
{
|
|
"name": "DCMS",
|
|
"status": "missing",
|
|
"withholds": ["drives", "firmware inventory"],
|
|
}
|
|
]
|