Commit b0e7d502 by Őry Máté

vm: move Instance.get_screenshot to ScreenshotOperation

parent cd1b2bc0
...@@ -44,7 +44,7 @@ from common.models import ( ...@@ -44,7 +44,7 @@ from common.models import (
create_readable, HumanReadableException, create_readable, HumanReadableException,
) )
from common.operations import OperatedMixin from common.operations import OperatedMixin
from ..tasks import vm_tasks, agent_tasks from ..tasks import agent_tasks
from .activity import (ActivityInProgressError, instance_activity, from .activity import (ActivityInProgressError, instance_activity,
InstanceActivity) InstanceActivity)
from .common import BaseResourceConfigModel, Lease from .common import BaseResourceConfigModel, Lease
...@@ -835,12 +835,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin, ...@@ -835,12 +835,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
return merged_acts return merged_acts
def get_screenshot(self, timeout=5):
queue_name = self.get_remote_queue_name("vm", "fast")
return vm_tasks.screenshot.apply_async(args=[self.vm_name],
queue=queue_name
).get(timeout=timeout)
def get_latest_activity_in_progress(self): def get_latest_activity_in_progress(self):
try: try:
return InstanceActivity.objects.filter( return InstanceActivity.objects.filter(
......
...@@ -1037,7 +1037,7 @@ class DisableOperation(NodeOperation): ...@@ -1037,7 +1037,7 @@ class DisableOperation(NodeOperation):
@register_operation @register_operation
class ScreenshotOperation(InstanceOperation): class ScreenshotOperation(RemoteInstanceOperation):
id = 'screenshot' id = 'screenshot'
name = _("screenshot") name = _("screenshot")
description = _("Get a screenshot about the virtual machine's console. A " description = _("Get a screenshot about the virtual machine's console. A "
...@@ -1046,9 +1046,7 @@ class ScreenshotOperation(InstanceOperation): ...@@ -1046,9 +1046,7 @@ class ScreenshotOperation(InstanceOperation):
acl_level = "owner" acl_level = "owner"
required_perms = () required_perms = ()
accept_states = ('RUNNING', ) accept_states = ('RUNNING', )
task = vm_tasks.screenshot
def _operation(self):
return self.instance.get_screenshot(timeout=20)
@register_operation @register_operation
......
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