Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0d5684f5
authored
Nov 04, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: create vm with different parameters
parent
0c033922
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
15 deletions
+42
-15
circle/dashboard/static/dashboard/vm-create.js
+11
-3
circle/dashboard/templates/dashboard/vm-detail.html
+1
-1
circle/dashboard/views.py
+30
-11
No files found.
circle/dashboard/static/dashboard/vm-create.js
View file @
0d5684f5
...
...
@@ -6,8 +6,7 @@ $(function() {
});
function
vmCreateLoaded
()
{
// temporarily disable for testing
//$('.vm-create-advanced').hide();
$
(
'.vm-create-advanced'
).
hide
();
$
(
'.vm-create-advanced-btn'
).
click
(
function
()
{
$
(
'.vm-create-advanced'
).
stop
().
slideToggle
();
if
(
$
(
'.vm-create-advanced-icon'
).
hasClass
(
'icon-caret-down'
))
{
...
...
@@ -178,7 +177,16 @@ function vmCreateLoaded() {
type
:
'POST'
,
data
:
$
(
'form'
).
serialize
(),
success
:
function
(
data
,
textStatus
,
xhr
)
{
console
.
log
(
data
);
if
(
data
.
pk
)
{
window
.
location
.
replace
(
'/dashboard/vm/'
+
data
.
pk
+
'/#activity'
);
}
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
if
(
xhr
.
status
==
500
)
{
alert
(
"uhuhuhuhuhuh"
);
}
else
{
alert
(
"unknown error"
);
}
}
});
return
false
;
...
...
circle/dashboard/templates/dashboard/vm-detail.html
View file @
0d5684f5
...
...
@@ -4,7 +4,7 @@
{% block content %}
<div
class=
"body-content"
>
<div
class=
"page-header"
>
<h1>
{{ instance.name }}
<small>
550
.vm.ik.bme.hu
</small></h1>
<h1>
{{ instance.name }}
<small>
{{ instance.pk }}
.vm.ik.bme.hu
</small></h1>
</div>
<div
class=
"row"
>
<div
class=
"col-md-4"
id=
"vm-info-pane"
>
...
...
circle/dashboard/views.py
View file @
0d5684f5
from
django.http
import
HttpResponse
from
django.views.generic
import
TemplateView
,
DetailView
from
django_tables2
import
SingleTableView
from
django.core.urlresolvers
import
reverse_lazy
from
django.shortcuts
import
redirect
from
django_tables2
import
SingleTableView
from
tables
import
VmListTable
from
vm.models
import
Instance
,
InstanceTemplate
,
InterfaceTemplate
...
...
@@ -121,21 +123,38 @@ class VmCreate(TemplateView):
return
context
# TODO handle not ajax posts
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
self
.
request
.
user
.
is_authenticated
():
user
=
self
.
request
.
user
else
:
user
=
None
resp
=
request
.
POST
.
copy
()
resp
[
'managed-vlans'
]
=
request
.
POST
.
getlist
(
'managed-vlans'
)
resp
[
'unmanaged-vlans'
]
=
request
.
POST
.
getlist
(
'unmanaged-vlans'
)
resp
[
'disks'
]
=
request
.
POST
.
getlist
(
'disks'
)
resp
=
{}
try
:
ikwargs
=
{
'num_cores'
:
request
.
POST
.
get
(
'cpu-count'
),
'ram_size'
:
request
.
POST
.
get
(
'ram-size'
),
'priority'
:
request
.
POST
.
get
(
'cpu-priority'
),
'disks'
:
Disk
.
objects
.
filter
(
pk__in
=
request
.
POST
.
getlist
(
'disks'
))
}
template
=
InstanceTemplate
.
objects
.
get
(
pk
=
request
.
POST
.
get
(
'template-pk'
))
inst
=
Instance
.
create_from_template
(
template
=
template
,
owner
=
user
,
**
ikwargs
)
inst
.
deploy_async
()
template
=
InstanceTemplate
.
objects
.
get
(
pk
=
request
.
POST
.
get
(
'template-pk'
))
inst
=
Instance
.
create_from_template
(
template
=
template
,
owner
=
user
)
inst
.
deploy_async
()
resp
[
'pk'
]
=
inst
.
pk
except
InstanceTemplate
.
DoesNotExist
:
resp
[
'error'
]
=
True
except
:
resp
[
'error'
]
=
True
# TODO handle response
return
HttpResponse
(
json
.
dumps
(
resp
),
content_type
=
"application/json"
)
if
request
.
is_ajax
():
return
HttpResponse
(
json
.
dumps
(
resp
),
content_type
=
"application/json"
,
status
=
500
if
resp
.
get
(
'error'
)
else
200
)
else
:
return
redirect
(
reverse_lazy
(
'dashboard.views.detail'
,
resp
))
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