mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-25 07:35:22 +00:00
fix dhcp type interface error
This commit is contained in:
parent
217e106c8b
commit
af38e90f41
2 changed files with 30 additions and 10 deletions
|
@ -7,13 +7,33 @@ from django.utils.translation import gettext_lazy as _
|
||||||
class AddInterface(forms.Form):
|
class AddInterface(forms.Form):
|
||||||
name = forms.CharField(max_length=10, required=True)
|
name = forms.CharField(max_length=10, required=True)
|
||||||
itype = forms.ChoiceField(required=True, choices=(('bridge', 'bridge'), ('ethernet', 'ethernet')))
|
itype = forms.ChoiceField(required=True, choices=(('bridge', 'bridge'), ('ethernet', 'ethernet')))
|
||||||
start_mode = forms.ChoiceField(required=True,
|
start_mode = forms.ChoiceField(
|
||||||
choices=(('none', 'none'), ('onboot', 'onboot'), ('hotplug', 'hotplug')))
|
required=True,
|
||||||
|
choices=(
|
||||||
|
('none', 'none'),
|
||||||
|
('onboot', 'onboot'),
|
||||||
|
('hotplug', 'hotplug')
|
||||||
|
)
|
||||||
|
)
|
||||||
netdev = forms.CharField(max_length=15, required=True)
|
netdev = forms.CharField(max_length=15, required=True)
|
||||||
ipv4_type = forms.ChoiceField(required=True, choices=(('dhcp', 'dhcp'), ('static', 'static'), ('none', 'none')))
|
ipv4_type = forms.ChoiceField(
|
||||||
|
required=True,
|
||||||
|
choices=(
|
||||||
|
('dhcp', 'dhcp'),
|
||||||
|
('static', 'static'),
|
||||||
|
('none', 'none')
|
||||||
|
)
|
||||||
|
)
|
||||||
ipv4_addr = forms.CharField(max_length=18, required=False)
|
ipv4_addr = forms.CharField(max_length=18, required=False)
|
||||||
ipv4_gw = forms.CharField(max_length=15, required=False)
|
ipv4_gw = forms.CharField(max_length=15, required=False)
|
||||||
ipv6_type = forms.ChoiceField(required=True, choices=(('dhcp', 'dhcp'), ('static', 'static'), ('none', 'none')))
|
ipv6_type = forms.ChoiceField(
|
||||||
|
required=True,
|
||||||
|
choices=(
|
||||||
|
('dhcp', 'dhcp'),
|
||||||
|
('static', 'static'),
|
||||||
|
('none', 'none')
|
||||||
|
)
|
||||||
|
)
|
||||||
ipv6_addr = forms.CharField(max_length=100, required=False)
|
ipv6_addr = forms.CharField(max_length=100, required=False)
|
||||||
ipv6_gw = forms.CharField(max_length=100, required=False)
|
ipv6_gw = forms.CharField(max_length=100, required=False)
|
||||||
stp = forms.ChoiceField(required=False, choices=(('on', 'on'), ('off', 'off')))
|
stp = forms.ChoiceField(required=False, choices=(('on', 'on'), ('off', 'off')))
|
||||||
|
@ -39,7 +59,7 @@ class AddInterface(forms.Form):
|
||||||
|
|
||||||
def clean_ipv6_addr(self):
|
def clean_ipv6_addr(self):
|
||||||
ipv6_addr = self.cleaned_data['ipv6_addr']
|
ipv6_addr = self.cleaned_data['ipv6_addr']
|
||||||
have_symbol = re.match('^[0-9a-f./:]+$', ipv6_addr)
|
have_symbol = re.match('^[0-9a-f./:]+|^$', ipv6_addr)
|
||||||
if not have_symbol:
|
if not have_symbol:
|
||||||
raise forms.ValidationError(_('The IPv6 address must not contain any special characters'))
|
raise forms.ValidationError(_('The IPv6 address must not contain any special characters'))
|
||||||
elif len(ipv6_addr) > 100:
|
elif len(ipv6_addr) > 100:
|
||||||
|
@ -48,7 +68,7 @@ class AddInterface(forms.Form):
|
||||||
|
|
||||||
def clean_ipv6_gw(self):
|
def clean_ipv6_gw(self):
|
||||||
ipv6_gw = self.cleaned_data['ipv6_gw']
|
ipv6_gw = self.cleaned_data['ipv6_gw']
|
||||||
have_symbol = re.match('^[0-9.]+$', ipv6_gw)
|
have_symbol = re.match('^[0-9a-f./:]+|^$', ipv6_gw)
|
||||||
if not have_symbol:
|
if not have_symbol:
|
||||||
raise forms.ValidationError(_('The IPv6 gateway must not contain any special characters'))
|
raise forms.ValidationError(_('The IPv6 gateway must not contain any special characters'))
|
||||||
elif len(ipv6_gw) > 100:
|
elif len(ipv6_gw) > 100:
|
||||||
|
|
|
@ -95,13 +95,13 @@
|
||||||
<div class="row static_ipv4_form_group">
|
<div class="row static_ipv4_form_group">
|
||||||
<label class="col-sm-3 col-form-label">{% trans "IPv4 Address" %}</label>
|
<label class="col-sm-3 col-form-label">{% trans "IPv4 Address" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input type="text" class="form-control" name="ipv4_addr" maxlength="19" pattern="[0-9\.\/]+">
|
<input type="text" class="form-control" name="ipv4_addr" maxlength="19" pattern="[0-9\.\/]+|^$">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row static_ipv4_form_group">
|
<div class="row static_ipv4_form_group">
|
||||||
<label class="col-sm-3 col-form-label">{% trans "IPv4 Gateway" %}</label>
|
<label class="col-sm-3 col-form-label">{% trans "IPv4 Gateway" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input type="text" class="form-control" name="ipv4_gw" maxlength="16" pattern="[0-9\.]+">
|
<input type="text" class="form-control" name="ipv4_gw" maxlength="16" pattern="[0-9\.]+|^$">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -121,13 +121,13 @@
|
||||||
<div class="row static_ipv6_form_group">
|
<div class="row static_ipv6_form_group">
|
||||||
<label class="col-sm-3 col-form-label">{% trans "IPv6 Address" %}</label>
|
<label class="col-sm-3 col-form-label">{% trans "IPv6 Address" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input type="text" class="form-control" name="ipv6_addr" maxlength="100" pattern="[0-9a-f\:\/]+">
|
<input type="text" class="form-control" name="ipv6_addr" maxlength="100" pattern="[0-9a-f\:\/]+|^$">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row static_ipv6_form_group">
|
<div class="row static_ipv6_form_group">
|
||||||
<label class="col-sm-3 col-form-label">{% trans "IPv6 Gateway" %}</label>
|
<label class="col-sm-3 col-form-label">{% trans "IPv6 Gateway" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input type="text" class="form-control" name="ipv6_gw" maxlength="100" pattern="[0-9a-f\:]+">
|
<input type="text" class="form-control" name="ipv6_gw" maxlength="100" pattern="[0-9a-f\:]+|^$">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue