mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 11:16:47 +00:00
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.
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
from django import forms
|
|
from django.utils.translation import gettext_lazy as _
|
|
from vrtManager.connection import CONN_SOCKET, CONN_SSH, CONN_TCP, CONN_TLS
|
|
|
|
from computes.models import Compute
|
|
|
|
from .validators import validate_hostname
|
|
|
|
|
|
class KeepPasswordMixin:
|
|
"""The form never shows the stored password: left empty on an edit, it
|
|
stays as it is."""
|
|
|
|
def clean_password(self):
|
|
return self.cleaned_data["password"] or self.instance.password
|
|
|
|
|
|
class TcpComputeForm(KeepPasswordMixin, forms.ModelForm):
|
|
hostname = forms.CharField(validators=[validate_hostname])
|
|
type = forms.IntegerField(widget=forms.HiddenInput, initial=CONN_TCP)
|
|
|
|
class Meta:
|
|
model = Compute
|
|
widgets = {"password": forms.PasswordInput()}
|
|
fields = "__all__"
|
|
|
|
|
|
class SshComputeForm(forms.ModelForm):
|
|
hostname = forms.CharField(validators=[validate_hostname], label=_("FQDN/IP"))
|
|
type = forms.IntegerField(widget=forms.HiddenInput, initial=CONN_SSH)
|
|
|
|
class Meta:
|
|
model = Compute
|
|
exclude = ["password"]
|
|
|
|
|
|
class TlsComputeForm(KeepPasswordMixin, forms.ModelForm):
|
|
hostname = forms.CharField(validators=[validate_hostname])
|
|
type = forms.IntegerField(widget=forms.HiddenInput, initial=CONN_TLS)
|
|
|
|
class Meta:
|
|
model = Compute
|
|
widgets = {"password": forms.PasswordInput()}
|
|
fields = "__all__"
|
|
|
|
|
|
class SocketComputeForm(forms.ModelForm):
|
|
hostname = forms.CharField(widget=forms.HiddenInput, initial="localhost")
|
|
type = forms.IntegerField(widget=forms.HiddenInput, initial=CONN_SOCKET)
|
|
|
|
class Meta:
|
|
model = Compute
|
|
fields = ["name", "details", "hostname", "type", "migration_address"]
|