v1.1.31: CMDB hard delete + fix _resolve_ref_svc params update
This commit is contained in:
@@ -117,3 +117,13 @@ class HttpClient:
|
|||||||
# Location бывает вида "./UUID" или "/api/v1/svc/instanceOperations/UUID"
|
# Location бывает вида "./UUID" или "/api/v1/svc/instanceOperations/UUID"
|
||||||
result["_location"] = loc
|
result["_location"] = loc
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def raw_delete(self, url):
|
||||||
|
"""DELETE-запрос к произвольному URL (CMDB API).
|
||||||
|
Не добавляет Nubes-эндпоинт — используется для жёсткого удаления инстансов.
|
||||||
|
Возвращает True если 2xx, иначе False."""
|
||||||
|
try:
|
||||||
|
r = self._session.delete(url, timeout=10)
|
||||||
|
return r.ok
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ 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
|
||||||
|
|
||||||
# Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI.
|
# Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI.
|
||||||
VERSION = "1.1.30"
|
VERSION = "1.1.31"
|
||||||
|
|
||||||
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-test.ngcloud.ru/api/v1/svc")
|
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-test.ngcloud.ru/api/v1/svc")
|
||||||
|
|||||||
@@ -214,6 +214,12 @@ def api_test():
|
|||||||
if not instance_uid:
|
if not instance_uid:
|
||||||
return jsonify({"status": "FAIL", "error": "Нет instanceUid"}), 400
|
return jsonify({"status": "FAIL", "error": "Нет instanceUid"}), 400
|
||||||
|
|
||||||
|
if op_name == "delete":
|
||||||
|
# Жёсткое удаление через CMDB (без авторизации) — для недосозданных инстансов
|
||||||
|
cmdb_url = f"https://cmdb-api.deck.nubes.ru/instances/{instance_uid}"
|
||||||
|
if client.raw_delete(cmdb_url):
|
||||||
|
return jsonify({"status": "OK", "opUid": "cmdb-"+instance_uid[:8], "instanceUid": instance_uid, "displayName": display_name})
|
||||||
|
|
||||||
if op_name == "redeploy":
|
if op_name == "redeploy":
|
||||||
op_payload = {"instanceUid": instance_uid, "svcOperationId": svc_op_id, "operation": op_name}
|
op_payload = {"instanceUid": instance_uid, "svcOperationId": svc_op_id, "operation": op_name}
|
||||||
op_resp = client.post("/instanceOperations", op_payload)
|
op_resp = client.post("/instanceOperations", op_payload)
|
||||||
@@ -312,7 +318,7 @@ def _resolve_ref_svc(client, cfs_params, params):
|
|||||||
match = next((i for i in instances if i.get("serviceId") == ref_id and i.get("explainedStatus") not in ("deleted",)), None)
|
match = next((i for i in instances if i.get("serviceId") == ref_id and i.get("explainedStatus") not in ("deleted",)), None)
|
||||||
if match:
|
if match:
|
||||||
user_val[sk] = match["instanceUid"]
|
user_val[sk] = match["instanceUid"]
|
||||||
if user_val and pid in params:
|
if user_val:
|
||||||
params[pid] = json.dumps(user_val)
|
params[pid] = json.dumps(user_val)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user