From 35468bc0fd3ba51514b44fb9eb3c954fe1357536 Mon Sep 17 00:00:00 2001 From: catborise Date: Mon, 19 Oct 2026 22:21:10 +0300 Subject: [PATCH] fix(instances): a custom VM gets the MAC addresses its create form shows The custom create form shows a MAC per network (random, or typed in), but had no mac field: the script wrote the joined list into every name="mac" input of the page, the other six-plus forms' own MAC fields, so a flavor form then sent one MAC per custom network and was refused, and the custom VM got other MACs from libvirt. The custom form gets its own hidden mac field and the script writes only there. The field took 17 characters, one MAC, so the API also refused a VM with two NICs and their MACs; it takes 255. The serializer's test sent no submission_key, so its check for more MACs than networks never ran; it does now, next to the case of two networks with two MACs. --- instances/models.py | 2 +- instances/templates/create_instance_w2.html | 5 ++++- instances/tests/test_create_instance.py | 23 +++++++++++++-------- instances/tests/test_create_page_js.py | 21 +++++++++++++++++++ 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/instances/models.py b/instances/models.py index 99883859..16d8df13 100644 --- a/instances/models.py +++ b/instances/models.py @@ -372,7 +372,7 @@ class CreateInstance(models.Model): meta_prealloc = models.BooleanField(default=False, blank=True) virtio = models.BooleanField(default=True) qemu_ga = models.BooleanField(default=False) - mac = models.CharField(max_length=17, blank=True) + mac = models.CharField(max_length=255, blank=True) # one per NIC, comma separated add_cdrom = models.CharField(max_length=16) add_input = models.CharField(max_length=16) video = models.CharField( diff --git a/instances/templates/create_instance_w2.html b/instances/templates/create_instance_w2.html index 5af065be..fdd42491 100644 --- a/instances/templates/create_instance_w2.html +++ b/instances/templates/create_instance_w2.html @@ -413,6 +413,7 @@ +