fester/backend/nodes_cli.py

44 lines
936 B
Python
Executable File

import json
import requests
from backend.config import CONFIG, EXTERNAL_CONFIG
from backend.scheduler import build_distcc_hosts
# F-06: AGENT_PORT is now env-var driven (FESTER_AGENT_PORT).
AGENT_PORT = EXTERNAL_CONFIG["agent_port"]
def fetch_agent(node):
try:
r = requests.get(f"http://{node['host']}:{AGENT_PORT}/status", timeout=1.5)
return r.json()
except Exception:
return None
def enrich(node):
agent = fetch_agent(node)
return {
"name": node["name"],
"host": node["host"],
"state": "online" if agent else "offline",
"agent": agent,
"release_ready": agent is not None
}
def main():
nodes = [enrich(n) for n in CONFIG["nodes"]]
output = {
"master": CONFIG["master"],
"nodes": nodes,
"distcc": build_distcc_hosts(nodes)
}
print(json.dumps(output, indent=2))
if __name__ == "__main__":
main()