v1.1.14: serviceId filter, svcShort displayName, descr, remove duplicate endpoint
This commit is contained in:
+2
-34
@@ -115,39 +115,6 @@ def api_instances_list():
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/api/operations/<int:svc_id>")
|
||||
def api_operations(svc_id):
|
||||
try:
|
||||
detail = get_service_detail(get_client(), svc_id)
|
||||
ops = detail.get("operations", [])
|
||||
# только отслеживаемые инстансы этого сервиса
|
||||
tracked = tracker_list(get_client_id(), get_stand())
|
||||
tracked_by_uid = {t["instanceUid"]: t for t in tracked if t["svcId"] == svc_id}
|
||||
tracked_uids = set(tracked_by_uid.keys())
|
||||
instances = get_instances(get_client())
|
||||
nubes_uids = {i["instanceUid"] for i in instances}
|
||||
svc_instances = [i for i in instances
|
||||
if i.get("instanceUid") in tracked_uids
|
||||
and i.get("explainedStatus") not in ("deleted",)]
|
||||
# Добавить tracked инстансы, которых Nubes ещё не отдаёт (creating)
|
||||
for uid, t in tracked_by_uid.items():
|
||||
if uid not in nubes_uids:
|
||||
svc_instances.append({
|
||||
"instanceUid": uid,
|
||||
"displayName": t["displayName"],
|
||||
"serviceId": svc_id,
|
||||
"svc": detail.get("svc", ""),
|
||||
"explainedStatus": "creating",
|
||||
})
|
||||
return jsonify({
|
||||
"svc": detail.get("svc", ""),
|
||||
"operations": [{"svcOperationId": o["svcOperationId"], "operation": o["operation"]} for o in ops],
|
||||
"instances": svc_instances,
|
||||
})
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/api/params/<int:op_id>")
|
||||
def api_params(op_id):
|
||||
"""Параметры операции. Если передан instanceUid — с текущими значениями из API."""
|
||||
@@ -209,7 +176,8 @@ def api_test():
|
||||
if not display_name:
|
||||
display_name = f"autotest-{svc_id}"
|
||||
display_name = _unique_display_name(client, display_name)
|
||||
payload = {"serviceId": svc_id, "displayName": display_name, "descr": ""}
|
||||
descr = f"created by autotest v{current_app.config.get('VERSION', '')}"
|
||||
payload = {"serviceId": svc_id, "displayName": display_name, "descr": descr}
|
||||
resp = client.post("/instances", payload)
|
||||
instance_uid = resp.get("instanceUid") or _find_uid(resp) or _uid_from_location(resp.get("_location", ""))
|
||||
if not instance_uid:
|
||||
|
||||
@@ -194,6 +194,8 @@ def api_operations(svc_id):
|
||||
display_name = str(i.get("displayName", "") or "")
|
||||
if not display_name.startswith(AUTOTEST_PREFIX):
|
||||
continue # не наш инстанс
|
||||
if i.get("serviceId") != svc_id:
|
||||
continue # не нашего сервиса
|
||||
if i.get("explainedStatus") in ("deleted",):
|
||||
continue # удалённые не показываем
|
||||
item = dict(i)
|
||||
@@ -220,6 +222,7 @@ def api_operations(svc_id):
|
||||
|
||||
return jsonify({
|
||||
"svc": detail.get("svc", ""),
|
||||
"svcShort": detail.get("svcShort", ""),
|
||||
"operations": ops, # [{svcOperationId, operation}, ...]
|
||||
"instances": svc_instances, # [{instanceUid, displayName, status, ...}, ...]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user