def test_snmp_ipaddress_from_mgmt_board_unresolvable(monkeypatch): def failed_ip_lookup(h): raise MKIPAddressLookupError("Failed to ...") Scenario().add_host("hostname").apply(monkeypatch) monkeypatch.setattr(ip_lookup, "lookup_ip_address", failed_ip_lookup) monkeypatch.setattr(config, "host_attributes", { "hostname": { "management_address": "lolo" }, }) assert management_board_ipaddress("hostname") is None
def test_ipmi_ipaddress_from_mgmt_board(monkeypatch): hostname = "testhost" ipaddress = "127.0.0.1" Scenario().add_host(hostname).apply(monkeypatch) monkeypatch.setattr(ip_lookup, "lookup_ip_address", lambda h: ipaddress) monkeypatch.setattr(config, "host_attributes", { hostname: { "management_address": ipaddress }, }) source = IPMIManagementBoardDataSource( hostname, management_board_ipaddress(hostname), ) assert source._host_config.management_address == ipaddress assert source._ipaddress == ipaddress
def test_attribute_defaults(monkeypatch): hostname = "testhost" Scenario().add_host(hostname).apply(monkeypatch) source = IPMIManagementBoardDataSource( hostname, management_board_ipaddress(hostname), ) assert source.source_type is SourceType.MANAGEMENT assert source._hostname == hostname # Address comes from management board. assert source._ipaddress is None assert source.id() == "mgmt_ipmi" assert source.title() == "Management board - IPMI" assert source._cpu_tracking_id() == source.id() assert source._gather_check_plugin_names() == {"mgmt_ipmi_sensors"} assert source._summary_result(True) == (0, "Version: unknown", []) assert source._get_ipmi_version() == "unknown"