Commit 50c045e9 by Guba Sándor Committed by Őry Máté

vm: added has_ercentage and get_percentage to activities

parent 879ccc6c
......@@ -116,6 +116,17 @@ class InstanceActivity(ActivityModel):
else:
return 'failed'
def has_percentage(self):
op = self.instance.get_operation_from_activity_code(self.activity_code)
return (self.task_uuid and op and op.has_percentage
and not self.finished)
def get_percentage(self):
"""Returns the percentage of the running operation if available.
"""
if self.has_percentage():
celery.AsyncResult(id=self.task_uuid).info.get("percent")
@property
def is_abortable(self):
"""Can the activity be aborted?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment