cat > /tmp/iso_diag.py <<'PYEOF'
import asyncio, time, httpx
import vsphere_datastore_files as dsf
ds, dc = dsf.ISO_DATASTORE, dsf.VSPHERE_DATACENTER
print(f"DS={ds} DC={dc} user=Gold_Imager")
async def put_tiny(remote, n=1024):
async def body():
yield b"x"*n
return await dsf.stream_put_iso(body(), n, remote)
async def http_delete(remote):
cookie = dsf.get_datastore_session_cookie()
url = dsf._folder_url(remote, ds, dc)
async with httpx.AsyncClient(verify=False, timeout=60) as c:
r = await c.delete(url, headers={"Cookie": cookie})
return r.status_code
# A) PUT -> СРАЗУ SOAP delete (точный падающий сценарий), при сбое ретрай через 5с
try: print("A PUT:", asyncio.run(put_tiny("ISO/diag-a.iso")))
except Exception as e: print("A PUT FAILED:", repr(e))
try:
dsf.delete_datastore_file("ISO/diag-a.iso"); print("A SOAP DELETE immediate: OK")
except Exception as e:
print("A SOAP DELETE immediate FAILED:", repr(e)); time.sleep(5)
try: dsf.delete_datastore_file("ISO/diag-a.iso"); print("A SOAP DELETE after 5s: OK")
except Exception as e2: print("A SOAP DELETE after 5s FAILED:", repr(e2))
# B) SOAP move (путь переименования tmp->final)
try: print("B PUT:", asyncio.run(put_tiny("ISO/diag-b-src.iso")))
except Exception as e: print("B PUT FAILED:", repr(e))
try: dsf.rename_datastore_file("ISO/diag-b-src.iso","ISO/diag-b-dst.iso"); print("B SOAP MOVE: OK")
except Exception as e: print("B SOAP MOVE FAILED:", repr(e))
# C) HTTP delete (другой канал) + чистка
for f in ("ISO/diag-a.iso","ISO/diag-b-src.iso","ISO/diag-b-dst.iso"):
try: print("HTTP DELETE", f, asyncio.run(http_delete(f)))
except Exception as e: print("HTTP DELETE", f, "err", repr(e))
PYEOF