v1.0.82: _get_instance_display_name() — fetch real name from API for non-create
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ from routes.main import bp as main_bp
|
|||||||
from routes.api import bp as api_bp
|
from routes.api import bp as api_bp
|
||||||
from routes.api_test import bp as api_test_bp
|
from routes.api_test import bp as api_test_bp
|
||||||
|
|
||||||
VERSION = "1.0.81"
|
VERSION = "1.0.82"
|
||||||
|
|
||||||
app = Flask(__name__, template_folder="templates", static_folder="static")
|
app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||||
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc")
|
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc")
|
||||||
|
|||||||
+13
-1
@@ -242,7 +242,9 @@ def api_test():
|
|||||||
|
|
||||||
# фоном ждать завершения
|
# фоном ждать завершения
|
||||||
is_delete = (op_name == "delete")
|
is_delete = (op_name == "delete")
|
||||||
display_name = display_name or instance_uid or f"instance-{svc_id}"
|
# Получить реальное имя инстанса из API (не UUID!)
|
||||||
|
if not display_name:
|
||||||
|
display_name = _get_instance_display_name(client, instance_uid)
|
||||||
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, False, is_delete), daemon=True).start()
|
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, False, is_delete), daemon=True).start()
|
||||||
return jsonify({"status": "RUNNING", "opUid": op_uid, "instanceUid": instance_uid, "displayName": display_name})
|
return jsonify({"status": "RUNNING", "opUid": op_uid, "instanceUid": instance_uid, "displayName": display_name})
|
||||||
|
|
||||||
@@ -255,6 +257,16 @@ def api_test():
|
|||||||
_op_results = {}
|
_op_results = {}
|
||||||
|
|
||||||
|
|
||||||
|
def _get_instance_display_name(client, instance_uid):
|
||||||
|
"""Получить displayName инстанса из GET /instances/{uid}."""
|
||||||
|
try:
|
||||||
|
data = client.get(f"/instances/{instance_uid}")
|
||||||
|
name = data.get("instance", {}).get("displayName", "")
|
||||||
|
return name or instance_uid # fallback — UUID если имя пустое
|
||||||
|
except Exception:
|
||||||
|
return instance_uid
|
||||||
|
|
||||||
|
|
||||||
def _finish_op(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, is_create, is_delete=False):
|
def _finish_op(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, is_create, is_delete=False):
|
||||||
"""Фоном ждать dtFinish и сохранить результат."""
|
"""Фоном ждать dtFinish и сохранить результат."""
|
||||||
import time
|
import time
|
||||||
|
|||||||
Reference in New Issue
Block a user