mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
fix(instances): a VM name of any length libvirt takes is kept
libvirt names a VM by its <name>.xml file, so a name can have up to 251 bytes. The panel's VM, removed-VM and log records held 120 characters: on PostgreSQL one longer name made the host's sync fail and the VM list answer with an error. They now hold 255. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
e83bdcbd44
commit
373760f2c5
8 changed files with 68 additions and 8 deletions
|
|
@ -204,7 +204,7 @@ def clone_data(user, instance, fields):
|
|||
quota=utils.quota_message(quota_msg), clone_name=data["name"])
|
||||
if check_instance:
|
||||
raise util.OperationError(_("Instance '%(clone_name)s' already exists!"), clone_name=data["name"])
|
||||
if len(data["name"]) > 64: # as a new VM's: the panel's records hold 120
|
||||
if len(data["name"]) > 64: # as a new VM's: the panel's records hold 255
|
||||
raise util.OperationError(_("Instance name '%(clone_name)s' is longer than 64 characters"),
|
||||
clone_name=data["name"])
|
||||
if not re.match(r"^[a-zA-Z0-9-]+$", data["name"]):
|
||||
|
|
|
|||
23
instances/migrations/0016_vm_name_length.py
Normal file
23
instances/migrations/0016_vm_name_length.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 5.2.18 on 2026-11-09 18:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('instances', '0015_remove_api_only_models'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='instance',
|
||||
name='name',
|
||||
field=models.CharField(db_index=True, max_length=255, verbose_name='name'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='instancetombstone',
|
||||
name='name',
|
||||
field=models.CharField(max_length=255),
|
||||
),
|
||||
]
|
||||
|
|
@ -29,7 +29,8 @@ class InstanceManager(models.Manager):
|
|||
|
||||
class Instance(models.Model):
|
||||
compute = models.ForeignKey(Compute, on_delete=models.CASCADE)
|
||||
name = models.CharField(_("name"), max_length=120, db_index=True)
|
||||
# libvirt takes any name its <name>.xml file can have: up to 251 bytes
|
||||
name = models.CharField(_("name"), max_length=255, db_index=True)
|
||||
uuid = models.CharField(_("uuid"), max_length=36, db_index=True)
|
||||
is_template = models.BooleanField(_("is template"), default=False)
|
||||
created = models.DateTimeField(_("created"), auto_now_add=True)
|
||||
|
|
@ -409,7 +410,7 @@ class InstanceTombstone(models.Model):
|
|||
"""
|
||||
|
||||
uuid = models.CharField(max_length=36, db_index=True)
|
||||
name = models.CharField(max_length=120)
|
||||
name = models.CharField(max_length=255)
|
||||
host = models.CharField(max_length=64, blank=True) # the compute's name: the compute may be deleted
|
||||
is_template = models.BooleanField(default=False)
|
||||
owners = models.JSONField(default=list) # [{"user": id, "is_change": .., "is_delete": .., "is_vnc": ..}]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue