mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
The host page in maintenance showed the host's latest bulk migration even when it was from before the maintenance, as a job of the morning that "succeeded" while a VM still ran. The host now keeps when it went in maintenance (maintenance_since; a job that puts it there sets it to the job's own time), and the page shows a bulk migration from then on, or one still running. A refusal of the panel's own (OperationError), such as a VM start on a host in maintenance, was shown as "libvirt Error - ...": it is shown as is.
27 lines
801 B
Python
27 lines
801 B
Python
from django.db import migrations, models
|
|
from django.utils import timezone
|
|
|
|
|
|
def keep_maintenance(apps, schema_editor):
|
|
# a host in maintenance stays in it, from now on
|
|
apps.get_model("computes", "Compute").objects.filter(maintenance=True).update(maintenance_since=timezone.now())
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("computes", "0010_maintenance"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name="compute",
|
|
name="maintenance_since",
|
|
field=models.DateTimeField(blank=True, editable=False, null=True),
|
|
),
|
|
migrations.RunPython(keep_maintenance, migrations.RunPython.noop),
|
|
migrations.RemoveField(
|
|
model_name="compute",
|
|
name="maintenance",
|
|
),
|
|
]
|