fix(ipam): require resource name before allocating IP and fill missing fields on VM link
All checks were successful
Backend Tests / pytest (Python 3.12) (push) Successful in 46s
Deploy to Production / Trigger production update (push) Successful in 8s

- Validate resource name in auto-allocate form before sending request
- Fill resource_name, proxmox_node, resource_type, mac_address when syncing
  a VM that already has matching vmid/server_id but missing metadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-20 03:23:57 +05:00
parent 7546883393
commit 965fb858da
4 changed files with 12 additions and 1 deletions

View File

@@ -707,8 +707,16 @@ class IPAMService:
last_seen=utcnow()
)
else:
# Just update last_seen
# vmid/server already match — update last_seen and fill missing resource_name/node
existing.last_seen = utcnow()
if not existing.resource_name and vm_name:
existing.resource_name = vm_name
if not existing.proxmox_node and node:
existing.proxmox_node = node
if not existing.resource_type and vm_type:
existing.resource_type = vm_type
if mac_address and not existing.mac_address:
existing.mac_address = mac_address
self.db.commit()
return existing, None