mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 15:15:22 +00:00
Reconfig to create nat routed network without subnet
This commit is contained in:
parent
78ec7ac746
commit
8bc316355d
3 changed files with 5 additions and 7 deletions
|
@ -7,7 +7,7 @@ class AddNetPool(forms.Form):
|
|||
name = forms.CharField(error_messages={'required': _('No pool name has been entered')},
|
||||
max_length=20)
|
||||
subnet = forms.CharField(error_messages={'required': _('No subnet has been entered')},
|
||||
max_length=20)
|
||||
max_length=20, required=False)
|
||||
forward = forms.CharField(max_length=100)
|
||||
dhcp4 = forms.BooleanField(required=False)
|
||||
fixed = forms.BooleanField(required=False)
|
||||
|
@ -25,7 +25,7 @@ class AddNetPool(forms.Form):
|
|||
|
||||
def clean_subnet(self):
|
||||
subnet = self.cleaned_data['subnet']
|
||||
have_symbol = re.match('^[0-9./]+$', subnet)
|
||||
have_symbol = re.match('^[0-9./]+$', subnet if subnet else ".")
|
||||
if not have_symbol:
|
||||
raise forms.ValidationError(_('The pool subnet must not contain any special characters'))
|
||||
elif len(subnet) > 20:
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<h4 class="modal-title">{% trans "Add New Network" %}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal" method="post" action="" role="form">{% csrf_token %}
|
||||
<form class="form-horizontal" method="post" action="" role="form" novalidate>{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">{% trans "Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
|
|
|
@ -31,6 +31,7 @@ def networks(request, compute_id):
|
|||
compute.password,
|
||||
compute.type)
|
||||
networks = conn.get_networks_info()
|
||||
dhcp4 = netmask = gateway = ''
|
||||
|
||||
if request.method == 'POST':
|
||||
if 'create' in request.POST:
|
||||
|
@ -42,11 +43,8 @@ def networks(request, compute_id):
|
|||
error_messages.append(msg)
|
||||
if data['forward'] == 'bridge' and data['bridge_name'] == '':
|
||||
error_messages.append('Please enter bridge name')
|
||||
try:
|
||||
if data['subnet']:
|
||||
gateway, netmask, dhcp4 = network_size(data['subnet'], data['dhcp4'])
|
||||
except:
|
||||
error_msg = _("Input subnet pool error")
|
||||
error_messages.append(error_msg)
|
||||
if not error_messages:
|
||||
conn.create_network(data['name'], data['forward'], gateway, netmask,
|
||||
dhcp4, data['bridge_name'], data['openvswitch'], data['fixed'])
|
||||
|
|
Loading…
Reference in a new issue