Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
2e3d4c2d
authored
Apr 28, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: abort activities
note: this doesn't work
parent
3304837c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
0 deletions
+32
-0
circle/common/operations.py
+1
-0
circle/dashboard/templates/dashboard/vm-detail/_activity-timeline.html
+8
-0
circle/dashboard/views.py
+11
-0
circle/vm/models/activity.py
+11
-0
circle/vm/operations.py
+1
-0
No files found.
circle/common/operations.py
View file @
2e3d4c2d
...
...
@@ -15,6 +15,7 @@ class Operation(object):
async_queue
=
'localhost.man'
required_perms
=
()
do_not_call_in_templates
=
True
abortable
=
False
def
__call__
(
self
,
**
kwargs
):
return
self
.
call
(
**
kwargs
)
...
...
circle/dashboard/templates/dashboard/vm-detail/_activity-timeline.html
View file @
2e3d4c2d
...
...
@@ -9,6 +9,14 @@
{{ a.get_readable_name }}{% if user.is_superuser %}
</a>
{% endif %}
</strong>
{{ a.started|date:"Y-m-d H:i" }}{% if a.user %}, {{ a.user }}{% endif %}
{% if user.is_superuser and a.is_abortable %}
<form
action=
""
method=
"POST"
class=
"pull-right"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"abort_shutdown"
/>
<input
type=
"hidden"
name=
"activity"
value=
"{{ a.pk }}"
/>
<button
class=
"btn btn-danger btn-xs"
><i
class=
"icon-bolt"
></i>
{% trans "Abort shutdown" %}
</button>
</form>
{% endif %}
{% if a.children.count > 0 %}
<div
class=
"sub-timeline"
>
{% for s in a.children.all %}
...
...
circle/dashboard/views.py
View file @
2e3d4c2d
...
...
@@ -243,6 +243,7 @@ class VmDetailView(CheckedDetailView):
'to_remove'
:
self
.
__remove_tag
,
'port'
:
self
.
__add_port
,
'new_network_vlan'
:
self
.
__new_network
,
'abort_shutdown'
:
self
.
__abort_shutdown
,
}
for
k
,
v
in
options
.
iteritems
():
if
request
.
POST
.
get
(
k
)
is
not
None
:
...
...
@@ -428,6 +429,16 @@ class VmDetailView(CheckedDetailView):
return
redirect
(
"
%
s#network"
%
reverse_lazy
(
"dashboard.views.detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
def
__abort_shutdown
(
self
,
request
):
self
.
object
=
self
.
get_object
()
if
not
request
.
user
.
is_superuser
:
raise
PermissionDenied
()
activity
=
get_object_or_404
(
InstanceActivity
,
pk
=
request
.
POST
.
get
(
"activity"
))
activity
.
abort
()
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
class
OperationView
(
DetailView
):
...
...
circle/vm/models/activity.py
View file @
2e3d4c2d
...
...
@@ -2,6 +2,8 @@ from __future__ import absolute_import, unicode_literals
from
contextlib
import
contextmanager
from
logging
import
getLogger
from
celery.contrib.abortable
import
AbortableAsyncResult
from
django.core.urlresolvers
import
reverse
from
django.db.models
import
CharField
,
ForeignKey
from
django.utils
import
timezone
...
...
@@ -11,6 +13,8 @@ from common.models import (
ActivityModel
,
activitycontextimpl
,
join_activity_code
,
)
from
manager.mancelery
import
celery
logger
=
getLogger
(
__name__
)
...
...
@@ -103,6 +107,13 @@ class InstanceActivity(ActivityModel):
self
.
instance
.
_update_status
()
return
ret
def
is_abortable
(
self
):
op
=
self
.
instance
.
get_operation_from_activity_code
(
self
.
activity_code
)
return
False
if
op
is
None
else
(
op
.
abortable
and
not
self
.
finished
)
def
abort
(
self
):
AbortableAsyncResult
(
self
.
task_uuid
,
backend
=
celery
.
backend
)
.
abort
()
@contextmanager
def
instance_activity
(
code_suffix
,
instance
,
on_abort
=
None
,
on_commit
=
None
,
...
...
circle/vm/operations.py
View file @
2e3d4c2d
...
...
@@ -315,6 +315,7 @@ class ShutdownOperation(InstanceOperation):
id
=
'shutdown'
name
=
_
(
"shutdown"
)
description
=
_
(
"Shutdown virtual machine with ACPI signal."
)
abortable
=
True
def
check_precond
(
self
):
super
(
ShutdownOperation
,
self
)
.
check_precond
()
...
...
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