Commit 76a2a4a6 by Szeberényi Imre

Merge branch 'store_fixes' into 'master'

Store and export updates

See merge request !420
parents 649c35f4 4c11f5b4
......@@ -824,6 +824,7 @@ class VmCreateDiskForm(OperationForm):
class VmDiskExportForm(OperationForm):
exported_name = forms.CharField(max_length=100, label=_('Filename'))
disk_format = forms.ChoiceField(
choices=Disk.EXPORT_FORMATS,
label=_('Format'))
......@@ -850,7 +851,9 @@ class VmDiskExportForm(OperationForm):
HTML(_("<label>Disk:</label> %s") % escape(self.disk)),
css_class="form-group",
),
Field('disk'), Field('disk_format')
Field('disk'),
Field('exported_name'),
Field('disk_format')
)
return helper
......
......@@ -49,9 +49,16 @@ class Store(object):
def __init__(self, user, default_timeout=0.5):
self.store_url = settings.STORE_URL
if not self.store_url or not user.profile.org_id:
if not self.store_url:
raise NoStoreException
self.username = 'u-%s' % user.profile.org_id
if user.is_superuser and not user.profile.org_id:
self.username = 'u-admin'
elif not user.profile.org_id:
raise NoStoreException
else:
self.username = 'u-%s' % user.profile.org_id
self.request_args = {'verify': settings.STORE_VERIFY_SSL}
if settings.STORE_SSL_AUTH:
self.request_args['cert'] = (settings.STORE_CLIENT_CERT,
......
......@@ -497,9 +497,7 @@ class Disk(TimeStampedModel):
disk.save()
return disk
def export(self, disk_format, upload_link, task):
exported_name = self.name if self.name != '' else self.filename
def export(self, exported_name, disk_format, upload_link, task):
queue_name = self.get_remote_queue_name('storage', priority='slow')
remote = storage_tasks.export_disk.apply_async(
kwargs={
......
......@@ -389,10 +389,10 @@ class ExportDiskOperation(InstanceOperation):
except NoStoreException:
raise PermissionDenied
def _operation(self, user, disk, disk_format, task):
def _operation(self, user, disk, exported_name, disk_format, task):
store = Store(user)
upload_link = store.request_upload('/')
disk.export(disk_format, upload_link, task)
disk.export(exported_name, disk_format, upload_link, task)
@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