fix(pve1): task_timeout в Valves, Optional[template_vmid], исправление таймаутов ожидания задач
This commit is contained in:
@@ -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,7 +752,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:
|
||||
|
||||
Reference in New Issue
Block a user