Commit 139b8230 by Guba Sándor

added readable_name params

parent ac493847
...@@ -24,6 +24,8 @@ from django.core.exceptions import PermissionDenied ...@@ -24,6 +24,8 @@ from django.core.exceptions import PermissionDenied
from django.utils import timezone from django.utils import timezone
from django.utils.translation import ugettext_lazy as _, ugettext_noop from django.utils.translation import ugettext_lazy as _, ugettext_noop
from sizefield.utils import filesizeformat
from celery.exceptions import TimeLimitExceeded from celery.exceptions import TimeLimitExceeded
from common.models import create_readable from common.models import create_readable
...@@ -107,7 +109,10 @@ class AddInterfaceOperation(InstanceOperation): ...@@ -107,7 +109,10 @@ class AddInterfaceOperation(InstanceOperation):
managed=managed, owner=user, vlan=vlan) managed=managed, owner=user, vlan=vlan)
if self.instance.is_running: if self.instance.is_running:
with activity.sub_activity('attach_network'): with activity.sub_activity(
'attach_network',
readable_name=ugettext_noop("attach network")
):
self.instance.attach_network(net) self.instance.attach_network(net)
net.deploy() net.deploy()
...@@ -149,14 +154,21 @@ class CreateDiskOperation(InstanceOperation): ...@@ -149,14 +154,21 @@ class CreateDiskOperation(InstanceOperation):
self.instance.disks.add(disk) self.instance.disks.add(disk)
if self.instance.is_running: if self.instance.is_running:
with activity.sub_activity('deploying_disk'): with activity.sub_activity(
'deploying_disk',
readable_name=ugettext_noop("deploying disk")
):
disk.deploy() disk.deploy()
with activity.sub_activity('attach_disk'): with activity.sub_activity(
'attach_disk',
readable_name=ugettext_noop("attach disk")
):
self.instance.attach_disk(disk) self.instance.attach_disk(disk)
def get_activity_name(self, kwargs): def get_activity_name(self, kwargs):
return create_readable(ugettext_noop("create %(size)s disk"), return create_readable(
size=kwargs['size']) ugettext_noop("create disk %(name)s (%(size)s)"),
size=filesizeformat(kwargs['size']), name=kwargs['name'])
register_operation(CreateDiskOperation) register_operation(CreateDiskOperation)
...@@ -193,7 +205,10 @@ class DownloadDiskOperation(InstanceOperation): ...@@ -193,7 +205,10 @@ class DownloadDiskOperation(InstanceOperation):
# TODO iso (cd) hot-plug is not supported by kvm/guests # TODO iso (cd) hot-plug is not supported by kvm/guests
if self.instance.is_running and disk.type not in ["iso"]: if self.instance.is_running and disk.type not in ["iso"]:
with activity.sub_activity('attach_disk'): with activity.sub_activity(
'attach_disk',
readable_name=ugettext_noop("attach disk")
):
self.instance.attach_disk(disk) self.instance.attach_disk(disk)
register_operation(DownloadDiskOperation) register_operation(DownloadDiskOperation)
...@@ -398,13 +413,20 @@ class RemoveInterfaceOperation(InstanceOperation): ...@@ -398,13 +413,20 @@ class RemoveInterfaceOperation(InstanceOperation):
def _operation(self, activity, user, system, interface): def _operation(self, activity, user, system, interface):
if self.instance.is_running: if self.instance.is_running:
with activity.sub_activity('detach_network'): with activity.sub_activity(
'detach_network',
readable_name=ugettext_noop("detach network")
):
self.instance.detach_network(interface) self.instance.detach_network(interface)
interface.shutdown() interface.shutdown()
interface.destroy() interface.destroy()
interface.delete() interface.delete()
def get_activity_name(self, kwargs):
return create_readable(ugettext_noop("remove %(vlan)s interface"),
vlan=kwargs['vlan'])
register_operation(RemoveInterfaceOperation) register_operation(RemoveInterfaceOperation)
...@@ -423,10 +445,20 @@ class RemoveDiskOperation(InstanceOperation): ...@@ -423,10 +445,20 @@ class RemoveDiskOperation(InstanceOperation):
def _operation(self, activity, user, system, disk): def _operation(self, activity, user, system, disk):
if self.instance.is_running and disk.type not in ["iso"]: if self.instance.is_running and disk.type not in ["iso"]:
with activity.sub_activity('detach_disk'): with activity.sub_activity(
'detach_disk',
readable_name=ugettext_noop('detach disk')
):
self.instance.detach_disk(disk) self.instance.detach_disk(disk)
with activity.sub_activity(
'destroy_disk',
readable_name=ugettext_noop('destroy disk')
):
return self.instance.disks.remove(disk) return self.instance.disks.remove(disk)
def get_activity_name(self, kwargs):
return create_readable(ugettext_noop('remove disk %(name)s'),
name=kwargs["disk"].name)
register_operation(RemoveDiskOperation) register_operation(RemoveDiskOperation)
...@@ -523,9 +555,13 @@ class SaveAsTemplateOperation(InstanceOperation): ...@@ -523,9 +555,13 @@ class SaveAsTemplateOperation(InstanceOperation):
return disk return disk
self.disks = [] self.disks = []
with activity.sub_activity('saving_disks',
readable_name=ugettext_noop("save disks")):
for disk in self.instance.disks.all(): for disk in self.instance.disks.all():
with activity.sub_activity(
'saving_disk',
readable_name=create_readable(
ugettext_noop("saving disk %(name)s"),
name=disk.name)
):
self.disks.append(__try_save_disk(disk)) self.disks.append(__try_save_disk(disk))
for disk in self.disks: for disk in self.disks:
......
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