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.
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
"""What netOrk's discovery scores the driver on.
|
|
|
|
netOrk lowercases the page (title, Server header, body) and matches each rule's pattern as
|
|
a substring; a port that answers adds its PortSpec weight. AMT names itself in its
|
|
``Server`` header on every answer, also the 401 of a page that needs a login.
|
|
"""
|
|
|
|
from napalm_device_types.base import rules_max_weight
|
|
|
|
from napalm_amt import AmtDriver
|
|
|
|
|
|
def _score(text: str) -> float:
|
|
text = " ".join(text.lower().split())
|
|
return sum(rule.weight for rule in AmtDriver.HTTP_FINGERPRINT if rule.pattern in text)
|
|
|
|
|
|
def test_amt_ports_are_probed():
|
|
assert {(s.scheme, s.port) for s in AmtDriver.PORT_SPECS} == {("http", 16992), ("https", 16993)}
|
|
|
|
|
|
def test_server_header_is_recognised():
|
|
assert _score("Intel(R) Active Management Technology 11.8.50.3399") >= 10.0
|
|
|
|
|
|
def test_web_ui_landing_page_is_recognised():
|
|
page = (
|
|
"<html><head><title>Intel® Active Management Technology</title></head>"
|
|
"<body>Log On</body></html>"
|
|
)
|
|
assert _score(page) >= 10.0
|
|
|
|
|
|
def test_other_pages_score_nothing():
|
|
assert _score("<title>Loading...</title> Web Switch nginx") == 0.0
|
|
|
|
|
|
def test_an_answering_amt_port_with_its_header_is_a_confident_match():
|
|
# One of the two ports answers (16992 without TLS, 16993 with); with the header the
|
|
# normalised score must reach netOrk's "high" (0.7).
|
|
port = max(s.weight for s in AmtDriver.PORT_SPECS)
|
|
total = sum(s.weight for s in AmtDriver.PORT_SPECS) + rules_max_weight(
|
|
AmtDriver.HTTP_FINGERPRINT
|
|
)
|
|
assert (port + _score("Intel(R) Active Management Technology 11.8")) / total >= 0.7
|