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
9bc2639a
authored
Apr 29, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: sort methods
parent
692f0819
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
31 deletions
+31
-31
circle/vm/models/activity.py
+31
-31
No files found.
circle/vm/models/activity.py
View file @
9bc2639a
...
@@ -52,29 +52,8 @@ class InstanceActivity(ActivityModel):
...
@@ -52,29 +52,8 @@ class InstanceActivity(ActivityModel):
return
'{}({})'
.
format
(
self
.
activity_code
,
return
'{}({})'
.
format
(
self
.
activity_code
,
self
.
instance
)
self
.
instance
)
def
get_absolute_url
(
self
):
def
abort
(
self
):
return
reverse
(
'dashboard.views.vm-activity'
,
args
=
[
self
.
pk
])
AbortableAsyncResult
(
self
.
task_uuid
,
backend
=
celery
.
backend
)
.
abort
()
def
get_readable_name
(
self
):
activity_code_last_suffix
=
split_activity_code
(
self
.
activity_code
)[
-
1
]
return
activity_code_last_suffix
.
replace
(
'_'
,
' '
)
.
capitalize
()
def
get_status_id
(
self
):
if
self
.
succeeded
is
None
:
return
'wait'
elif
self
.
succeeded
:
return
'success'
else
:
return
'failed'
@property
def
is_abortable
(
self
):
"""Can the activity be aborted?
:returns: True if the activity can be aborted; otherwise, False.
"""
op
=
self
.
instance
.
get_operation_from_activity_code
(
self
.
activity_code
)
return
self
.
task_uuid
and
op
and
op
.
abortable
and
not
self
.
finished
@classmethod
@classmethod
def
create
(
cls
,
code_suffix
,
instance
,
task_uuid
=
None
,
user
=
None
,
def
create
(
cls
,
code_suffix
,
instance
,
task_uuid
=
None
,
user
=
None
,
...
@@ -104,21 +83,42 @@ class InstanceActivity(ActivityModel):
...
@@ -104,21 +83,42 @@ class InstanceActivity(ActivityModel):
act
.
save
()
act
.
save
()
return
act
return
act
@contextmanager
def
get_absolute_url
(
self
):
def
sub_activity
(
self
,
code_suffix
,
on_abort
=
None
,
on_commit
=
None
,
return
reverse
(
'dashboard.views.vm-activity'
,
args
=
[
self
.
pk
])
task_uuid
=
None
,
concurrency_check
=
True
):
"""Create a transactional context for a nested instance activity.
def
get_readable_name
(
self
):
activity_code_last_suffix
=
split_activity_code
(
self
.
activity_code
)[
-
1
]
return
activity_code_last_suffix
.
replace
(
'_'
,
' '
)
.
capitalize
()
def
get_status_id
(
self
):
if
self
.
succeeded
is
None
:
return
'wait'
elif
self
.
succeeded
:
return
'success'
else
:
return
'failed'
@property
def
is_abortable
(
self
):
"""Can the activity be aborted?
:returns: True if the activity can be aborted; otherwise, False.
"""
"""
act
=
self
.
create_sub
(
code_suffix
,
task_uuid
,
concurrency_check
)
op
=
self
.
instance
.
get_operation_from_activity_code
(
self
.
activity_code
)
return
activitycontextimpl
(
act
,
on_abort
=
on_abort
,
on_commit
=
on_commit
)
return
self
.
task_uuid
and
op
and
op
.
abortable
and
not
self
.
finished
def
save
(
self
,
*
args
,
**
kwargs
):
def
save
(
self
,
*
args
,
**
kwargs
):
ret
=
super
(
InstanceActivity
,
self
)
.
save
(
*
args
,
**
kwargs
)
ret
=
super
(
InstanceActivity
,
self
)
.
save
(
*
args
,
**
kwargs
)
self
.
instance
.
_update_status
()
self
.
instance
.
_update_status
()
return
ret
return
ret
def
abort
(
self
):
@contextmanager
AbortableAsyncResult
(
self
.
task_uuid
,
backend
=
celery
.
backend
)
.
abort
()
def
sub_activity
(
self
,
code_suffix
,
on_abort
=
None
,
on_commit
=
None
,
task_uuid
=
None
,
concurrency_check
=
True
):
"""Create a transactional context for a nested instance activity.
"""
act
=
self
.
create_sub
(
code_suffix
,
task_uuid
,
concurrency_check
)
return
activitycontextimpl
(
act
,
on_abort
=
on_abort
,
on_commit
=
on_commit
)
@contextmanager
@contextmanager
...
...
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