Commit 3ce45c05 by Szeberényi Imre

vm_priodic task + percentage fix

parent 32dfeb71
......@@ -140,14 +140,14 @@ class InstanceActivity(ActivityModel):
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.
# """
# result = celery.AsyncResult(id=self.task_uuid)
# if self.has_percentage() and result.info is not None:
# return result.info.get("percent")
# else:
# return 0
def get_percentage(self):
"""Returns the percentage of the running operation if available.
"""
result = celery.AsyncResult(id=self.task_uuid)
if self.has_percentage() and result.info is not None:
return result.info.get("percent")
else:
return 0
@property
def is_abortable(self):
......
......@@ -851,10 +851,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
order_by('-started').
select_related('user').prefetch_related('children'))
# Check latest activity for percentage
# for i in acts:
# if i.has_percentage():
# i.has_percent = True
# i.percentage = i.get_percentage()
for i in acts:
if i.has_percentage():
i.has_percent = True
i.percentage = i.get_percentage()
if user is not None:
for i in acts:
i.is_abortable_for_user = partial(i.is_abortable_for,
......
......@@ -23,6 +23,7 @@ from django.conf import settings
from manager.mancelery import celery
from vm.models import Node, Instance
from vm.models.activity import ActivityInProgressError
logger = logging.getLogger(__name__)
......
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