Реализовано создание LXC из CTID-шаблона

This commit is contained in:
2026-08-09 16:44:23 +03:00
parent 9fd8d92abb
commit ce062972f4
+3 -1
View File
@@ -64,7 +64,9 @@ def provision_lxc_clone(source_vmid: int, vmid: int, name: str, cores: int, memo
def provision_lxc(source_template: str, vmid: int, name: str, cores: int, memory_mb: int, disk_gb: int, password: str) -> None:
"""Создаёт LXC из архивного CT-шаблона и запускает его."""
"""Создаёт LXC из архива или клонирует LXC-шаблон по внутреннему vmid:ID."""
if source_template.startswith("vmid:"):
return provision_lxc_clone(int(source_template.split(":", 1)[1]), vmid, name, cores, memory_mb, disk_gb, password)
client = _client(); node = settings.pve_node
upid = client.nodes(node).lxc.post(vmid=vmid, hostname=name, ostemplate=source_template, cores=cores, memory=memory_mb, swap=memory_mb, rootfs=f"{settings.pve_lxc_storage}:{disk_gb}", password=password, net0=f"name=eth0,bridge={settings.pve_bridge},ip=dhcp", unprivileged=1)
_wait_task(client, node, upid)