From f42d611597976e5648847bba84fa789b0c19ffd6 Mon Sep 17 00:00:00 2001 From: host Date: Sun, 9 Aug 2026 18:40:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=B0?= =?UTF-8?q?=D1=80=D1=85=D0=B8=D0=B2=D0=BD=D1=8B=D0=B5=20LXC-=D1=88=D0=B0?= =?UTF-8?q?=D0=B1=D0=BB=D0=BE=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/templates.py | 40 +++++++------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/backend/app/routers/templates.py b/backend/app/routers/templates.py index 90c25f1..039bd95 100644 --- a/backend/app/routers/templates.py +++ b/backend/app/routers/templates.py @@ -32,30 +32,12 @@ def create_template( return tpl -def _list_lxc_container_templates(node: str = None) -> list: - """Возвращает LXC-контейнеры, отмеченные в Proxmox как template=1.""" - node = node or pve.settings.pve_node - px = pve._client() - result = [] - for container in px.nodes(node).lxc.get(): - if container.get("template") != 1: - continue - vmid = int(container["vmid"]) - config = px.nodes(node).lxc(vmid).config.get() - result.append({ - "vmid": vmid, - "name": container.get("hostname") or config.get("hostname") or f"lxc-{vmid}", - "cores": int(config.get("cores", 1)), - "memory_mb": int(config.get("memory", 1024)), - "disk_gb": 8, - "source_kind": "vmid", - }) - return result - - @router.get("/from-proxmox") def list_proxmox_templates(_=Depends(require_admin)): - """Ищет VM, LXC-контейнеры и архивы LXC на Proxmox-ноде.""" + """Возвращает VM-шаблоны и архивные LXC-шаблоны с Proxmox. + + Готовые LXC-контейнеры по VMID намеренно не показываются. + """ try: vm_templates = pve.list_vm_templates() except Exception as exc: @@ -63,23 +45,17 @@ def list_proxmox_templates(_=Depends(require_admin)): vm_templates = [] try: - lxc_templates = _list_lxc_container_templates() - except Exception as exc: - logger.warning("Ошибка получения LXC-шаблонов-контейнеров из Proxmox: %s", exc) - lxc_templates = [] - - try: - archive_templates = pve.list_lxc_templates() + lxc_templates = pve.list_lxc_templates() except Exception as exc: logger.warning("Ошибка получения архивов LXC-шаблонов из Proxmox: %s", exc) - archive_templates = [] + lxc_templates = [] - for template in archive_templates: + for template in lxc_templates: template["source_kind"] = "archive" return { "vm_templates": vm_templates, - "lxc_templates": lxc_templates + archive_templates, + "lxc_templates": lxc_templates, }