Remove automatic agent update workflow

This commit is contained in:
2025-10-04 20:36:19 -06:00
parent 777b1173eb
commit d94ce9be3a
3 changed files with 1 additions and 317 deletions

View File

@@ -3126,67 +3126,6 @@ def scripts_quick_run():
return jsonify({"results": results})
@app.route("/api/agents/silent_update", methods=["POST"])
def agent_silent_update():
"""Request connected agents to run the Borealis silent update workflow."""
data = request.get_json(silent=True) or {}
raw_hosts = data.get("hostnames")
if not isinstance(raw_hosts, list):
return jsonify({"error": "hostnames[] must be provided"}), 400
hostnames: List[str] = []
seen: Set[str] = set()
for entry in raw_hosts:
name = str(entry or "").strip()
if not name:
continue
key = name.lower()
if key in seen:
continue
seen.add(key)
hostnames.append(name)
if not hostnames:
return jsonify({"error": "No valid hostnames provided"}), 400
request_id = uuid.uuid4().hex
now_ts = int(time.time())
results: List[Dict[str, Any]] = []
# Map hostname -> connected agent_id(s) so we can target specific rooms.
host_to_agents: Dict[str, List[str]] = {}
for agent_id, info in (registered_agents or {}).items():
try:
hostname = str(info.get("hostname") or "").strip().lower()
except Exception:
hostname = ""
if not hostname:
continue
host_to_agents.setdefault(hostname, []).append(agent_id)
for host in hostnames:
payload = {
"target_hostname": host,
"request_id": request_id,
"requested_at": now_ts,
}
target_agents = host_to_agents.get(host.strip().lower(), [])
if target_agents:
for agent_id in target_agents:
socketio.emit("agent_silent_update", payload, room=agent_id)
else:
# Fallback broadcast for legacy agents or if hostname lookup failed.
socketio.emit("agent_silent_update", payload)
results.append({"hostname": host, "status": "queued", "agent_ids": target_agents})
_write_service_log(
"server",
f"[silent_update] request_id={request_id} dispatched to {len(hostnames)} host(s): {', '.join(hostnames)}",
)
return jsonify({"results": results, "request_id": request_id})
@app.route("/api/ansible/quick_run", methods=["POST"])
def ansible_quick_run():
"""Queue an Ansible Playbook Quick Job via WebSocket to targeted agents.
@@ -3356,27 +3295,6 @@ def handle_quick_job_result(data):
print(f"[ERROR] quick_job_result DB update failed for job {job_id}: {e}")
@socketio.on("agent_silent_update_status")
def handle_agent_silent_update_status(data):
try:
hostname = str(data.get("hostname") or "").strip()
status = str(data.get("status") or "").strip() or "unknown"
request_id = str(data.get("request_id") or "").strip()
error = str(data.get("error") or "").strip()
message_parts = [
"[silent_update_status]",
f"host={hostname or 'unknown'}",
f"status={status}",
]
if request_id:
message_parts.append(f"request_id={request_id}")
if error:
message_parts.append(f"error={error}")
_write_service_log("server", " ".join(message_parts))
except Exception:
pass
# ---------------------------------------------
# Ansible Runtime API (Play Recaps)
# ---------------------------------------------