mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 04:36:48 +00:00
fix(instances): a clone stays on the host of the VM it was made from
With "VM Clone Auto Migrate" on, a new clone was migrated to a random compute, whatever storage, CPU or network that host had, and a failed migration showed as a failed clone although the clone existed. The setting and its code are removed; migration appsettings.0015 deletes the setting. A clone can be migrated afterwards like any VM. The README's update notes list the migration changes: the migration address, storage pools for the disk check, and this setting.
This commit is contained in:
parent
5c22fc8436
commit
1016f745c2
5 changed files with 51 additions and 7 deletions
|
|
@ -0,0 +1,31 @@
|
|||
from django.db import migrations
|
||||
|
||||
|
||||
def remove_auto_migrate(apps, schema_editor):
|
||||
"""A clone stays on the host of the VM it was made from: the setting sent
|
||||
it to a random host, whatever storage, CPU or network that host had."""
|
||||
AppSettings = apps.get_model("appsettings", "AppSettings")
|
||||
AppSettings.objects.using(schema_editor.connection.alias).filter(key="CLONE_INSTANCE_AUTO_MIGRATE").delete()
|
||||
|
||||
|
||||
def restore_auto_migrate(apps, schema_editor):
|
||||
AppSettings = apps.get_model("appsettings", "AppSettings")
|
||||
AppSettings.objects.using(schema_editor.connection.alias).get_or_create(
|
||||
key="CLONE_INSTANCE_AUTO_MIGRATE",
|
||||
defaults={
|
||||
"name": "VM Clone Auto Migrate",
|
||||
"value": "False",
|
||||
"choices": "True,False",
|
||||
"description": "Auto migrate instance after clone",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("appsettings", "0014_login_lockout_settings"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(remove_auto_migrate, restore_auto_migrate),
|
||||
]
|
||||
|
|
@ -43,3 +43,8 @@ class AppSettingsTestCase(TestCase):
|
|||
self.client.force_login(regular_user)
|
||||
response = self.client.get(reverse("appsettings"))
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
def test_clones_are_not_migrated_automatically(self):
|
||||
# a clone stays on the host of the VM it was made from; the setting
|
||||
# that sent it to a random host is removed by migration 0015
|
||||
self.assertFalse(AppSettings.objects.filter(key="CLONE_INSTANCE_AUTO_MIGRATE").exists())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue