1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

feat(computes): putting a host in maintenance migrates its VMs; ready once none runs

A host was put in maintenance with its VMs still on it, and emptying it was
a separate step. "Put in maintenance" on a host with VMs that run now opens
Bulk Migrate, whose button migrates the chosen VMs and puts the host in
maintenance in one transaction: with the job admitted, or not at all; a
form sent again finds its job and does not put back a host taken out of
maintenance since. The page also puts it in maintenance without migrating,
for VMs that cannot move or when no host can take them.

Maintenance is not refused while VMs run: it must be on before they move,
or a new VM or Balance could take their place. The host shows instead
whether it is ready: "Maintenance requested" while VMs other than shut-off
ones remain on it (or it cannot be read), with its bulk migration's state;
"In maintenance" once none does. None of its VMs starts or resumes there
meanwhile. Ending maintenance during the bulk migration lets it go on.
This commit is contained in:
catborise 2026-11-16 16:47:55 +03:00
parent 22362de068
commit d96fe940e9
14 changed files with 962 additions and 537 deletions

View file

@ -52,8 +52,9 @@ class Compute(Model):
# reaches it: one host is one compute, and a compute's VMs stay on it
host_uuid = CharField(max_length=36, blank=True, default="", editable=False)
# in maintenance: no new VM and no migration comes to the host, and Balance
# leaves it out; its VMs run on and Bulk Migrate empties it (refuse_new_vms)
# in maintenance: no new VM and no migration comes to the host, none of its
# VMs starts there, and Balance leaves it out; Bulk Migrate empties it, and
# it is ready once none of its VMs runs (refuse_new_vms, refuse_start)
maintenance = BooleanField(default=False, editable=False)
class Meta:
@ -65,6 +66,12 @@ class Compute(Model):
raise util.OperationError(gettext_noop("%(compute)s is in maintenance: no new VM or migration comes to it"),
compute=self.name)
def refuse_start(self):
"""Refuses starting or resuming a VM of the host while it is in maintenance."""
if self.maintenance:
raise util.OperationError(gettext_noop("%(compute)s is in maintenance: its VMs cannot be started there; "
"migrate the VM to start it on another host"), compute=self.name)
@property
def migration_uri(self):
"""The native migration URI for VMs migrated to this host: its