mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(computes): a libvirt host is one compute, and a compute's VMs stay on their host
One host could be added twice, under another name, as TCP and SSH, or by another address: its VMs were listed once per record, each with its own owners, and counted twice in the capacity totals. A compute with VMs could also be pointed at another host: the owners of a VM then reached the VM with the same UUID there, a restored or copied one. A compute now keeps its libvirt host UUID. Adding a compute or changing its connection, on the web or the API, connects and reads it: a host that is already a compute is refused, and a compute with VMs moves only to an address of the same host, which must answer. Computes added before are read when another one is checked.
This commit is contained in:
parent
2db25314ea
commit
29ec20682b
17 changed files with 567 additions and 259 deletions
|
|
@ -28,6 +28,18 @@ def libvirt_compute_lock(compute, *, shared=False):
|
|||
yield
|
||||
|
||||
|
||||
@contextmanager
|
||||
def hosts_lock(compute=None):
|
||||
"""A compute added or its connection changed: checked (Compute.clean)
|
||||
and saved one at a time, so two cannot be one host; a compute changed
|
||||
is held exclusive, so its VMs are not listed from the old host meanwhile."""
|
||||
wanted = {claims.hosts_key(): Claim.EXCLUSIVE}
|
||||
if compute is not None:
|
||||
wanted[claims.compute_key(compute.pk)] = Claim.EXCLUSIVE
|
||||
with claims.hold(wanted):
|
||||
yield
|
||||
|
||||
|
||||
@contextmanager
|
||||
def user_quota_lock(user):
|
||||
"""One user's quota check and the change it allows run one at a time."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue