From 42767fd8bc3b669c84c47faccae23b301d96edbd Mon Sep 17 00:00:00 2001 From: Fredrick Amnehagen Date: Thu, 5 Feb 2026 19:53:18 +0100 Subject: [PATCH] feat: add automatic template resolution for debian-13 alias --- README.md | 4 ++-- infra_cli/proxmox.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5bac3d1..93df3f7 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@ infra samba add-to-group "xmpp-users" "jdoe" # List containers on a specific node infra proxmox list-lxcs --node la-vmh-12 -# Create a new container -infra proxmox create-lxc 12150 local:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst "new-app" "10.32.70.100/16" "10.32.0.1" --node la-vmh-12 +# Create a new container (CLI resolves "debian-13" automatically) +infra proxmox create-lxc 12150 debian-13 "new-app" "10.32.70.100/16" "10.32.0.1" --node la-vmh-12 ``` ### 3. Database (PostgreSQL) diff --git a/infra_cli/proxmox.py b/infra_cli/proxmox.py index bd4ada7..6abfccb 100644 --- a/infra_cli/proxmox.py +++ b/infra_cli/proxmox.py @@ -25,11 +25,25 @@ class ProxmoxManager: res = self.client.run(f"pct status {vmid}") return res.stdout + def resolve_template(self, alias): + """Resolves a template alias (e.g. 'debian-13') to the latest full path on the node""" + if alias == "debian-13": + # Search for debian-13 templates in all storages + res = self.client.run("pvesm list --content vztmpl | grep 'debian-13-standard' | sort -V | tail -n 1") + if res.returncode == 0 and res.stdout.strip(): + # Extract first column (Volid) + return res.stdout.split()[0] + return alias # Fallback to original if no resolution + def create_lxc(self, vmid, template, hostname, ip, gateway, bridge="vmbr0", storage="local-zfs", password=None): + # Resolve template if it's an alias + full_template = self.resolve_template(template) + # Professional creation command with sane defaults - cmd = f"pct create {vmid} {template} --hostname {hostname} " \ + cmd = f"pct create {vmid} {full_template} --hostname {hostname} " \ f"--net0 name=eth0,bridge={bridge},ip={ip},gw={gateway} " \ f"--storage {storage} --onboot 1" + if password: cmd += f" --password {password}"