Commit a8f09724 by Bálint Máhonfai

Add export disk operation to disk model

parent 70a151ef
...@@ -469,6 +469,12 @@ class Disk(TimeStampedModel): ...@@ -469,6 +469,12 @@ class Disk(TimeStampedModel):
disk.save() disk.save()
return disk return disk
def export(self, format):
queue_name = self.get_remote_queue_name('storage', priority='slow')
storage_tasks.export.apply_async(
args=[self.get_disk_desc(), format],
queue=queue_name)
def destroy(self, user=None, task_uuid=None): def destroy(self, user=None, task_uuid=None):
if self.destroyed: if self.destroyed:
return False return False
......
...@@ -38,6 +38,11 @@ def download(disk_desc, url): ...@@ -38,6 +38,11 @@ def download(disk_desc, url):
pass pass
@celery.task(name='storagedriver.export')
def export(disk_desc, format):
pass
@celery.task(name='storagedriver.delete') @celery.task(name='storagedriver.delete')
def delete(path): def delete(path):
pass pass
......
...@@ -352,6 +352,19 @@ class DownloadDiskOperation(InstanceOperation): ...@@ -352,6 +352,19 @@ class DownloadDiskOperation(InstanceOperation):
@register_operation @register_operation
class ExportDiskOperation(InstanceOperation):
id = 'export_disk'
name = _('export disk')
description = _('Export disk to VMDK format.')
abortable = True
required_perms = ('storage.export_disk',)
accept_states = ('STOPPED',)
def _operation(self, disk, format='vmdk'):
disk.export(format)
@register_operation
class ImportDiskOperation(InstanceOperation): class ImportDiskOperation(InstanceOperation):
id = 'import_disk' id = 'import_disk'
...@@ -363,20 +376,8 @@ class ImportDiskOperation(InstanceOperation): ...@@ -363,20 +376,8 @@ class ImportDiskOperation(InstanceOperation):
accept_states = ('STOPPED', 'PENDING', 'RUNNING') accept_states = ('STOPPED', 'PENDING', 'RUNNING')
async_queue = 'localhost.man.slow' async_queue = 'localhost.man.slow'
def _operation(self, **kwargs): def _operation(self, activity):
from storage.models import Disk pass
@register_operation
class ExportDiskOperation(InstanceOperation):
id = 'export_disk'
name = _('export disk')
description = _('Export disk to VMDK format.')
required_perms = ('storage.export_disk',)
accept_states = ('STOPPED', 'PENDING', 'RUNNING')
def _operation(self, **kwargs):
from storage.models import Disk
@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