fix(pve1): task_timeout в Valves, Optional[template_vmid], исправление таймаутов ожидания задач

This commit is contained in:
2026-08-01 13:43:35 +03:00
parent 8b64877052
commit 62b0fc06e0
+9 -6
View File
@@ -43,6 +43,9 @@ class Tools:
request_timeout: int = Field(
default=30, description="HTTP request timeout in seconds"
)
task_timeout: int = Field(
default=120, description="Timeout for waiting Proxmox tasks (creation, cloning) in seconds"
)
def __init__(self):
self.valves = self.Valves()
@@ -477,7 +480,7 @@ class Tools:
out.append(f"UPID: {upid}")
if wait and upid:
out.append("Waiting for creation to finish...")
ok, msg = self._wait_for_task(upid, node=node, timeout=120)
ok, msg = self._wait_for_task(upid, node=node, timeout=self.valves.task_timeout)
out.append(" Creation done" if ok else f" WARN Creation may not have finished: {msg}")
return "\n".join(out)
except Exception as e:
@@ -615,7 +618,7 @@ class Tools:
out.append(f"UPID: {upid}")
out.append("Waiting for clone to finish...")
clone_node = target_node or node
ok, msg = self._wait_for_task(upid, node=clone_node, timeout=120)
ok, msg = self._wait_for_task(upid, node=clone_node, timeout=self.valves.task_timeout)
out.append(" Clone done" if ok else f" WARN Clone may not have finished: {msg}")
config_params = {}
if memory is not None:
@@ -662,7 +665,7 @@ class Tools:
self,
vmid: int,
name: str,
template_vmid: Optional[int] = 999,
template_vmid: Optional[int] = None,
memory: int = 4096,
cores: int = 2,
disk_size: str = "32G",
@@ -708,7 +711,7 @@ class Tools:
node = node or self.valves.default_node
bridge = bridge or self.valves.default_bridge
try:
if template_vmid:
if template_vmid is not None:
return self.pve1_vm_create_from_template(
vmid=vmid, name=name, template_vmid=template_vmid,
full=True, memory=memory, cores=cores, storage=disk_storage,
@@ -749,8 +752,8 @@ class Tools:
out.append(f"UPID: {upid}")
if wait and upid:
out.append("Waiting for creation to finish...")
ok, msg = self._wait_for_task(upid, node=node, timeout=120)
ok, msg = self._wait_for_task(upid, node=node, timeout=self.valves.task_timeout)
out.append(" Creation done" if ok else f" WARN Creation may not have finished: {msg}")
return "\n".join(out)
except Exception as e:
return "ERR " + str(e)
return "ERR " + str(e)