diff --git a/circle/vm/models/activity.py b/circle/vm/models/activity.py index 90b6c22..b0cd1ac 100644 --- a/circle/vm/models/activity.py +++ b/circle/vm/models/activity.py @@ -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?