mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
feat(computes): a compute names the address migrations reach it on
Migration is client-driven: libvirt sends the VM's memory to the destination's own host name unless a migration URI is given, and the app never gave one. Where the hosts cannot resolve each other's names (or the names point at a management network) every migration failed with "Unable to resolve address '<host name>' service '49152'". A compute now has an optional migration address (an IP address or a host name, no scheme or port), editable in the compute form and the API. A VM migrating to that compute is sent to tcp://<address> (bracketed for IPv6). Empty, the default for existing computes, keeps the previous behavior. The compute's host name is not reused, because for SSH computes it can be an ssh_config alias. The migration log entry names the address when one is set.
This commit is contained in:
parent
25b3671c33
commit
5a523befbd
10 changed files with 158 additions and 3 deletions
|
|
@ -1,8 +1,11 @@
|
|||
from ipaddress import ip_address
|
||||
|
||||
from django.db.models import CharField, IntegerField, Model
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from libvirt import virConnect
|
||||
|
||||
from computes.validators import validate_migration_address
|
||||
from vrtManager.connection import connection_manager
|
||||
from vrtManager.hostdetails import wvmHostDetails
|
||||
|
||||
|
|
@ -14,6 +17,30 @@ class Compute(Model):
|
|||
password = CharField(_("password"), max_length=14, blank=True, null=True)
|
||||
details = CharField(_("details"), max_length=64, null=True, blank=True)
|
||||
type = IntegerField()
|
||||
migration_address = CharField(
|
||||
_("migration address"),
|
||||
max_length=64,
|
||||
blank=True,
|
||||
default="",
|
||||
validators=[validate_migration_address],
|
||||
help_text=_(
|
||||
"IP address or host name the other hosts send migrating VMs to; "
|
||||
"empty: the host's own host name, which they must be able to resolve"
|
||||
),
|
||||
)
|
||||
|
||||
@property
|
||||
def migration_uri(self):
|
||||
"""The native migration URI for VMs migrated to this host, or None for
|
||||
libvirt's default."""
|
||||
if not self.migration_address:
|
||||
return None
|
||||
try:
|
||||
if ip_address(self.migration_address).version == 6:
|
||||
return f"tcp://[{self.migration_address}]"
|
||||
except ValueError:
|
||||
pass
|
||||
return f"tcp://{self.migration_address}"
|
||||
|
||||
@cached_property
|
||||
def status(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue