Commit cb15e6e4 by Szabolcs Gelencser

Implement advanced network creation

parent 400534b4
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<div v-cloak v-if="isAdvancedConfig"> <div v-cloak v-if="isAdvancedConfig">
<div class="form-group"> <div class="form-group">
<label for="id_network_address"> Network address <i class="asteriskField">*</i></label> <label for="id_network_address"> Network address <i class="asteriskField">*</i></label>
<input type="text" name="name" required class="form-control textinput textInput form-control" id="id_network_address"> <input type="text" name="networkAddress" required class="form-control textinput textInput form-control" id="id_network_address">
<input name="isDhcpEnabled" type="checkbox" v-model="isDhcpEnabled"> Enable DHCP <input name="isDhcpEnabled" type="checkbox" v-model="isDhcpEnabled"> Enable DHCP
</div> </div>
......
...@@ -999,10 +999,16 @@ class VxlanCreate(LoginRequiredMixin, FormView): ...@@ -999,10 +999,16 @@ class VxlanCreate(LoginRequiredMixin, FormView):
def form_valid(self, form): def form_valid(self, form):
network_created = openstack_api.neutron.network_create(self.request, name=form.cleaned_data['name']) network_created = openstack_api.neutron.network_create(self.request, name=form.cleaned_data['name'])
if form.cleaned_data['isAdvancedConfig']: try:
pass if form.cleaned_data['isAdvancedConfig']:
else: openstack_api.neutron.subnet_create(
try: self.request,
network_created.id,
ip_version=4, #TODO: there should be a radio button for protocol
cidr=form.cleaned_data['networkAddress'],
enable_dhcp=form.cleaned_data['isDhcpEnabled'],
)
else:
# TODO: default ip version should read from SETTINGS # TODO: default ip version should read from SETTINGS
openstack_api.neutron.subnet_create( openstack_api.neutron.subnet_create(
self.request, self.request,
...@@ -1010,10 +1016,10 @@ class VxlanCreate(LoginRequiredMixin, FormView): ...@@ -1010,10 +1016,10 @@ class VxlanCreate(LoginRequiredMixin, FormView):
ip_version=4, ip_version=4,
subnetpool_id=SubnetPool.get_id(self.request) subnetpool_id=SubnetPool.get_id(self.request)
) )
except: except:
openstack_api.neutron.network_delete(self.request, network_created.id) openstack_api.neutron.network_delete(self.request, network_created.id)
#TODO: user friendly error handling #TODO: user friendly error handling
raise Exception("Could not create subnet for network, deleted network.") raise Exception("Could not create subnet for network, deleted network.")
return redirect(reverse_lazy('network.vxlan', kwargs={'pk': network_created.id})) return redirect(reverse_lazy('network.vxlan', kwargs={'pk': network_created.id}))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment