fix(snapshot): message d erreur distingue login KO de VM non trouvee (etait trompeur)
This commit is contained in:
parent
f1baae9c8e
commit
a006e3f422
@ -164,21 +164,40 @@ def snapshot_server(hostname, vm_name, branch, db, snap_name=None):
|
|||||||
if not vcenters:
|
if not vcenters:
|
||||||
return {"ok": False, "vcenter": "", "detail": "Aucun vCenter actif configure", "skipped": True}
|
return {"ok": False, "vcenter": "", "detail": "Aucun vCenter actif configure", "skipped": True}
|
||||||
|
|
||||||
|
login_failures = []
|
||||||
|
not_found_on = []
|
||||||
for vc in vcenters:
|
for vc in vcenters:
|
||||||
si = _connect_vcenter(vc.endpoint, vc_user, vc_pass)
|
si = _connect_vcenter(vc.endpoint, vc_user, vc_pass)
|
||||||
if not si:
|
if not si:
|
||||||
|
login_failures.append(vc.name)
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
vm = _find_vm(si, search_name)
|
vm = _find_vm(si, search_name)
|
||||||
if vm:
|
if vm:
|
||||||
ok, msg = _take_snapshot(vm, snap_name,
|
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}
|
return {"ok": ok, "vcenter": vc.name, "detail": msg}
|
||||||
|
not_found_on.append(vc.name)
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
Disconnect(si)
|
Disconnect(si)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
tried = ", ".join(vc.name for vc in vcenters)
|
# Tous les vCenters épuisés sans match → message précis
|
||||||
return {"ok": False, "vcenter": "", "detail": f"VM '{search_name}' non trouvee sur: {tried}"}
|
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)}"}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user