1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-10 20:26:48 +00:00
webvirtcloud/instances/migrations/0013_instancetombstone.py
catborise d054b13a87 fix(computes): VM ownership survives a move or a short absence
The sync deleted the Instance of every VM missing from its compute, and
its owners and rights went with it. A VM moved with virsh, or undefined
and defined again, came back with no owner.

Now, when a VM disappears from a compute:
- if the same UUID is recorded on another compute, it moved: its owners
  and template flag go there;
- otherwise they are kept in an InstanceTombstone and restored when the
  UUID appears again within INSTANCE_OWNERSHIP_RETENTION_DAYS (30).
A UUID recorded on two computes at the same time is a copy and gets no
owners. VMs deleted through WebVirtCloud leave no tombstone.
2026-10-04 01:08:11 +03:00

32 lines
992 B
Python

# Generated by Django 5.2.17 on 2026-10-03 19:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("instances", "0012_instance_unique_compute_uuid"),
]
operations = [
migrations.CreateModel(
name="InstanceTombstone",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("uuid", models.CharField(db_index=True, max_length=36)),
("name", models.CharField(max_length=120)),
("is_template", models.BooleanField(default=False)),
("owners", models.JSONField(default=list)),
("removed", models.DateTimeField(auto_now_add=True)),
],
),
]