Commit 4c11f5b4 by Máhonfai Bálint

Add filename field to disk export

parent 86c7b4e9
Pipeline #1390 passed with stage
in 0 seconds
...@@ -824,6 +824,7 @@ class VmCreateDiskForm(OperationForm): ...@@ -824,6 +824,7 @@ class VmCreateDiskForm(OperationForm):
class VmDiskExportForm(OperationForm): class VmDiskExportForm(OperationForm):
exported_name = forms.CharField(max_length=100, label=_('Filename'))
disk_format = forms.ChoiceField( disk_format = forms.ChoiceField(
choices=Disk.EXPORT_FORMATS, choices=Disk.EXPORT_FORMATS,
label=_('Format')) label=_('Format'))
...@@ -850,7 +851,9 @@ class VmDiskExportForm(OperationForm): ...@@ -850,7 +851,9 @@ class VmDiskExportForm(OperationForm):
HTML(_("<label>Disk:</label> %s") % escape(self.disk)), HTML(_("<label>Disk:</label> %s") % escape(self.disk)),
css_class="form-group", css_class="form-group",
), ),
Field('disk'), Field('disk_format') Field('disk'),
Field('exported_name'),
Field('disk_format')
) )
return helper return helper
......
...@@ -497,9 +497,7 @@ class Disk(TimeStampedModel): ...@@ -497,9 +497,7 @@ class Disk(TimeStampedModel):
disk.save() disk.save()
return disk return disk
def export(self, disk_format, upload_link, task): def export(self, exported_name, disk_format, upload_link, task):
exported_name = self.name if self.name != '' else self.filename
queue_name = self.get_remote_queue_name('storage', priority='slow') queue_name = self.get_remote_queue_name('storage', priority='slow')
remote = storage_tasks.export_disk.apply_async( remote = storage_tasks.export_disk.apply_async(
kwargs={ kwargs={
......
...@@ -389,10 +389,10 @@ class ExportDiskOperation(InstanceOperation): ...@@ -389,10 +389,10 @@ class ExportDiskOperation(InstanceOperation):
except NoStoreException: except NoStoreException:
raise PermissionDenied raise PermissionDenied
def _operation(self, user, disk, disk_format, task): def _operation(self, user, disk, exported_name, disk_format, task):
store = Store(user) store = Store(user)
upload_link = store.request_upload('/') upload_link = store.request_upload('/')
disk.export(disk_format, upload_link, task) disk.export(exported_name, disk_format, upload_link, task)
@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