mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
More tests for computes
This commit is contained in:
parent
a4d28f2953
commit
d3c59acb3f
4 changed files with 20 additions and 34 deletions
|
|
@ -40,31 +40,3 @@ class SocketComputeForm(forms.ModelForm):
|
|||
class Meta:
|
||||
model = Compute
|
||||
fields = ['name', 'details', 'hostname', 'type']
|
||||
|
||||
|
||||
class ComputeEditHostForm(forms.Form):
|
||||
host_id = forms.CharField()
|
||||
name = forms.CharField(error_messages={'required': _('No hostname has been entered')}, max_length=64)
|
||||
hostname = forms.CharField(error_messages={'required': _('No IP / Domain name has been entered')}, max_length=100)
|
||||
login = forms.CharField(error_messages={'required': _('No login has been entered')}, max_length=100)
|
||||
password = forms.CharField(max_length=100)
|
||||
details = forms.CharField(max_length=50, required=False)
|
||||
|
||||
def clean_name(self):
|
||||
name = self.cleaned_data['name']
|
||||
have_symbol = re.match('[^a-zA-Z0-9._-]+', name)
|
||||
if have_symbol:
|
||||
raise forms.ValidationError(_('The name of the host must not contain any special characters'))
|
||||
elif len(name) > 20:
|
||||
raise forms.ValidationError(_('The name of the host must not exceed 20 characters'))
|
||||
return name
|
||||
|
||||
def clean_hostname(self):
|
||||
hostname = self.cleaned_data['hostname']
|
||||
have_symbol = re.match('[^a-zA-Z0-9._-]+', hostname)
|
||||
wrong_ip = re.match('^0.|^255.', hostname)
|
||||
if have_symbol:
|
||||
raise forms.ValidationError(_('Hostname must contain only numbers, or the domain name separated by "."'))
|
||||
elif wrong_ip:
|
||||
raise forms.ValidationError(_('Wrong IP address'))
|
||||
return hostname
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue