feat: add automatic template resolution for debian-13 alias
This commit is contained in:
parent
0dfaadab20
commit
42767fd8bc
2 changed files with 17 additions and 3 deletions
|
|
@ -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}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue