Files
Sergey Antropoff 48df10b17e Prepare 0.1.0 for lab release: durable handlers, HTTP Compose, CI, and pulumi-tests.
- Harden DB-backed handlers and seed profiles; align client wire shapes for
  cluster resources, QEMU config, and node SSL fields
- Serve plain HTTP on Compose :8006; keep TLS optional (--profile tls) and
  terminate HTTPS at Kubernetes Ingress
- Add pulumi-tests (full contract surface majors 6–9 + BPG lifecycle) and
  make pulumi-tests
- Ship bilingual docs, CHANGELOG, SECURITY, CONTRIBUTING, and GitHub Actions
  (make ci + Compose/Helm validation)
2026-07-18 04:18:05 +03:00

44 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Delete leftover test guests whose names start with the configured prefix."""
from __future__ import annotations
import os
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(HERE / "pulumi"))
from pvelib.api import Pve # noqa: E402
def main() -> int:
prefix = os.environ.get("TEST_RESOURCE_PREFIX", "hx")
deleted = 0
with Pve() as pve:
for kind, delete in (
("qemu", pve.delete_vm),
("lxc", pve.delete_lxc),
):
items = pve.req("GET", f"/nodes/{pve.node}/{kind}")
if not isinstance(items, list):
continue
for item in items:
name = str(item.get("name") or item.get("hostname") or "")
vmid = int(item["vmid"])
if not name.startswith(prefix):
continue
try:
delete(vmid)
deleted += 1
print(f"deleted {kind} vmid={vmid} name={name}")
except Exception as exc: # noqa: BLE001
print(f"skip {kind} vmid={vmid}: {exc}", file=sys.stderr)
print(f"cleanup complete: deleted={deleted}")
return 0
if __name__ == "__main__":
raise SystemExit(main())