fix(lxc): preserve credentials and IP across reinstall

Three related fixes so login/password/SSH key/IP survive a reinstall:

1. backend/app/api/proxmox/lxc.py — on initial LXC deploy save
   cloud_init_user='root' and cloud_init_password=req.password to VMInstance
   (previously both were None, so reinstall could not restore root password).

2. backend/app/api/proxmox/async_ops.py — _do_reinstall_sync passes
   cached.cloud_init_password to create_lxc_container so the new container
   gets the same root password as the original.

3. backend/app/workers/monitoring_worker.py — VM sync worker no longer
   overwrites VMInstance.ip_address with NULL when no IPAM allocation
   exists for that (server_id, vmid). It only updates the field when
   IPAM has a value, otherwise the IP saved at deploy/wizard time is
   preserved.
This commit is contained in:
markmorado
2026-05-06 20:22:50 +02:00
parent aba2eb3583
commit 9da65a46aa
4 changed files with 89 additions and 3 deletions

View File

@@ -221,6 +221,7 @@ def _do_reinstall_sync(task_id: int, server_id: int, vmid: int, node: str,
net0=net0,
nameserver=nameserver,
searchdomain=searchdomain,
password=cached.cloud_init_password,
ssh_public_keys=cached.ssh_keys,
unprivileged=unprivileged,
start_after_create=False,

View File

@@ -280,8 +280,8 @@ def _do_lxc_deploy(task_id: int, req: LXCDeployRequest, user_id: int, username:
ip_address=allocated_ip,
ip_prefix=int(network_mask),
gateway=gateway,
cloud_init_user=None,
cloud_init_password=None,
cloud_init_user="root",
cloud_init_password=req.password,
ssh_keys=req.ssh_keys,
template_id=None,
template_name=req.ostemplate,