mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(instances): device edits fit every definition and device type
A volume of an LVM or iSCSI pool can be attached: by its own path, with the format its volume reports (raw when the pool knows none). Detaching a disk takes each definition's own description of it, so a disk only in the persistent definition goes too. Every NIC type can be a boot device; bridge and direct NICs were dropped from the boot order. The video model is a value, never parsed as XML. QoS changes clear the page's read cache. The NIC model "default" leaves the choice to libvirt instead of writing model "default", and rt18139 is rtl8139: a VM with either did not start (checked on a RHEL 10 host). A migration corrects the default NIC type setting.
This commit is contained in:
parent
769a0dc96f
commit
11fe2409f9
12 changed files with 250 additions and 48 deletions
22
appsettings/migrations/0016_nic_type_rtl8139.py
Normal file
22
appsettings/migrations/0016_nic_type_rtl8139.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from django.db import migrations
|
||||
|
||||
|
||||
def fix_rtl8139(apps, schema_editor):
|
||||
"""The NIC type is rtl8139: a VM with model rt18139 does not start. Not
|
||||
undone on the way back, as nothing needs the misspelling."""
|
||||
AppSettings = apps.get_model("appsettings", "AppSettings")
|
||||
for setting in AppSettings.objects.using(schema_editor.connection.alias).filter(key="INSTANCE_NIC_DEFAULT_TYPE"):
|
||||
setting.choices = setting.choices.replace("rt18139", "rtl8139")
|
||||
if setting.value == "rt18139":
|
||||
setting.value = "rtl8139"
|
||||
setting.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("appsettings", "0015_remove_clone_instance_auto_migrate"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(fix_rtl8139, migrations.RunPython.noop),
|
||||
]
|
||||
|
|
@ -4,10 +4,11 @@ an id must not collide with them."""
|
|||
|
||||
import importlib
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
|
||||
from django.apps import apps
|
||||
from django.db import connection
|
||||
from django.test import TransactionTestCase
|
||||
from django.test import TestCase, TransactionTestCase
|
||||
|
||||
from appsettings.models import AppSettings
|
||||
|
||||
|
|
@ -26,3 +27,16 @@ class SequenceAfterFixedIdsTestCase(TransactionTestCase):
|
|||
cursor.execute("SELECT setval(pg_get_serial_sequence('appsettings_appsettings', 'id'), 1, false)")
|
||||
login_lockout.add_settings(apps, schema_editor)
|
||||
self.assertEqual(AppSettings.objects.filter(key__startswith="LOGIN_").count(), 2)
|
||||
|
||||
|
||||
nic_type = importlib.import_module("appsettings.migrations.0016_nic_type_rtl8139")
|
||||
|
||||
|
||||
class NicTypeTestCase(TestCase):
|
||||
def test_the_misspelt_nic_type_becomes_rtl8139(self):
|
||||
setting = AppSettings.objects.get(key="INSTANCE_NIC_DEFAULT_TYPE")
|
||||
self.assertEqual(setting.choices, "default,e1000,e1000e,rtl8139,virtio")
|
||||
AppSettings.objects.filter(pk=setting.pk).update(value="rt18139", choices="default,e1000,e1000e,rt18139,virtio")
|
||||
nic_type.fix_rtl8139(apps, SimpleNamespace(connection=connection))
|
||||
setting.refresh_from_db()
|
||||
self.assertEqual((setting.value, setting.choices), ("rtl8139", "default,e1000,e1000e,rtl8139,virtio"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue