Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
12 deletions
+39
-12
circle/dashboard/static/dashboard/vm-create.js
+11
-3
circle/dashboard/templates/dashboard/vm-detail.html
+1
-1
circle/dashboard/views.py
+27
-8
No files found.
circle/dashboard/static/dashboard/vm-create.js
View file @
0d5684f5
...
@@ -6,8 +6,7 @@ $(function() {
...
@@ -6,8 +6,7 @@ $(function() {
});
});
function
vmCreateLoaded
()
{
function
vmCreateLoaded
()
{
// temporarily disable for testing
$
(
'.vm-create-advanced'
).
hide
();
//$('.vm-create-advanced').hide();
$
(
'.vm-create-advanced-btn'
).
click
(
function
()
{
$
(
'.vm-create-advanced-btn'
).
click
(
function
()
{
$
(
'.vm-create-advanced'
).
stop
().
slideToggle
();
$
(
'.vm-create-advanced'
).
stop
().
slideToggle
();
if
(
$
(
'.vm-create-advanced-icon'
).
hasClass
(
'icon-caret-down'
))
{
if
(
$
(
'.vm-create-advanced-icon'
).
hasClass
(
'icon-caret-down'
))
{
...
@@ -178,7 +177,16 @@ function vmCreateLoaded() {
...
@@ -178,7 +177,16 @@ function vmCreateLoaded() {
type
:
'POST'
,
type
:
'POST'
,
data
:
$
(
'form'
).
serialize
(),
data
:
$
(
'form'
).
serialize
(),
success
:
function
(
data
,
textStatus
,
xhr
)
{
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
;
return
false
;
...
...
circle/dashboard/templates/dashboard/vm-detail.html
View file @
0d5684f5
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
{% block content %}
{% block content %}
<div
class=
"body-content"
>
<div
class=
"body-content"
>
<div
class=
"page-header"
>
<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>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-4"
id=
"vm-info-pane"
>
<div
class=
"col-md-4"
id=
"vm-info-pane"
>
...
...
circle/dashboard/views.py
View file @
0d5684f5
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.views.generic
import
TemplateView
,
DetailView
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
tables
import
VmListTable
from
vm.models
import
Instance
,
InstanceTemplate
,
InterfaceTemplate
from
vm.models
import
Instance
,
InstanceTemplate
,
InterfaceTemplate
...
@@ -121,21 +123,38 @@ class VmCreate(TemplateView):
...
@@ -121,21 +123,38 @@ class VmCreate(TemplateView):
return
context
return
context
# TODO handle not ajax posts
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
self
.
request
.
user
.
is_authenticated
():
if
self
.
request
.
user
.
is_authenticated
():
user
=
self
.
request
.
user
user
=
self
.
request
.
user
else
:
else
:
user
=
None
user
=
None
resp
=
request
.
POST
.
copy
()
resp
=
{}
resp
[
'managed-vlans'
]
=
request
.
POST
.
getlist
(
'managed-vlans'
)
try
:
resp
[
'unmanaged-vlans'
]
=
request
.
POST
.
getlist
(
'unmanaged-vlans'
)
ikwargs
=
{
resp
[
'disks'
]
=
request
.
POST
.
getlist
(
'disks'
)
'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
(
template
=
InstanceTemplate
.
objects
.
get
(
pk
=
request
.
POST
.
get
(
'template-pk'
))
pk
=
request
.
POST
.
get
(
'template-pk'
))
inst
=
Instance
.
create_from_template
(
template
=
template
,
owner
=
user
)
inst
=
Instance
.
create_from_template
(
template
=
template
,
owner
=
user
,
**
ikwargs
)
inst
.
deploy_async
()
inst
.
deploy_async
()
# TODO handle response
resp
[
'pk'
]
=
inst
.
pk
return
HttpResponse
(
json
.
dumps
(
resp
),
content_type
=
"application/json"
)
except
InstanceTemplate
.
DoesNotExist
:
resp
[
'error'
]
=
True
except
:
resp
[
'error'
]
=
True
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