Commit a8f09724 by Bálint Máhonfai

Add export disk operation to disk model

parent 70a151ef
......@@ -469,6 +469,12 @@ class Disk(TimeStampedModel):
disk.save()
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):
if self.destroyed:
return False
......
......@@ -38,6 +38,11 @@ def download(disk_desc, url):
pass
@celery.task(name='storagedriver.export')
def export(disk_desc, format):
pass
@celery.task(name='storagedriver.delete')
def delete(path):
pass
......
......@@ -352,6 +352,19 @@ class DownloadDiskOperation(InstanceOperation):
@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):
id = 'import_disk'
......@@ -363,20 +376,8 @@ class ImportDiskOperation(InstanceOperation):
accept_states = ('STOPPED', 'PENDING', 'RUNNING')
async_queue = 'localhost.man.slow'
def _operation(self, **kwargs):
from storage.models import Disk
@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
def _operation(self, activity):
pass
@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