Hide empty server slots (0.0.0.0) from list_servers output

Only show servers with actual IP addresses. Empty slots are
HAProxy pre-allocated placeholders that add noise to the output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-02-08 12:13:25 +09:00
parent 1be615be99
commit 0084b99f05
2 changed files with 6 additions and 4 deletions

View File

@@ -73,9 +73,12 @@ def _haproxy_list_servers_impl(domain: str) -> str:
for server_name, srv_info in backend_servers.items():
addr = srv_info["addr"]
port = srv_info["port"]
status = "active" if addr != "0.0.0.0" else "disabled"
servers.append(f"{server_name}: {addr}:{port} ({status})")
if addr == "0.0.0.0":
continue
servers.append(f"{server_name}: {addr}:{port}")
if not servers:
return f"No active servers for {domain} ({backend})"
return f"Servers for {domain} ({backend}):\n" + "\n".join(servers)
except (HaproxyError, ValueError) as e:
return f"Error: {e}"