fix: remove pvesm config content check — show all compatible pools, user can pick
This commit is contained in:
parent
f5755827d5
commit
b257ada9a8
1 changed files with 2 additions and 16 deletions
|
|
@ -96,14 +96,11 @@ def health() -> HealthResponse:
|
||||||
|
|
||||||
@app.get(f"{API_PREFIX}/storage/pools")
|
@app.get(f"{API_PREFIX}/storage/pools")
|
||||||
def storage_pools():
|
def storage_pools():
|
||||||
"""Return available Proxmox storage pools that support VM disk images."""
|
"""Return available Proxmox storage pools that can host VM disks."""
|
||||||
result = []
|
result = []
|
||||||
try:
|
try:
|
||||||
import subprocess
|
import subprocess
|
||||||
out = subprocess.run(["/usr/sbin/pvesm", "status"], capture_output=True, text=True, timeout=10)
|
out = subprocess.run(["/usr/sbin/pvesm", "status"], capture_output=True, text=True, timeout=10)
|
||||||
logger.info("pvesm status returned %d lines, rc=%d", len(out.stdout.split("\n")), out.returncode)
|
|
||||||
if out.stderr:
|
|
||||||
logger.warning("pvesm stderr: %s", out.stderr.strip()[:200])
|
|
||||||
for line in out.stdout.split("\n")[1:]:
|
for line in out.stdout.split("\n")[1:]:
|
||||||
parts = line.split()
|
parts = line.split()
|
||||||
if len(parts) < 3:
|
if len(parts) < 3:
|
||||||
|
|
@ -113,22 +110,11 @@ def storage_pools():
|
||||||
continue
|
continue
|
||||||
if stype not in ("lvmthin", "zfspool", "rbd", "dir", "nfs"):
|
if stype not in ("lvmthin", "zfspool", "rbd", "dir", "nfs"):
|
||||||
continue
|
continue
|
||||||
content = ""
|
|
||||||
try:
|
|
||||||
cp = subprocess.run(["/usr/sbin/pvesm", "config", name], capture_output=True, text=True, timeout=5)
|
|
||||||
for cl in cp.stdout.split("\n"):
|
|
||||||
if cl.strip().startswith("content"):
|
|
||||||
content = cl.strip().split(None, 1)[1] if len(cl.strip().split(None, 1)) > 1 else ""
|
|
||||||
logger.info(" pool %s (%s) content=%r", name, stype, content)
|
|
||||||
except Exception as exc:
|
|
||||||
logger.warning(" pvesm config %s failed: %s", name, exc)
|
|
||||||
if "images" not in content:
|
|
||||||
continue
|
|
||||||
result.append({"name": name, "type": stype})
|
result.append({"name": name, "type": stype})
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.warning("Storage pool discovery failed: %s", exc)
|
logger.warning("Storage pool discovery failed: %s", exc)
|
||||||
|
|
||||||
logger.info("Storage pools found: %s", [p["name"] for p in result])
|
logger.info("Storage pools: %s", [p["name"] for p in result])
|
||||||
return {"pools": result}
|
return {"pools": result}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue