Fix: main.py /api/operations now returns tracked instances, v1.0.38
This commit is contained in:
+9
-1
@@ -3,6 +3,7 @@ from flask import Blueprint, current_app, render_template, request, make_respons
|
||||
from api.http_client import HttpClient
|
||||
from operations.get_instances import get_organization, get_instances
|
||||
from operations.get_services import get_services, get_service_detail
|
||||
from operations.tracker import list_all as tracker_list
|
||||
from runner import load_config
|
||||
|
||||
bp = Blueprint("main", __name__)
|
||||
@@ -118,6 +119,13 @@ def api_operations(svc_id):
|
||||
client = HttpClient(current_app.config["NUBES_API_ENDPOINT"], active_token)
|
||||
detail = get_service_detail(client, svc_id)
|
||||
ops = detail.get("operations", [])
|
||||
return jsonify({"svc": detail.get("svc", ""), "operations": ops})
|
||||
# только отслеживаемые инстансы этого сервиса
|
||||
tracked = tracker_list()
|
||||
tracked_uids = {t["instanceUid"] for t in tracked if t["svcId"] == svc_id}
|
||||
instances = get_instances(client)
|
||||
svc_instances = [i for i in instances
|
||||
if i.get("instanceUid") in tracked_uids
|
||||
and i.get("explainedStatus") not in ("deleted", "not created")]
|
||||
return jsonify({"svc": detail.get("svc", ""), "operations": ops, "instances": svc_instances})
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
Reference in New Issue
Block a user