Esempio n. 1
0
def test_describe_with_credentials(monkeypatch):
    hostname = "testhost"
    Scenario().add_host(hostname).apply(monkeypatch)
    source = IPMIManagementBoardDataSource(hostname, None)
    source._credentials = {"username": "******"}

    assert source.describe() == "Management board - IPMI (User: Bobby)"
def test_describe_with_ipaddress_and_credentials(monkeypatch):
    hostname = "testhost"
    Scenario().add_host(hostname).apply(monkeypatch)
    source = IPMIManagementBoardDataSource(hostname, "127.0.0.1")
    source._credentials = {"username": "******"}

    assert source.describe() == "Management board - IPMI (Address: 127.0.0.1, User: Bobby)"
Esempio n. 3
0
def test_describe_with_ipaddress(monkeypatch):
    hostname = "testhost"
    Scenario().add_host(hostname).apply(monkeypatch)
    source = IPMIManagementBoardDataSource(hostname, None)
    source._ipaddress = "127.0.0.1"  # The API is lying.

    assert source.describe() == "Management board - IPMI (Address: 127.0.0.1)"
def test_attribute_defaults(monkeypatch, ipaddress):
    hostname = "testhost"
    Scenario().add_host(hostname).apply(monkeypatch)
    # NOTE: pylint is quite buggy when it comes to class hierarchies and abstract methods!
    source = IPMIManagementBoardDataSource(hostname, ipaddress)  # pylint: disable=abstract-class-instantiated

    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("anything will do") == (0,
                                                          "Version: unknown",
                                                          [])
    assert source._get_ipmi_version() == "unknown"
Esempio n. 5
0
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, None)

    assert source._host_config.management_address == ipaddress
    assert source._ipaddress == ipaddress
Esempio n. 6
0
def test_attribute_defaults(monkeypatch, ipaddress):
    hostname = "testhost"
    Scenario().add_host(hostname).apply(monkeypatch)
    source = IPMIManagementBoardDataSource(hostname, ipaddress)

    assert source._for_mgmt_board is True
    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"
def test_attribute_defaults(monkeypatch):
    hostname = "testhost"
    Scenario().add_host(hostname).apply(monkeypatch)
    source = IPMIManagementBoardDataSource(
        hostname,
        ip_lookup.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._summary_result(True) == (0, "Version: unknown", [])
    assert source._get_ipmi_version() == "unknown"
Esempio n. 8
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
        },
    })

    configurator = IPMIConfigurator(hostname, ipaddress, mode=mode)
    assert configurator.host_config.management_address == ipaddress

    source = IPMIManagementBoardDataSource(configurator=configurator)
    assert source.ipaddress == ipaddress
Esempio n. 9
0
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)

    configurator = IPMIConfigurator(hostname, ipaddress, mode=mode)
    assert configurator.hostname == hostname
    assert configurator.ipaddress == ipaddress
    assert configurator.mode is mode
    assert configurator.description == "Management board - IPMI"
    assert configurator.source_type is SourceType.MANAGEMENT

    source = IPMIManagementBoardDataSource(configurator=configurator)
    assert source.hostname == hostname
    # Address comes from management board.
    assert source.ipaddress is None
    assert source.id == "mgmt_ipmi"
    assert source._cpu_tracking_id == source.id

    summarizer = source.summarizer
    assert summarizer.summarize(AgentHostSections()) == (0, "Version: unknown", [])
Esempio n. 10
0
def test_ipmi_ipaddress_from_mgmt_board(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
        },
    })

    host_config = config.get_config_cache().get_host_config(hostname)
    source = IPMIManagementBoardDataSource(
        hostname,
        ip_lookup.lookup_mgmt_board_ip_address(host_config),
    )

    assert source._host_config.management_address == ipaddress
    assert source.ipaddress == ipaddress