2015-03-06 11:59:27 +00:00
|
|
|
from django import forms
|
2020-10-14 12:27:57 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2020-10-15 14:18:45 +00:00
|
|
|
from vrtManager.connection import CONN_SOCKET, CONN_SSH, CONN_TCP, CONN_TLS
|
|
|
|
|
2015-03-06 11:59:27 +00:00
|
|
|
from computes.models import Compute
|
2020-10-15 14:18:45 +00:00
|
|
|
|
2020-05-29 13:25:36 +00:00
|
|
|
from .validators import validate_hostname
|
2015-03-06 11:59:27 +00:00
|
|
|
|
|
|
|
|
2020-05-29 13:25:36 +00:00
|
|
|
class TcpComputeForm(forms.ModelForm):
|
|
|
|
hostname = forms.CharField(validators=[validate_hostname])
|
|
|
|
type = forms.IntegerField(widget=forms.HiddenInput, initial=CONN_TCP)
|
2015-03-06 11:59:27 +00:00
|
|
|
|
2020-05-29 13:25:36 +00:00
|
|
|
class Meta:
|
|
|
|
model = Compute
|
2022-11-02 05:54:35 +00:00
|
|
|
widgets = {"password": forms.PasswordInput()}
|
|
|
|
fields = "__all__"
|
2015-03-06 11:59:27 +00:00
|
|
|
|
|
|
|
|
2020-05-29 13:25:36 +00:00
|
|
|
class SshComputeForm(forms.ModelForm):
|
|
|
|
hostname = forms.CharField(validators=[validate_hostname], label=_("FQDN/IP"))
|
|
|
|
type = forms.IntegerField(widget=forms.HiddenInput, initial=CONN_SSH)
|
2015-03-06 11:59:27 +00:00
|
|
|
|
2020-05-29 13:25:36 +00:00
|
|
|
class Meta:
|
|
|
|
model = Compute
|
2022-11-02 05:54:35 +00:00
|
|
|
exclude = ["password"]
|
2015-03-06 11:59:27 +00:00
|
|
|
|
|
|
|
|
2020-05-29 13:25:36 +00:00
|
|
|
class TlsComputeForm(forms.ModelForm):
|
|
|
|
hostname = forms.CharField(validators=[validate_hostname])
|
|
|
|
type = forms.IntegerField(widget=forms.HiddenInput, initial=CONN_TLS)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Compute
|
2022-11-02 05:54:35 +00:00
|
|
|
widgets = {"password": forms.PasswordInput()}
|
|
|
|
fields = "__all__"
|
2020-05-29 13:25:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SocketComputeForm(forms.ModelForm):
|
2022-11-02 05:54:35 +00:00
|
|
|
hostname = forms.CharField(widget=forms.HiddenInput, initial="localhost")
|
2020-05-29 13:25:36 +00:00
|
|
|
type = forms.IntegerField(widget=forms.HiddenInput, initial=CONN_SOCKET)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Compute
|
2022-11-02 05:54:35 +00:00
|
|
|
fields = ["name", "details", "hostname", "type"]
|