Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1e204ec1
authored
Mar 07, 2018
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement some network creation and details
parent
feb51452
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
13 deletions
+57
-13
.idea/workspace.xml
+0
-0
circle/circle/db.sqlite3
+0
-0
circle/circle/settings/base.py
+2
-2
circle/dashboard/views/vm.py
+6
-0
circle/network/forms.py
+1
-0
circle/network/templates/network/vxlan-create.html
+5
-4
circle/network/templates/network/vxlan-edit.html
+25
-5
circle/network/views.py
+18
-2
No files found.
.idea/workspace.xml
View file @
1e204ec1
This diff is collapsed.
Click to expand it.
circle/circle/db.sqlite3
View file @
1e204ec1
No preview for this file type
circle/circle/settings/base.py
View file @
1e204ec1
...
...
@@ -267,10 +267,10 @@ PIPELINE = {
),
"output_filename"
:
"editor.js"
,
},
"
new-network
"
:
{
"source_filenames"
:
(
"
vue
"
:
{
"source_filenames"
:
(
"vue/dist/vue.js"
,
),
"output_filename"
:
"
new-network
.js"
,
"output_filename"
:
"
vue
.js"
,
},
},
}
...
...
circle/dashboard/views/vm.py
View file @
1e204ec1
...
...
@@ -1022,11 +1022,17 @@ class VmPlainImageCreate(LoginRequiredMixin, TemplateView):
return
self
.
render_to_response
(
context
)
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
#TODO: if there is a network available use it, of there isn't use none
# there could be some checkboxes for the user to decide
# could create default network, setup internet access
server_created
=
openstack_api
.
nova
.
server_create
(
request
,
request
.
POST
.
get
(
"name"
),
request
.
POST
.
get
(
"image"
),
request
.
POST
.
get
(
"flavor"
),
# nics=({
# 'uuid': 'fc7ba14c-53d8-4810-9030-a0f00985c036'
# })
)
return
HttpResponseRedirect
(
"vm/
%
s#activity"
%
server_created
.
id
)
...
...
circle/network/forms.py
View file @
1e204ec1
...
...
@@ -381,5 +381,6 @@ class VxlanForm(forms.Form):
}))
networkAddress
=
forms
.
CharField
(
required
=
False
)
isDhcpEnabled
=
forms
.
BooleanField
(
required
=
False
)
isAdvancedConfig
=
forms
.
BooleanField
(
required
=
False
)
#TODO: validate
circle/network/templates/network/vxlan-create.html
View file @
1e204ec1
...
...
@@ -19,13 +19,13 @@
{{ form.name|as_crispy_field }}
{% verbatim %}
<div
id=
"vuepart"
v-bind:class=
"{ well: isAdvancedConfig }"
>
<input
v-model=
"isAdvancedConfig"
type=
"checkbox"
>
Advanced configuration
<input
name=
"isAdvancedConfig"
v-model=
"isAdvancedConfig"
type=
"checkbox"
>
Advanced configuration
<div
v-cloak
v-if=
"isAdvancedConfig"
>
<div
class=
"form-group"
>
<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
name=
"isDhcpEnabled"
type=
"checkbox"
>
Enable DHCP
<input
name=
"isDhcpEnabled"
type=
"checkbox"
v-model=
"isDhcpEnabled"
>
Enable DHCP
</div>
</div>
</div>
...
...
@@ -38,13 +38,14 @@
{% endblock %}
{% block extra_js %}
{% javascript '
new-network
' %}
{% javascript '
vue
' %}
<script>
var
app
=
new
Vue
({
el
:
'#vuepart'
,
data
:
{
isAdvancedConfig
:
false
isAdvancedConfig
:
false
,
isDhcpEnabled
:
true
}
})
</script>
...
...
circle/network/templates/network/vxlan-edit.html
View file @
1e204ec1
...
...
@@ -8,19 +8,39 @@
{% block title-page %}{{ form.name.value }} | {% trans "vxlan" %}{% endblock %}
{% block content %}
{% if isMultipleSubnetsAvailable %}
<div
class=
"alert alert-warning alert-dismissible"
>
<a
href=
"#"
class=
"close"
data-dismiss=
"alert"
aria-label=
"close"
>
×
</a>
<strong>
Warning!
</strong>
Selecting a default subnet for network but there are more than one subnets available.
This network might have been created outside of CIRCLE and might not work as expected!
{#TODO: users should use default subnet here (or merge subnets?)#}
</div>
{% endif %}
{% if isSubnetMissing %}
<div
class=
"alert alert-danger alert-dismissible"
>
<strong>
Error!
</strong>
There must be at least one subnet allocated for network!
This network might have been created outside of CIRCLE and might not work as expected!
Click
<a
href=
""
>
here
</a>
to allocate subnet for network.
{#TODO: implement. Could be a little more sophisticated?#}
</div>
{% endif %}
<div
class=
"page-header"
>
<a
href=
"{% url "
network
.
vxlan-delete
"
pk=
network.id
%}"
class=
"btn btn-danger pull-right"
><i
class=
"fa fa-times-circle"
></i>
{% trans "Delete this network" %}
</a>
<h2>
{{ form.name.value }}
<small>
{% trans "details of network" %}
</small>
</h2>
<h2>
{{ form.name.value }}
</h2>
</div>
<div
class=
"row"
>
<div
class=
"col-sm-6"
>
{% crispy form %}
<h3><small>
{% trans "Details of network" %}
</small></h3>
{{ form.name|as_crispy_field }}
{{ form.networkAddress|as_crispy_field }}
{{ form.isDhcpEnabled|as_crispy_field }}
</div>
<div
class=
"col-sm-6"
>
<div
class=
"page-header"
>
<h3>
{% trans "Connected virtual machines" %}
</h3>
</div>
<h3
class=
"pull-right"
><small>
{% trans "connected virtual machines" %}
</small></h3>
</div>
</div>
{% endblock %}
circle/network/views.py
View file @
1e204ec1
...
...
@@ -974,12 +974,23 @@ class VxlanDetail(LoginRequiredMixin, SuccessMessageMixin, DetailView): #TODO: c
context_object_name
=
'network'
def
get_object
(
self
,
queryset
=
None
):
return
openstack_api
.
neutron
.
network_get
(
self
.
request
,
self
.
kwargs
[
'pk'
])
return
openstack_api
.
neutron
.
network_get
(
self
.
request
,
self
.
kwargs
[
'pk'
]
,
expand_subnet
=
True
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
VxlanDetail
,
self
)
.
get_context_data
(
**
kwargs
)
subnet
=
self
.
object
.
subnets
[
0
]
if
len
(
self
.
object
.
subnets
)
>
0
else
None
form
=
VxlanForm
(
initial
=
{
'name'
:
self
.
object
.
name
,
'networkAddress'
:
subnet
.
cidr
if
subnet
else
None
,
'isDhcpEnabled'
:
subnet
.
enable_dhcp
if
subnet
else
False
,
})
context
[
'isMultipleSubnetsAvailable'
]
=
len
(
self
.
object
.
subnets
)
>
1
context
[
'isSubnetMissing'
]
=
len
(
self
.
object
.
subnets
)
<
1
context
[
'vm_list'
]
=
()
#SmallVmTable(self.object.vm_interface.all())
context
[
'form'
]
=
VxlanF
orm
context
[
'form'
]
=
f
orm
return
context
class
VxlanCreate
(
LoginRequiredMixin
,
FormView
):
...
...
@@ -988,6 +999,11 @@ class VxlanCreate(LoginRequiredMixin, FormView):
def
form_valid
(
self
,
form
):
network_created
=
openstack_api
.
neutron
.
network_create
(
self
.
request
,
name
=
form
.
cleaned_data
[
'name'
])
if
form
.
cleaned_data
[
'isAdvancedConfig'
]:
pass
else
:
openstack_api
.
neutron
.
subnet_create
(
self
.
request
,
network_created
.
id
,
ip_version
=
4
)
# TODO: default ip version should read from SETTINGS
return
redirect
(
reverse_lazy
(
'network.vxlan'
,
kwargs
=
{
'pk'
:
network_created
.
id
}))
class
VxlanDelete
(
LoginRequiredMixin
,
DeleteView
):
#TODO: check user
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment