Phase 1 — New modules: - api/utils.py: find_uid(), uid_from_location() (replaces 2 duplicates) - operations/poll.py: poll_until_done() (shared sync/async polling) - operations/executor.py: execute_operation() (single CREATE/non-CREATE flow) Phase 2 — Format + validation: - routes/api_scenario_defs.py: _validate_steps with output/instance_ref/instance_uid - operations/scenario.py: resolve instance_uid > instance_ref > service_id, use executor + poll_until_done, persist instance_bindings Phase 3 — Migration: - routes/api_test.py: create/non-create through executor, _finish_op through poll_until_done - db/init_db.py: startup cleanup of stuck scenario_runs (>1h) Phase 4 — UI shared module: - static/js/params-render.js: renderParamRow, renderMapFixedRow, collectParams - static/js/operations.js: use params-render.js (remove duplicates) - templates/index.html: include params-render.js - app.py: bump 1.1.57 → 1.2.0
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
"""
|
||
app-autotest — точка входа Flask-приложения для автотестов Nubes.
|
||
|
||
Регистрирует три blueprint'а:
|
||
- main_bp → / (главная, токен, инфраструктура)
|
||
- api_bp → /api/run, /api/status, /api/config [LEGACY]
|
||
- api_test_bp → /api/test, /api/params, /api/log (основная логика)
|
||
|
||
Деплой: Nubes pythonk8s (gunicorn, несколько воркеров).
|
||
"""
|
||
|
||
import os
|
||
|
||
from flask import Flask
|
||
|
||
from routes.main import bp as main_bp
|
||
from routes.api_test import bp as api_test_bp
|
||
from routes.api_scenario_run import bp_run as api_scenario_run_bp
|
||
from routes.api_scenario_defs import bp_defs as api_scenario_defs_bp
|
||
|
||
# Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI.
|
||
VERSION = "1.2.0"
|
||
|
||
app = Flask(__name__, template_folder="templates", static_folder="static")
|
||
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-test.ngcloud.ru/api/v1/svc")
|
||
app.config["NUBES_API_TOKEN"] = os.getenv("NUBES_API_TOKEN", "")
|
||
app.config["VERSION"] = VERSION
|
||
app.register_blueprint(main_bp)
|
||
app.register_blueprint(api_test_bp)
|
||
app.register_blueprint(api_scenario_run_bp)
|
||
app.register_blueprint(api_scenario_defs_bp)
|
||
|
||
|
||
@app.route("/health")
|
||
def health():
|
||
return "OK"
|
||
|
||
|
||
if __name__ == "__main__":
|
||
app.run(debug=True, host="0.0.0.0", port=5000)
|