def test_attribute_defaults(mode, monkeypatch): hostname = "testhost" Scenario().add_host(hostname).apply(monkeypatch) host_config = config.get_config_cache().get_host_config(hostname) ipaddress = ip_lookup.lookup_mgmt_board_ip_address(host_config) source = IPMISource(hostname, ipaddress, mode=mode) assert source.hostname == hostname assert source.ipaddress == ipaddress assert source.mode is mode assert source.description == "Management board - IPMI" assert source.source_type is SourceType.MANAGEMENT assert source.summarize(Result.OK(AgentHostSections())) == (0, "Version: unknown", []) assert source.id == "mgmt_ipmi" assert source.cpu_tracking_id == "mgmt_ipmi"
def test_ipmi_ipaddress_from_mgmt_board(mode, monkeypatch): hostname = "testhost" ipaddress = "127.0.0.1" def fake_lookup_ip_address(host_config, family=None, for_mgmt_board=True): return ipaddress Scenario().add_host(hostname).apply(monkeypatch) monkeypatch.setattr(ip_lookup, "lookup_ip_address", fake_lookup_ip_address) monkeypatch.setattr(config, "host_attributes", { hostname: { "management_address": ipaddress }, }) source = IPMISource(hostname, ipaddress, mode=mode) assert source.host_config.management_address == ipaddress
def test_description_with_ipaddress_and_credentials(monkeypatch): assert IPMISource._make_description( "1.2.3.4", {"username": "******"}, ) == "Management board - IPMI (Address: 1.2.3.4, User: Bobby)"
def test_description_with_credentials(monkeypatch): assert IPMISource._make_description( None, {"username": "******"}) == "Management board - IPMI (User: Bobby)"
def test_description_with_ipaddress(monkeypatch): assert IPMISource._make_description( "1.2.3.4", {}, ) == "Management board - IPMI (Address: 1.2.3.4)"