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
193b37bd
authored
Mar 13, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-99' into 'master'
Issue 99
parents
ef6ba3f7
40acdf9c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
7 deletions
+50
-7
circle/dashboard/templates/dashboard/vm-detail.html
+14
-7
circle/dashboard/views.py
+9
-0
circle/vm/models/instance.py
+22
-0
circle/vm/tasks/local_tasks.py
+5
-0
No files found.
circle/dashboard/templates/dashboard/vm-detail.html
View file @
193b37bd
...
...
@@ -7,40 +7,47 @@
<div
class=
"pull-right"
style=
"padding-top: 15px;"
>
<form
style=
"display: inline;"
method=
"POST"
action=
"{% url "
dashboard
.
views
.
detail
"
pk=
instance.pk
%}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"sleep"
value=
"dummy"
/>
<input
type=
"hidden"
name=
"sleep"
/>
<button
title=
"{% trans "
Sleep
"
%}"
class=
"btn btn-default btn-xs"
type=
"submit"
><i
class=
"icon-moon"
></i></button>
</form>
<form
style=
"display: inline;"
method=
"POST"
action=
"{% url "
dashboard
.
views
.
detail
"
pk=
instance.pk
%}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"deploy"
value=
"dummy"
/>
<input
type=
"hidden"
name=
"deploy"
/>
<button
title=
"{% trans "
Deploy
"
%}"
class=
"btn btn-default btn-xs"
type=
"submit"
><i
class=
"icon-play"
></i></button>
</form>
<form
style=
"display: inline;"
method=
"POST"
action=
"{% url "
dashboard
.
views
.
detail
"
pk=
instance.pk
%}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"wake_up"
value=
"dummy"
/>
<input
type=
"hidden"
name=
"wake_up"
/>
<button
title=
"{% trans "
Wake
up
"
%}"
class=
"btn btn-default btn-xs"
type=
"submit"
><i
class=
"icon-sun"
></i></button>
</form>
<form
style=
"display: inline;"
method=
"POST"
action=
"{% url "
dashboard
.
views
.
detail
"
pk=
instance.pk
%}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"shut_down"
value=
"dummy"
/>
<input
type=
"hidden"
name=
"shut_down"
/>
<button
title=
"{% trans "
Shut
down
"
%}"
class=
"btn btn-default btn-xs"
type=
"submit"
><i
class=
"icon-off"
></i></button>
</form>
<form
style=
"display: inline;"
method=
"POST"
action=
"{% url "
dashboard
.
views
.
detail
"
pk=
instance.pk
%}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"reboot"
value=
"dummy"
/>
<input
type=
"hidden"
name=
"reboot"
/>
<button
title=
"{% trans "
Reboot
(
ctrl
+
alt
+
del
)"
%}"
class=
"btn btn-default btn-xs"
type=
"submit"
><i
class=
"icon-refresh"
></i></button>
</form>
<form
style=
"display: inline;"
method=
"POST"
action=
"{% url "
dashboard
.
views
.
detail
"
pk=
instance.pk
%}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"reset"
value=
"dummy"
/>
<input
type=
"hidden"
name=
"reset"
/>
<button
title=
"{% trans "
Reset
(
power
cycle
)"
%}"
class=
"btn btn-default btn-xs"
type=
"submit"
><i
class=
"icon-bolt"
></i></button>
</form>
<form
style=
"display: inline;"
method=
"POST"
action=
"{% url "
dashboard
.
views
.
detail
"
pk=
instance.pk
%}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"shut_off"
/>
<button
title=
"{% trans "
Shut
off
"
%}"
class=
"btn btn-default btn-xs"
type=
"submit"
>
<i
class=
"icon-ban-circle"
></i>
</button>
</form>
<a
title=
"Migrate"
data-vm-pk=
"{{ instance.pk }}"
href=
"{% url "
dashboard
.
views
.
vm-migrate
"
pk=
instance.pk
%}"
class=
"btn btn-default btn-xs vm-migrate"
>
<i
class=
"icon-truck"
></i>
</a>
<form
style=
"display: inline;"
method=
"POST"
action=
"{% url "
dashboard
.
views
.
detail
"
pk=
instance.pk
%}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"save_as"
value=
"dummy"
/>
<input
type=
"hidden"
name=
"save_as"
/>
<button
title=
"{% trans "
Save
as
template
"
%}"
class=
"btn btn-default btn-xs"
type=
"submit"
><i
class=
"icon-save"
></i></button>
</form>
<a
title=
"{% trans "
Destroy
"
%}"
href=
"{% url "
dashboard
.
views
.
delete-vm
"
pk=
instance.pk
%}"
class=
"btn btn-default btn-xs vm-delete"
data-vm-pk=
"{{ instance.pk }}"
><i
class=
"icon-remove"
></i></a>
...
...
circle/dashboard/views.py
View file @
193b37bd
...
...
@@ -235,6 +235,7 @@ class VmDetailView(CheckedDetailView):
'deploy'
:
self
.
__deploy
,
'reset'
:
self
.
__reset
,
'reboot'
:
self
.
__reboot
,
'shut_off'
:
self
.
__shut_off
,
}
for
k
,
v
in
options
.
iteritems
():
if
request
.
POST
.
get
(
k
)
is
not
None
:
...
...
@@ -469,6 +470,14 @@ class VmDetailView(CheckedDetailView):
self
.
object
.
reboot_async
(
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__shut_off
(
self
,
request
):
self
.
object
=
self
.
get_object
()
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
self
.
object
.
shut_off_async
(
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
class
NodeDetailView
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DetailView
):
template_name
=
"dashboard/node-detail.html"
...
...
circle/vm/models/instance.py
View file @
193b37bd
...
...
@@ -847,6 +847,28 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
return
local_tasks
.
redeploy
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
def
shut_off
(
self
,
user
=
None
,
task_uuid
=
None
):
"""Shut off VM. (plug-out)
"""
def
__on_commit
(
activity
):
activity
.
resultant_state
=
'STOPPED'
with
instance_activity
(
code_suffix
=
'shut_off'
,
instance
=
self
,
task_uuid
=
task_uuid
,
user
=
user
,
on_commit
=
__on_commit
)
as
act
:
# Destroy VM
if
self
.
node
:
self
.
__destroy_vm
(
act
)
self
.
__cleanup_after_destroy_vm
(
act
)
self
.
save
()
def
shut_off_async
(
self
,
user
=
None
):
"""Shut off VM. (plug-out)
"""
return
local_tasks
.
shut_off
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
def
destroy
(
self
,
user
=
None
,
task_uuid
=
None
):
"""Remove virtual machine and its networks.
...
...
circle/vm/tasks/local_tasks.py
View file @
193b37bd
...
...
@@ -14,6 +14,11 @@ def redeploy(instance, user):
@celery.task
def
shut_off
(
instance
,
user
):
instance
.
shut_off
(
task_uuid
=
shut_off
.
request
.
id
,
user
=
user
)
@celery.task
def
destroy
(
instance
,
user
):
instance
.
destroy
(
task_uuid
=
destroy
.
request
.
id
,
user
=
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