From a006e3f4220d69a579e36dc42bb2d6554eeb0d2c Mon Sep 17 00:00:00 2001 From: Admin MPCZ Date: Mon, 4 May 2026 16:25:10 +0200 Subject: [PATCH] fix(snapshot): message d erreur distingue login KO de VM non trouvee (etait trompeur) --- app/services/quickwin_snapshot_service.py | 25 ++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/app/services/quickwin_snapshot_service.py b/app/services/quickwin_snapshot_service.py index 6ef3575..1adecc3 100644 --- a/app/services/quickwin_snapshot_service.py +++ b/app/services/quickwin_snapshot_service.py @@ -164,21 +164,40 @@ def snapshot_server(hostname, vm_name, branch, db, snap_name=None): if not vcenters: return {"ok": False, "vcenter": "", "detail": "Aucun vCenter actif configure", "skipped": True} + login_failures = [] + not_found_on = [] for vc in vcenters: si = _connect_vcenter(vc.endpoint, vc_user, vc_pass) if not si: + login_failures.append(vc.name) continue try: vm = _find_vm(si, search_name) if vm: ok, msg = _take_snapshot(vm, snap_name, - description=f"QuickWin auto-snapshot {hostname}") + description=f"PatchCenter snapshot {hostname}") return {"ok": ok, "vcenter": vc.name, "detail": msg} + not_found_on.append(vc.name) finally: try: Disconnect(si) except Exception: pass - tried = ", ".join(vc.name for vc in vcenters) - return {"ok": False, "vcenter": "", "detail": f"VM '{search_name}' non trouvee sur: {tried}"} + # Tous les vCenters épuisés sans match → message précis + if login_failures and not not_found_on: + return { + "ok": False, "vcenter": "", + "detail": (f"Échec login sur tous les vCenters ({', '.join(login_failures)}). " + "Vérifier vsphere_user/vsphere_pass dans Settings > vSphere " + "(format attendu : user@vsphere.local ou DOMAIN\\\\user)."), + "skipped": True, + } + if login_failures: + return { + "ok": False, "vcenter": "", + "detail": (f"VM '{search_name}' non trouvée sur {', '.join(not_found_on)} ; " + f"login KO sur {', '.join(login_failures)}"), + } + return {"ok": False, "vcenter": "", + "detail": f"VM '{search_name}' non trouvée sur : {', '.join(not_found_on)}"}