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"
예제 #2
0
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