feat: a bmc driver that takes the best of Redfish and IPMI (0.4.0)
bmc (napalm_redfish.bmc:BmcDriver) reads a BMC over Redfish where it answers. A BMC that refuses Redfish (no license) is read and switched over IPMI. A getter that fails over Redfish is asked over IPMI where IPMI has it; IPMI is opened only then. Power control goes over Redfish when it answers, and a refusal is final. The BMC is reset over Redfish only. Same account for both; ipmi_port in optional_args. Discovery suggests bmc for a BMC it finds: the fingerprint rules moved from RedfishDriver to BmcDriver.
This commit is contained in:
1 parent
adf152ee12
commit
e9ad7951cd
9 files changed
+412
-23
No files matched your search
+15
-5
@@ -8,23 +8,33 @@ import json
|
||||
from pathlib import Path
|
||||
|
||||
from napalm_redfish import RedfishDriver
|
||||
from napalm_redfish.bmc import BmcDriver
|
||||
from napalm_redfish.ipmi import IpmiDriver
|
||||
|
||||
X10 = Path(__file__).parent / "fixtures" / "supermicro-x10drl-i-3.91"
|
||||
|
||||
|
||||
def _score(text: str) -> float:
|
||||
text = " ".join(text.lower().split())
|
||||
return sum(rule.weight for rule in RedfishDriver.HTTP_FINGERPRINT if rule.pattern in text)
|
||||
return sum(rule.weight for rule in BmcDriver.HTTP_FINGERPRINT if rule.pattern in text)
|
||||
|
||||
|
||||
def test_discovery_suggests_the_bmc_driver_only():
|
||||
# bmc works with and without a license; two drivers on the same rules would tie.
|
||||
assert BmcDriver.HTTP_FINGERPRINT
|
||||
assert RedfishDriver.HTTP_FINGERPRINT == []
|
||||
assert not RedfishDriver.PORT_SPECS
|
||||
assert IpmiDriver.HTTP_FINGERPRINT == []
|
||||
|
||||
|
||||
def test_an_open_https_port_proves_nothing():
|
||||
# Every switch with a web UI answers on 443; the port alone made six of
|
||||
# them look like BMCs.
|
||||
assert [spec.weight for spec in RedfishDriver.PORT_SPECS if spec.port == 443] == [0.0]
|
||||
assert [spec.weight for spec in BmcDriver.PORT_SPECS if spec.port == 443] == [0.0]
|
||||
|
||||
|
||||
def test_service_root_is_still_probed():
|
||||
assert any("/redfish/v1/" in spec.paths for spec in RedfishDriver.PORT_SPECS)
|
||||
assert any("/redfish/v1/" in spec.paths for spec in BmcDriver.PORT_SPECS)
|
||||
|
||||
|
||||
def test_supermicro_landing_page_is_recognised():
|
||||
@@ -53,11 +63,11 @@ def test_alternatives_count_once_towards_the_maximum():
|
||||
# BMC's SNMP sysDescr (5 of 18) beat the Supermicro landing page (6 of 41).
|
||||
from napalm_device_types import rules_max_weight
|
||||
|
||||
assert rules_max_weight(RedfishDriver.HTTP_FINGERPRINT) == 21.0
|
||||
assert rules_max_weight(BmcDriver.HTTP_FINGERPRINT) == 21.0
|
||||
|
||||
|
||||
def test_supermicro_landing_page_alone_outranks_a_linux_sysdescr():
|
||||
from napalm_device_types import rules_max_weight
|
||||
|
||||
page = _score((X10 / "landing_page.html").read_text())
|
||||
assert page / rules_max_weight(RedfishDriver.HTTP_FINGERPRINT) > 5.0 / 18.0
|
||||
assert page / rules_max_weight(BmcDriver.HTTP_FINGERPRINT) > 5.0 / 18.0
|
||||
Reference in new issue
Block a user