예제 #1
0
def test_delete_host(web):
    try:
        web.add_host("test-host-delete", attributes={
            "ipaddress": "127.0.0.1",
        })
    finally:
        web.delete_host("test-host-delete")
예제 #2
0
def test_automation_update_dns_cache(test_cfg, site, web):
    cache_path = 'var/check_mk/ipaddresses.cache'

    if site.file_exists(cache_path):
        site.delete_file(cache_path)

    try:
        web.add_host("update-dns-cache-host")
        web.add_host("localhost")

        site.write_file(cache_path, "{('bla', 4): '127.0.0.1'}")

        data = _execute_automation(site, "update-dns-cache")
        assert isinstance(data, tuple)
        assert len(data) == 2

        assert data[0] > 0
        assert data[1] == ["update-dns-cache-host"]

        assert site.file_exists(cache_path)

        cache = eval(site.read_file(cache_path))
        assert isinstance(cache, dict)
        assert cache[("localhost", 4)] == "127.0.0.1"
        assert ("bla", 4) not in cache

    finally:
        web.delete_host("localhost")
        web.delete_host("update-dns-cache-host")
예제 #3
0
def test_log(request, web, site, fake_sendmail):
    core, log = request.param
    site.set_config("CORE", core, with_restart=True)

    users = {
        "hh": {
            "alias": "Harry Hirsch",
            "password": "******",
            "email": u"%s@localhost" % web.site.id,
            'contactgroups': ['all'],
        },
    }

    expected_users = set(["cmkadmin", "automation"] + users.keys())
    web.add_htpasswd_users(users)
    all_users = web.get_all_users()
    assert not expected_users - set(all_users.keys())

    site.live.command("[%d] STOP_EXECUTING_HOST_CHECKS" % time.time())
    site.live.command("[%d] STOP_EXECUTING_SVC_CHECKS" % time.time())

    web.add_host("notify-test", attributes={
        "ipaddress": "127.0.0.1",
    })
    web.activate_changes()

    with WatchLog(site, log, default_timeout=20) as l:
        yield l

    site.live.command("[%d] START_EXECUTING_HOST_CHECKS" % time.time())
    site.live.command("[%d] START_EXECUTING_SVC_CHECKS" % time.time())

    web.delete_host("notify-test")
    web.delete_htpasswd_users(users.keys())
    web.activate_changes()
예제 #4
0
def graph_test_config(web, site):
    # No graph yet...
    with pytest.raises(APIError) as exc_info:
        web.get_regular_graph("test-host-get-graph",
                              "Check_MK",
                              0,
                              expect_error=True)
        assert "Cannot calculate graph recipes" in "%s" % exc_info

    try:
        # Now add the host
        web.add_host("test-host-get-graph",
                     attributes={
                         "ipaddress": "127.0.0.1",
                     })

        site.write_file(
            "etc/check_mk/conf.d/test-host-get-graph.mk",
            "datasource_programs.append(('cat ~/var/check_mk/agent_output/<HOST>', [], ['test-host-get-graph']))\n"
        )

        site.makedirs("var/check_mk/agent_output/")
        site.write_file(
            "var/check_mk/agent_output/test-host-get-graph",
            open(
                "%s/tests/integration/cmk/base/test-files/linux-agent-output" %
                repo_path()).read())

        web.discover_services("test-host-get-graph")
        web.activate_changes()
        site.schedule_check("test-host-get-graph", "Check_MK", 0)

        # Wait for RRD file creation. Isn't this a bug that the graph is not instantly available?
        rrd_path = site.path(
            "var/check_mk/rrd/test-host-get-graph/Check_MK.rrd")
        for attempt in xrange(50):
            time.sleep(0.1)
            proc = subprocess.Popen([
                site.path("bin/unixcat"),
                site.path("tmp/run/rrdcached.sock")
            ],
                                    stdin=subprocess.PIPE,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
            out, err = proc.communicate("FLUSH %s\n" % rrd_path)
            if os.path.exists(rrd_path):
                break
            sys.stdout.write("waiting for %s (attempt %d)%s%s\n" % (
                rrd_path,
                attempt + 1,  #
                ", stdout: %s" % out if out else "",
                ", stderr: %s" % err if err else ""))
        else:
            assert False, "RRD file %s missing" % rrd_path

        yield
    finally:
        web.delete_host("test-host-get-graph")
        site.delete_file("etc/check_mk/conf.d/test-host-get-graph.mk")
    web.activate_changes()
예제 #5
0
def fixture_local_test_hosts(web, site):
    site.makedirs("var/check_mk/agent_output/")

    web.add_hosts([
        ("test-host", "", {
            "ipaddress": "127.0.0.1",
        }),
        ("test-host2", "xy/zzz", {
            "ipaddress": "127.0.0.1",
        }),
    ])

    site.write_file(
        "etc/check_mk/conf.d/local-test-hosts.mk",
        "datasource_programs.append(('cat ~/var/check_mk/agent_output/<HOST>', [], ['test-host', 'test-host2']))\n"
    )

    for hostname in ["test-host", "test-host2"]:
        site.write_file("var/check_mk/agent_output/%s" % hostname,
                        get_standard_linux_agent_output())

    yield

    for hostname in ["test-host", "test-host2"]:
        web.delete_host(hostname)
        site.delete_file("var/check_mk/agent_output/%s" % hostname)
    site.delete_file("etc/check_mk/conf.d/local-test-hosts.mk")
예제 #6
0
def test_delete_host(web):
    try:
        web.add_host("test-host-delete", attributes={
            "ipaddress": "127.0.0.1",
        })
    finally:
        web.delete_host("test-host-delete")
예제 #7
0
def test_delete_host(web):  # noqa: F811 # pylint: disable=redefined-outer-name
    try:
        web.add_host("test-host-delete", attributes={
            "ipaddress": "127.0.0.1",
        })
    finally:
        web.delete_host("test-host-delete")
예제 #8
0
def test_config(web, site):
    users = {
        "hh": {
            "alias": "Harry Hirsch",
            "password": "******",
            "email": u"%s@localhost" % web.site.id,
            'contactgroups': ['all'],
        },
    }

    expected_users = set(["cmkadmin", "automation"] + users.keys())
    web.add_htpasswd_users(users)
    all_users = web.get_all_users()
    assert not expected_users - set(all_users.keys())

    site.live.command("[%d] STOP_EXECUTING_HOST_CHECKS" % time.time())
    site.live.command("[%d] STOP_EXECUTING_SVC_CHECKS" % time.time())

    web.add_host("notify-test", attributes={
        "ipaddress": "127.0.0.1",
    })
    web.activate_changes()

    yield

    site.live.command("[%d] START_EXECUTING_HOST_CHECKS" % time.time())
    site.live.command("[%d] START_EXECUTING_SVC_CHECKS" % time.time())

    web.delete_host("notify-test")
    web.delete_htpasswd_users(users.keys())
    web.activate_changes()
예제 #9
0
def local_test_hosts(web, site):
    site.makedirs("var/check_mk/agent_output/")

    web.add_hosts([
        ("test-host", "", {
            "ipaddress": "127.0.0.1",
        }),
        ("test-host2", "xy/zzz", {
            "ipaddress": "127.0.0.1",
        }),
    ])

    site.write_file(
        "etc/check_mk/conf.d/local-test-hosts.mk",
        "datasource_programs.append(('cat ~/var/check_mk/agent_output/<HOST>', [], ['test-host', 'test-host2']))\n"
    )

    for hostname in ["test-host", "test-host2"]:
        site.write_file(
            "var/check_mk/agent_output/%s" % hostname,
            open(
                "%s/tests/integration/cmk/base/test-files/linux-agent-output" %
                repo_path()).read())

    yield

    for hostname in ["test-host", "test-host2"]:
        web.delete_host(hostname)
        site.delete_file("var/check_mk/agent_output/%s" % hostname)
    site.delete_file("etc/check_mk/conf.d/local-test-hosts.mk")
예제 #10
0
def test_get_inventory(web):
    host_name = "test-host"
    inventory_dir = "var/check_mk/inventory"
    try:
        web.add_host(host_name, attributes={"ipaddress": "127.0.0.1"})
        # NOTE: Deleting the host deletes the file, too.
        web.site.makedirs(inventory_dir)
        web.site.write_file(os.path.join(inventory_dir, host_name),
                            "{'hardware': {'memory': {'ram': 10000, 'foo': 1}, 'blubb': 42}}")

        inv = web.get_inventory([host_name])
        assert inv[host_name] == {
            u'hardware': {
                u'memory': {
                    u'foo': 1,
                    u'ram': 10000
                },
                u'blubb': 42
            }
        }

        inv = web.get_inventory([host_name], paths=['.hardware.memory.'])
        assert inv[host_name] == {u'hardware': {u'memory': {u'foo': 1, u'ram': 10000}}}

        inv = web.get_inventory([host_name], paths=['.hardware.mumpf.'])
        assert inv[host_name] == {}
    finally:
        web.delete_host(host_name)
예제 #11
0
def test_add_host(web):
    try:
        # Also tests get_host
        web.add_host("test-host", attributes={
            "ipaddress": "127.0.0.1",
        })
    finally:
        web.delete_host("test-host")
예제 #12
0
def test_add_host(web):
    try:
        # Also tests get_host
        web.add_host("test-host", attributes={
            "ipaddress": "127.0.0.1",
        })
    finally:
        web.delete_host("test-host")
예제 #13
0
def test_discover_servics(web):
    try:
        web.add_host("test-host-discovery", attributes={
            "ipaddress": "127.0.0.1",
        })

        web.discover_services("test-host-discovery")
    finally:
        web.delete_host("test-host-discovery")
예제 #14
0
def test_discover_services(web):
    try:
        web.add_host("test-host-discovery", attributes={
            "ipaddress": "127.0.0.1",
        })

        web.discover_services("test-host-discovery")
    finally:
        web.delete_host("test-host-discovery")
예제 #15
0
def test_discover_services(web):  # noqa: F811 # pylint: disable=redefined-outer-name
    try:
        web.add_host("test-host-discovery", attributes={
            "ipaddress": "127.0.0.1",
        })

        web.discover_services("test-host-discovery")
    finally:
        web.delete_host("test-host-discovery")
예제 #16
0
def test_edit_host(web):
    try:
        web.add_host("test-edit-host", attributes={
            "ipaddress": "127.0.0.1",
        })

        web.edit_host("test-edit-host", attributes={"ipaddress": "127.10.0.1"})
    finally:
        web.delete_host("test-edit-host")
예제 #17
0
def graph_test_config(web, site):
    # No graph yet...
    with pytest.raises(APIError) as e:
        web.get_regular_graph("test-host-get-graph",
                              "Check_MK",
                              0,
                              expect_error=True)
        assert "Cannot calculate graph recipes" in "%s" % e

    try:
        # Now add the host
        web.add_host("test-host-get-graph",
                     attributes={
                         "ipaddress": "127.0.0.1",
                     })

        site.write_file(
            "etc/check_mk/conf.d/test-host-get-graph.mk",
            "datasource_programs.append(('cat ~/var/check_mk/agent_output/<HOST>', [], ['test-host-get-graph']))\n"
        )

        site.makedirs("var/check_mk/agent_output/")
        site.write_file(
            "var/check_mk/agent_output/test-host-get-graph",
            file(
                "%s/tests/integration/cmk_base/test-files/linux-agent-output" %
                repo_path()).read())

        web.discover_services("test-host-get-graph")
        web.activate_changes()
        site.schedule_check("test-host-get-graph", "Check_MK", 0)

        # Wait for RRD file creation
        # Isn't this a bug that the graph is not instantly available?
        timeout = 10
        print "Checking for graph..."
        while timeout and not site.file_exists(
                "var/check_mk/rrd/test-host-get-graph/Check_MK.rrd"):
            try:
                web.get_regular_graph("test-host-get-graph",
                                      "Check_MK",
                                      0,
                                      expect_error=True)
            except Exception:
                pass
            timeout -= 1
            time.sleep(1)
            print "Checking for graph..."
            assert site.file_exists("var/check_mk/rrd/test-host-get-graph/Check_MK.rrd"), \
                "RRD %s is still missing" % "var/check_mk/rrd/test-host-get-graph/Check_MK.rrd"

        yield
    finally:
        web.delete_host("test-host-get-graph")
        site.delete_file("etc/check_mk/conf.d/test-host-get-graph.mk")
    web.activate_changes()
예제 #18
0
def test_get_all_hosts_basic(web):
    try:
        web.add_host("test-host-list", attributes={
            "ipaddress": "127.0.0.1",
        })

        hosts = web.get_all_hosts()
        assert "test-host-list" in hosts
    finally:
        web.delete_host("test-host-list")
예제 #19
0
def test_get_all_hosts_basic(web):  # noqa: F811 # pylint: disable=redefined-outer-name
    try:
        web.add_host("test-host-list", attributes={
            "ipaddress": "127.0.0.1",
        })

        hosts = web.get_all_hosts()
        assert "test-host-list" in hosts
    finally:
        web.delete_host("test-host-list")
예제 #20
0
def test_get_all_hosts_basic(web):
    try:
        web.add_host("test-host-list", attributes={
            "ipaddress": "127.0.0.1",
        })

        hosts = web.get_all_hosts()
        assert "test-host-list" in hosts
    finally:
        web.delete_host("test-host-list")
예제 #21
0
def test_add_host_folder_create(web):
    web.add_host(
        "test-host",
        attributes={
            "ipaddress": "127.0.0.1",
        },
        create_folders=True,
        folder="asd/eee",
    )

    web.delete_host("test-host")
예제 #22
0
def test_add_host_folder_create(web):  # noqa: F811 # pylint: disable=redefined-outer-name
    try:
        web.add_host(
            "test-host",
            attributes={
                "ipaddress": "127.0.0.1",
            },
            create_folders=True,
            folder="asd/eee",
        )
    finally:
        web.delete_host("test-host")
예제 #23
0
def test_activate_changes(web, site):
    try:
        web.add_host("test-host-activate", attributes={
            "ipaddress": "127.0.0.1",
        })

        web.activate_changes()

        result = site.live.query("GET hosts\nColumns: name\nFilter: name = test-host-activate\n")
        assert result == [["test-host-activate"]]
    finally:
        web.delete_host("test-host-activate")
        web.activate_changes()
예제 #24
0
def test_activate_changes(web, site):
    try:
        web.add_host("test-host-activate", attributes={
            "ipaddress": "127.0.0.1",
        })

        web.activate_changes()

        result = site.live.query("GET hosts\nColumns: name\nFilter: name = test-host-activate\n")
        assert result == [["test-host-activate"]]
    finally:
        web.delete_host("test-host-activate")
        web.activate_changes()
예제 #25
0
def test_cfg(web, site):
    print("Applying default config")
    web.add_host("modes-test-host", attributes={
        "ipaddress": "127.0.0.1",
    })
    web.add_host("modes-test-host2",
                 attributes={
                     "ipaddress": "127.0.0.1",
                     "tag_criticality": "test",
                 })
    web.add_host("modes-test-host3",
                 attributes={
                     "ipaddress": "127.0.0.1",
                     "tag_criticality": "test",
                 })
    web.add_host("modes-test-host4",
                 attributes={
                     "ipaddress": "127.0.0.1",
                     "tag_criticality": "offline",
                 })

    site.write_file(
        "etc/check_mk/conf.d/modes-test-host.mk",
        "datasource_programs.append(('cat ~/var/check_mk/agent_output/<HOST>', [], ALL_HOSTS))\n"
    )

    site.makedirs("var/check_mk/agent_output/")
    site.write_file(
        "var/check_mk/agent_output/modes-test-host",
        file("%s/tests/integration/cmk_base/test-files/linux-agent-output" %
             repo_path()).read())
    site.write_file(
        "var/check_mk/agent_output/modes-test-host2",
        file("%s/tests/integration/cmk_base/test-files/linux-agent-output" %
             repo_path()).read())
    site.write_file(
        "var/check_mk/agent_output/modes-test-host3",
        file("%s/tests/integration/cmk_base/test-files/linux-agent-output" %
             repo_path()).read())

    web.discover_services("modes-test-host")
    web.discover_services("modes-test-host2")
    web.discover_services("modes-test-host3")

    web.activate_changes()
    yield None

    #
    # Cleanup code
    #
    print("Cleaning up test config")

    site.delete_dir("var/check_mk/agent_output")

    site.delete_file("etc/check_mk/conf.d/modes-test-host.mk")

    web.delete_host("modes-test-host")
    web.delete_host("modes-test-host2")
    web.delete_host("modes-test-host3")
    web.delete_host("modes-test-host4")
예제 #26
0
def test_get_host_effective_attributes(web):  # noqa: F811 # pylint: disable=redefined-outer-name
    try:
        web.add_host("test-host", attributes={
            "ipaddress": "127.0.0.1",
        })

        host = web.get_host("test-host", effective_attributes=False)
        assert "tag_networking" not in host["attributes"]

        host = web.get_host("test-host", effective_attributes=True)
        assert "tag_networking" in host["attributes"]
        assert host["attributes"]["tag_networking"] == "lan"
    finally:
        web.delete_host("test-host")
예제 #27
0
def test_get_host_effective_attributes(web):
    try:
        web.add_host("test-host", attributes={
            "ipaddress": "127.0.0.1",
        })

        host = web.get_host("test-host", effective_attributes=False)
        assert "tag_networking" not in host["attributes"]

        host = web.get_host("test-host", effective_attributes=True)
        assert "tag_networking" in host["attributes"]
        assert host["attributes"]["tag_networking"] == "lan"
    finally:
        web.delete_host("test-host")
예제 #28
0
def test_get_graph(web, site):
    try:
        # No graph yet...
        with pytest.raises(APIError) as e:
            data = web.get_regular_graph("test-host-get-graph",
                                         "Check_MK",
                                         0,
                                         expect_error=True)
            assert "Cannot calculate graph recipes" in "%s" % e

        # Now add the host
        web.add_host("test-host-get-graph",
                     attributes={
                         "ipaddress": "127.0.0.1",
                     })
        web.discover_services("test-host-get-graph")
        web.activate_changes()

        # Issue a reschedule
        site.live.command(
            "SCHEDULE_FORCED_SERVICE_CHECK;test-host-get-graph;Check_MK;%d" %
            int(time.time()))

        # Wait for RRD file creation
        # Isn't this a bug that the graph is not instantly available?
        timeout = 10
        print "Checking for graph..."
        while timeout and not site.file_exists(
                "var/check_mk/rrd/test-host-get-graph/Check_MK.rrd"):
            try:
                data = web.get_regular_graph("test-host-get-graph",
                                             "Check_MK",
                                             0,
                                             expect_error=True)
            except Exception:
                pass
            timeout -= 1
            time.sleep(1)
            print "Checking for graph..."
        assert site.file_exists("var/check_mk/rrd/test-host-get-graph/Check_MK.rrd"), \
                        "RRD %s is still missing" % "var/check_mk/rrd/test-host-get-graph/Check_MK.rrd"

        _test_get_graph_api(web)
        _test_get_graph_image(web)
        _test_get_graph_notification_image(web)

    finally:
        web.delete_host("test-host-get-graph")
        web.activate_changes()
예제 #29
0
def default_cfg(web):
    web.add_host("livestatus-test-host", attributes={
        "ipaddress": "127.0.0.1",
    })

    web.discover_services("livestatus-test-host")

    web.activate_changes()
    yield None

    #
    # Cleanup code
    #

    web.delete_host("livestatus-test-host")
예제 #30
0
def default_cfg(web):
    web.add_host("livestatus-test-host",
                 attributes={
                     "ipaddress": "127.0.0.1",
                 })

    web.discover_services("livestatus-test-host")

    web.activate_changes()
    yield None

    #
    # Cleanup code
    #

    web.delete_host("livestatus-test-host")
예제 #31
0
def test_cfg_fixture(web, site):  # noqa: F811 # pylint: disable=redefined-outer-name
    print("Applying default config")
    web.add_host("modes-test-host", attributes={
        "ipaddress": "127.0.0.1",
    })
    web.add_host("modes-test-host2",
                 attributes={
                     "ipaddress": "127.0.0.1",
                     "tag_criticality": "test",
                 })
    web.add_host("modes-test-host3",
                 attributes={
                     "ipaddress": "127.0.0.1",
                     "tag_criticality": "test",
                 })
    web.add_host("modes-test-host4",
                 attributes={
                     "ipaddress": "127.0.0.1",
                     "tag_criticality": "offline",
                 })

    site.write_file(
        "etc/check_mk/conf.d/modes-test-host.mk",
        "datasource_programs.append(('cat ~/var/check_mk/agent_output/<HOST>', [], ALL_HOSTS))\n"
    )

    site.makedirs("var/check_mk/agent_output/")
    site.write_file("var/check_mk/agent_output/modes-test-host",
                    get_standard_linux_agent_output())
    site.write_file("var/check_mk/agent_output/modes-test-host2",
                    get_standard_linux_agent_output())
    site.write_file("var/check_mk/agent_output/modes-test-host3",
                    get_standard_linux_agent_output())

    web.discover_services("modes-test-host")
    web.discover_services("modes-test-host2")
    web.discover_services("modes-test-host3")

    try:
        web.activate_changes()
        yield None
    finally:
        #
        # Cleanup code
        #
        print("Cleaning up test config")

        site.delete_dir("var/check_mk/agent_output")

        site.delete_file("etc/check_mk/conf.d/modes-test-host.mk")

        web.delete_host("modes-test-host")
        web.delete_host("modes-test-host2")
        web.delete_host("modes-test-host3")
        web.delete_host("modes-test-host4")

        web.activate_changes()
예제 #32
0
def default_cfg(web):
    print "Applying default config"
    web.add_host("livestatus-test-host",
                 attributes={
                     "ipaddress": "127.0.0.1",
                 })

    web.discover_services("livestatus-test-host")

    web.activate_changes()
    yield None

    #
    # Cleanup code
    #
    print "Cleaning up default config"

    web.delete_host("livestatus-test-host")
예제 #33
0
def test_cfg(request, web, site):
    config = DefaultConfig(core=request.param)
    site.set_config("CORE", config.core, with_restart=True)

    print("Applying default config")
    web.add_host("test-host", attributes={
        "ipaddress": "127.0.0.1",
        "tag_agent": "no-agent",
    })

    web.activate_changes()
    yield config

    #
    # Cleanup code
    #
    print("Cleaning up test config")

    web.delete_host("test-host")
예제 #34
0
def test_cfg(web, site):
    print("Applying default config")
    web.add_host("modes-test-host", attributes={
        "ipaddress": "127.0.0.1",
    })

    site.write_file(
        "etc/check_mk/conf.d/modes-test-host.mk",
        "datasource_programs.append(('cat ~/var/check_mk/agent_output/<HOST>', [], ['modes-test-host']))\n"
    )

    site.makedirs("var/check_mk/agent_output/")
    web.activate_changes()

    yield None

    #
    # Cleanup code
    #
    print("Cleaning up test config")
    web.delete_host("modes-test-host")
예제 #35
0
def test_cfg(web, clear_config_caches, enable_debug):
    reload_config()
    yield

    #
    # Cleanup code
    #
    print("Cleaning up test config")

    if web.host_exists("mgmt-host"):
        web.delete_host("mgmt-host")

    if web.folder_exists("folder1"):
        web.delete_folder("folder1")

    web.set_ruleset(
        "management_board_config",
        {
            "ruleset": {
                "": [],  # -> folder
            }
        })

    web.activate_changes()
예제 #36
0
def test_write_host_tags(web, site):
    try:
        web.add_host("test-host-dmz",
                     attributes={
                         "ipaddress": "127.0.0.1",
                         "tag_networking": "dmz",
                     })

        web.add_host("test-host-lan",
                     attributes={
                         "ipaddress": "127.0.0.1",
                         "tag_networking": "lan",
                     })

        web.add_host("test-host-lan2", attributes={
            "ipaddress": "127.0.0.1",
        })

        hosts = web.get_all_hosts(effective_attributes=True)
        assert hosts["test-host-dmz"]["attributes"]["tag_networking"] == "dmz"
        assert hosts["test-host-lan"]["attributes"]["tag_networking"] == "lan"
        assert hosts["test-host-lan2"]["attributes"]["tag_networking"] == "lan"

        cfg = {
            "FOLDER_PATH": "/",
            "all_hosts": [],
            "ipaddresses": {},
            "host_attributes": {},
        }

        exec(site.read_file("etc/check_mk/conf.d/wato/hosts.mk"), cfg, cfg)

        tags_by_host = {}
        for entry in cfg["all_hosts"]:
            hostname, tag_txt = entry.split("|", 1)
            tags_by_host[hostname] = tag_txt.split("|")

        assert "dmz" in tags_by_host["test-host-dmz"]
        assert "lan" not in tags_by_host["test-host-dmz"]

        assert "dmz" not in tags_by_host["test-host-lan"]
        assert "lan" in tags_by_host["test-host-lan"]

        assert "dmz" not in tags_by_host["test-host-lan2"]
        assert "lan" in tags_by_host["test-host-lan2"]

    finally:
        web.delete_host("test-host-lan2")
        web.delete_host("test-host-lan")
        web.delete_host("test-host-dmz")