mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
feat(migrations): a migration's bandwidth can be capped
A migration took all the network it could, its disk copies too, and the VMs on both hosts felt it. Settings has a Migrations group with "Migration bandwidth" (MiB/s, 0: libvirt's default, the default); every migration, by hand, in bulk or for maintenance, passes it to libvirt, and its log line names it. libvirt applies it to the memory until the final switchover and to each copied disk on its own; the help and README say so. A refused setting is now named in the page's language.
This commit is contained in:
parent
46931bdbdb
commit
3da55342da
14 changed files with 438 additions and 333 deletions
29
appsettings/migrations/0028_migration_bandwidth.py
Normal file
29
appsettings/migrations/0028_migration_bandwidth.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from django.core.management.color import no_style
|
||||
from django.db import migrations
|
||||
from django.utils.translation import gettext_noop as _
|
||||
|
||||
SETTING = (_("Migration bandwidth"), "MIGRATION_BANDWIDTH", "0",
|
||||
_("MiB/s for the memory and each copied disk, not the final switchover; 0: libvirt's default"))
|
||||
|
||||
|
||||
def add_setting(apps, schema_editor):
|
||||
setting = apps.get_model("appsettings", "AppSettings")
|
||||
db_alias = schema_editor.connection.alias
|
||||
# see 0014: move a PostgreSQL id sequence past the fixed ids first
|
||||
with schema_editor.connection.cursor() as cursor:
|
||||
for sql in schema_editor.connection.ops.sequence_reset_sql(no_style(), [setting]):
|
||||
cursor.execute(sql)
|
||||
name, key, value, description = SETTING
|
||||
setting.objects.using(db_alias).get_or_create(
|
||||
key=key, defaults={"name": name, "value": value, "choices": "", "description": description})
|
||||
|
||||
|
||||
def del_setting(apps, schema_editor):
|
||||
apps.get_model("appsettings", "AppSettings").objects.using(schema_editor.connection.alias).filter(
|
||||
key=SETTING[1]).delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [("appsettings", "0027_alert_settings")]
|
||||
|
||||
operations = [migrations.RunPython(add_setting, del_setting)]
|
||||
Loading…
Add table
Add a link
Reference in a new issue