fix: hide synthetic rtt history keys from plugin accordion list
This commit is contained in:
+11
-1
@@ -210,6 +210,16 @@ def _mask_config_for_api(config) -> dict:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def _visible_plugin_names(plugin_data: dict) -> list:
|
||||||
|
"""Plugin names to render as accordion sections.
|
||||||
|
|
||||||
|
Excludes synthetic rtt_ipv4 / rtt_ipv6 history streams (written by
|
||||||
|
udp.py for charting) which aren't real client plugins and have no
|
||||||
|
accordion renderer.
|
||||||
|
"""
|
||||||
|
return [p for p in plugin_data.keys() if not p.startswith("rtt_")]
|
||||||
|
|
||||||
|
|
||||||
def _build_host_info(host, threshold_checker=None) -> dict:
|
def _build_host_info(host, threshold_checker=None) -> dict:
|
||||||
"""Assemble the info payload for GET /api/0/hosts/{hostname}/info."""
|
"""Assemble the info payload for GET /api/0/hosts/{hostname}/info."""
|
||||||
hbc_version = None
|
hbc_version = None
|
||||||
@@ -767,7 +777,7 @@ async def start(
|
|||||||
if host.plugin_data:
|
if host.plugin_data:
|
||||||
hosts_with_plugins.append({
|
hosts_with_plugins.append({
|
||||||
"name": hostname,
|
"name": hostname,
|
||||||
"plugins": list(host.plugin_data.keys()),
|
"plugins": _visible_plugin_names(host.plugin_data),
|
||||||
"is_owner": _can_own_host(current_user, host),
|
"is_owner": _can_own_host(current_user, host),
|
||||||
"owner": host.owner,
|
"owner": host.owner,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
"""Tests for the plugin-accordion visibility filter in http.py."""
|
||||||
|
from hbd.server.http import _visible_plugin_names
|
||||||
|
|
||||||
|
|
||||||
|
def test_visible_plugin_names_excludes_rtt_history_keys():
|
||||||
|
plugin_data = {
|
||||||
|
"cpu_monitor": [],
|
||||||
|
"rtt_ipv4": [],
|
||||||
|
"rtt_ipv6": [],
|
||||||
|
"network_monitor": [],
|
||||||
|
}
|
||||||
|
result = _visible_plugin_names(plugin_data)
|
||||||
|
assert sorted(result) == ["cpu_monitor", "network_monitor"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_visible_plugin_names_empty_when_no_plugins():
|
||||||
|
assert _visible_plugin_names({}) == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_visible_plugin_names_keeps_names_not_prefixed_with_rtt_():
|
||||||
|
plugin_data = {"nagios_runner": [], "os_info": []}
|
||||||
|
result = _visible_plugin_names(plugin_data)
|
||||||
|
assert sorted(result) == ["nagios_runner", "os_info"]
|
||||||
Reference in New Issue
Block a user