Files
napalm-amt/tests/parsers/test_inventory.py
T
christianmanivong 0052ba7884 feat: Intel AMT driver over WS-Management (0.1.0)
An `amt` driver (napalm_amt.AmtDriver), a ManagementControllerDriver for the
management controller of Intel vPro machines, with its own lean WS-Management
client (requests + ElementTree, HTTP Digest, ports 16992/16993).

It reads the machine's identity, hardware with the SMBIOS system UUID, firmware
(AMT with build, BIOS), power state and the hardware event log, reports what AMT
listens on (plain HTTP or TLS, KVM incl. port 5900, IDE-R), and switches the
machine's power. AMT cannot be reset over WS-Management, so there is no
reboot_host. Discovery recognises AMT by its ports and its Server header.

Tested against Intel's published AMT 12 recordings (go-wsman-messages,
Apache-2.0, see NOTICE). `python -m napalm_amt.record` records a real AMT
read-only; the first test devices are two Lenovo ThinkCentre M910x.
2026-10-18 14:55:32 +02:00

101 lines
3.1 KiB
Python

"""CPUs, DIMMs and drives of the managed machine, from the recorded NUC9."""
import pytest
from napalm_amt.parsers import parse_cpus, parse_drives, parse_memory
from ..conftest import instances
def test_cpus_take_the_model_from_the_chip():
cpus = parse_cpus(instances("CIM_Processor.pull.xml"), instances("CIM_Chip.pull.xml"))
assert cpus == [
{
"socket": "CPU 0",
"model": "Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz",
"cores": None,
"threads": None,
"status": "OK",
}
]
@pytest.mark.parametrize(
("cpu_status", "status"),
[("1", "OK"), ("4", "OK"), ("2", "Warning"), ("3", "Critical"), ("0", ""), ("", "")],
)
def test_cpu_status_follows_cpustatus(cpu_status, status):
(cpu,) = parse_cpus([{"DeviceID": "CPU 0", "CPUStatus": cpu_status}], [])
assert cpu["status"] == status
assert cpu["model"] == ""
def test_memory():
dimms = parse_memory(instances("CIM_PhysicalMemory.pull.xml"))
assert dimms[0] == {
"slot": "BANK 0",
"size_bytes": 17179869184,
"type": "DDR4",
"speed_mts": 2400,
"part_number": "CT16G4SFD824A.M16FE",
"serial_number": "E0E8D670",
"status": "",
}
assert [d["slot"] for d in dimms] == ["BANK 0", "BANK 2"]
@pytest.mark.parametrize(
("code", "name"),
[("24", "DDR3"), ("26", "DDR4"), ("29", "LPDDR3"), ("34", "DDR5"), ("2", ""), ("", "")],
)
def test_memory_type_follows_smbios(code, name):
(dimm,) = parse_memory([{"BankLabel": "BANK 0", "MemoryType": code}])
assert dimm["type"] == name
def test_memory_without_a_configured_speed_falls_back_to_the_maximum():
(dimm,) = parse_memory(
[{"BankLabel": "A", "ConfiguredMemoryClockSpeed": "0", "MaxMemorySpeed": "2133"}]
)
assert dimm["speed_mts"] == 2133
def test_memory_slot_falls_back_to_the_tag():
(dimm,) = parse_memory([{"Tag": "ChannelA-DIMM0", "Capacity": "8589934592"}])
assert dimm["slot"] == "ChannelA-DIMM0"
assert dimm["size_bytes"] == 8589934592
def test_drives_size_is_in_kilobytes_of_1000():
drives = parse_drives(instances("CIM_MediaAccessDevice.pull.xml"))
# 500107862 KB is the classic 500 GB disk (976773168 sectors of 512 bytes).
assert drives == [
{
"slot": "MEDIA DEV 0",
"model": "",
"serial_number": "",
"size_bytes": 960197124000,
"media": "",
"protocol": "",
"status": "",
},
{
"slot": "MEDIA DEV 1",
"model": "",
"serial_number": "",
"size_bytes": 500107862000,
"media": "",
"protocol": "",
"status": "",
},
]
@pytest.mark.parametrize(
("operational", "status"), [("2", "OK"), ("3", "Warning"), ("6", "Critical"), ("0", "")]
)
def test_drive_status_follows_operational_status(operational, status):
(drive,) = parse_drives([{"DeviceID": "MEDIA DEV 0", "OperationalStatus": operational}])
assert drive["status"] == status
assert drive["size_bytes"] is None