From 17c9c875e492956d3394aa5bdc4d983df06605b4 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 16 Jun 2026 21:20:11 -0400 Subject: [PATCH] refactor(hosts): remove legacy host_agent redirects/paths (no back-compat) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dev-only instance, no bookmarks — per family rule 22, fully remove old paths instead of shimming them. - Delete the /plugins/host_agent/ (index) and /plugins/host_agent/settings/ redirect routes; delete the now-dead host_list.html fleet template. - Move the remaining management POST routes off /settings/ to /fleet/ (add-host, rotate-token, delete) — single canonical prefix. - Repoint real callers to canonical URLs: dashboard widgets (host resources → /hosts/, history → /plugins/host_agent/fleet/), the full-metrics page breadcrumb + back link (→ the host hub), Settings→Ansible link, and the agent panel's curl-install link. Co-Authored-By: Claude Opus 4.8 (1M context) --- plugins/host_agent/routes.py | 21 ++------- plugins/host_agent/templates/host_detail.html | 4 +- plugins/host_agent/templates/host_list.html | 45 ------------------- plugins/host_agent/templates/panel.html | 6 +-- .../host_agent/templates/settings_list.html | 6 +-- steward/core/widgets.py | 4 +- steward/templates/settings/ansible.html | 2 +- 7 files changed, 14 insertions(+), 74 deletions(-) delete mode 100644 plugins/host_agent/templates/host_list.html diff --git a/plugins/host_agent/routes.py b/plugins/host_agent/routes.py index c15f177..ab88034 100644 --- a/plugins/host_agent/routes.py +++ b/plugins/host_agent/routes.py @@ -372,14 +372,6 @@ async def _fleet_rows(session) -> list[dict]: return rows -@host_agent_bp.get("/") -@require_role(UserRole.viewer) -async def index(): - """The fleet view folded into the Hosts hub — kept as a redirect so old - links/widgets don't 404.""" - return redirect("/hosts/") - - @host_agent_bp.get("/widget") async def widget_table(): """Fleet-glance dashboard widget: one row per monitored host, latest metrics.""" @@ -568,13 +560,6 @@ async def host_panel(host_id: str): ) -@host_agent_bp.get("/settings/") -@require_role(UserRole.admin) -async def settings_redirect(): - """Old management URL — agent management moved into the Hosts section.""" - return redirect(url_for("host_agent.fleet")) - - @host_agent_bp.get("/fleet/") @require_role(UserRole.admin) async def fleet(): @@ -618,7 +603,7 @@ async def fleet(): ) -@host_agent_bp.post("/settings/add-host") +@host_agent_bp.post("/fleet/add-host") @require_role(UserRole.admin) async def add_host(): form = await request.form @@ -650,7 +635,7 @@ async def add_host(): return redirect(url_for("host_agent.fleet") + f"?new_token={raw}&host_id={host_id}") -@host_agent_bp.post("/settings//rotate-token") +@host_agent_bp.post("/fleet//rotate-token") @require_role(UserRole.admin) async def rotate_token(host_id: str): async with current_app.db_sessionmaker() as session: @@ -666,7 +651,7 @@ async def rotate_token(host_id: str): return redirect(url_for("host_agent.fleet") + f"?new_token={raw}&host_id={host_id}") -@host_agent_bp.post("/settings//delete") +@host_agent_bp.post("/fleet//delete") @require_role(UserRole.admin) async def delete_registration(host_id: str): async with current_app.db_sessionmaker() as session: diff --git a/plugins/host_agent/templates/host_detail.html b/plugins/host_agent/templates/host_detail.html index 55a0cc3..c34fda9 100644 --- a/plugins/host_agent/templates/host_detail.html +++ b/plugins/host_agent/templates/host_detail.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% from "_macros.html" import crumbs %} {% block title %}{{ host.name }} — Host Agent — Steward{% endblock %} -{% block breadcrumb %}{{ crumbs([("Host Agents", "/plugins/host_agent/"), (host.name, "")]) }}{% endblock %} +{% block breadcrumb %}{{ crumbs([("Hosts", "/hosts/"), (host.name, "/hosts/" ~ host.id), ("Metrics", "")]) }}{% endblock %} {% macro fmt_bps(v) %} {%- if v is none -%}— @@ -27,7 +27,7 @@ {% block content %}
- ← Fleet + ← Host

{{ host.name }}

{% if stale %}stale{% else %}live{% endif %}
diff --git a/plugins/host_agent/templates/host_list.html b/plugins/host_agent/templates/host_list.html deleted file mode 100644 index 79d63a0..0000000 --- a/plugins/host_agent/templates/host_list.html +++ /dev/null @@ -1,45 +0,0 @@ -{% extends "base.html" %} -{% from "_macros.html" import crumbs %} -{% block title %}Host Agents — Steward{% endblock %} -{% block breadcrumb %}{{ crumbs([("Dashboard", "/"), ("Host Agents", "")]) }}{% endblock %} -{% block content %} -
-

Host Agents

- {% if session.user_role == 'admin' %} - Manage agents → - {% endif %} -
- -{% if not rows %} -
- No hosts are reporting agent metrics yet. - {% if session.user_role == 'admin' %} - Add one from Host Agent settings and run the install command on the target. - {% else %} - Ask an admin to install the agent on a host. - {% endif %} -
-{% else %} - -{% endif %} -{% endblock %} diff --git a/plugins/host_agent/templates/panel.html b/plugins/host_agent/templates/panel.html index 6391d19..4e8cc5c 100644 --- a/plugins/host_agent/templates/panel.html +++ b/plugins/host_agent/templates/panel.html @@ -37,11 +37,11 @@ {% endif %} -
-
@@ -65,7 +65,7 @@ {% elif not ansible_available %}

Ansible isn't available, so the agent can't be deployed from here. Install it manually with the - curl install command. + curl install command.

{% elif not managed_key_set %} diff --git a/plugins/host_agent/templates/settings_list.html b/plugins/host_agent/templates/settings_list.html index 866cad4..80c027f 100644 --- a/plugins/host_agent/templates/settings_list.html +++ b/plugins/host_agent/templates/settings_list.html @@ -23,7 +23,7 @@ {% endif %}
-
@@ -155,12 +155,12 @@ {{ item.reg.distro or "—" }} {{ item.reg.last_seen_at.strftime("%Y-%m-%d %H:%M:%S") if item.reg.last_seen_at else "never" }} - -
diff --git a/steward/core/widgets.py b/steward/core/widgets.py index 3b7740e..d637f1f 100644 --- a/steward/core/widgets.py +++ b/steward/core/widgets.py @@ -262,7 +262,7 @@ WIDGET_REGISTRY: dict[str, dict] = { "label": "Host Agent — Resources", "description": "Fleet view: CPU, memory, disk, and load per monitored host", "hx_url": "/plugins/host_agent/widget", - "detail_url": "/plugins/host_agent/", + "detail_url": "/hosts/", "plugin": "host_agent", "poll": True, "params": [], @@ -272,7 +272,7 @@ WIDGET_REGISTRY: dict[str, dict] = { "label": "Host Agent — History", "description": "CPU/memory/disk history for one host", "hx_url": "/plugins/host_agent/widget/history", - "detail_url": "/plugins/host_agent/settings/", + "detail_url": "/plugins/host_agent/fleet/", "plugin": "host_agent", "poll": True, "params": [ diff --git a/steward/templates/settings/ansible.html b/steward/templates/settings/ansible.html index 2bf1611..dd1021f 100644 --- a/steward/templates/settings/ansible.html +++ b/steward/templates/settings/ansible.html @@ -29,7 +29,7 @@ Steward's reusable Ansible identity. Provisioning installs the public key into each host's {{ ssh_user }} account; steady-state runs authenticate with the private half (stored encrypted). Generate it once, then provision hosts from - Host Agents. + Host Agents.

{% if ssh_public_key %}