Commit 72393682 by Dudás Ádám

vm: make activity related naming consistent

parent 881f4ad3
...@@ -523,12 +523,11 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -523,12 +523,11 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act.save() act.save()
# Schedule # Schedule
act.update_state('PENDING')
self.node = scheduler.get_node(self, Node.objects.all()) self.node = scheduler.get_node(self, Node.objects.all())
self.save() self.save()
# Create virtual images # Create virtual images
act.update_state('PREPARING DISKS') act.update_state('DEPLOYING DISKS')
for disk in self.disks.all(): for disk in self.disks.all():
disk.deploy() disk.deploy()
...@@ -576,13 +575,15 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -576,13 +575,15 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act.task_uuid = task_uuid act.task_uuid = task_uuid
act.save() act.save()
queue_name = self.node.host.hostname + ".vm" queue_name = self.node.host.hostname + ".vm"
# Delete instance # Destroy virtual machine
act.update_state('DESTROYING VM')
vm_tasks.destroy.apply_async(args=[self.vm_name], vm_tasks.destroy.apply_async(args=[self.vm_name],
queue=queue_name).get() queue=queue_name).get()
# Delete networks # Delete networks
for net in self.interface_set.all(): for net in self.interface_set.all():
net.remove() net.remove()
act.finish(result="DONE")
act.finish(result="SUCCESS")
def destroy_async(self, user=None): def destroy_async(self, user=None):
"""Execute destroy asynchronously. """Execute destroy asynchronously.
...@@ -610,7 +611,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -610,7 +611,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
local_tasks.sleep.apply_async(args=[self, user], queue="localhost.man") local_tasks.sleep.apply_async(args=[self, user], queue="localhost.man")
def wake_up(self, user=None, task_uuid=None): def wake_up(self, user=None, task_uuid=None):
act = InstanceActivity(activity_code='vm.Instance.resume') act = InstanceActivity(activity_code='vm.Instance.wake_up')
act.instance = self act.instance = self
act.user = user act.user = user
act.started = timezone.now() act.started = timezone.now()
...@@ -619,6 +620,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -619,6 +620,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
queue_name = self.node.host.hostname + ".vm" queue_name = self.node.host.hostname + ".vm"
vm_tasks.resume.apply_async(args=[self.vm_name], vm_tasks.resume.apply_async(args=[self.vm_name],
queue=queue_name).get() queue=queue_name).get()
act.finish(result='SUCCESS') act.finish(result='SUCCESS')
def wake_up_async(self, user=None): def wake_up_async(self, user=None):
...@@ -630,7 +632,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -630,7 +632,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
def shutdown(self, user=None, task_uuid=None): def shutdown(self, user=None, task_uuid=None):
"""Shutdown virtual machine with ACPI signal. """Shutdown virtual machine with ACPI signal.
""" """
act = InstanceActivity(activity_code='vm.Instance.power_off') act = InstanceActivity(activity_code='vm.Instance.shutdown')
act.instance = self act.instance = self
act.user = user act.user = user
act.started = timezone.now() act.started = timezone.now()
...@@ -639,6 +641,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -639,6 +641,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
queue_name = self.node.host.hostname + ".vm" queue_name = self.node.host.hostname + ".vm"
vm_tasks.shutdown.apply_async(args=[self.vm_name], vm_tasks.shutdown.apply_async(args=[self.vm_name],
queue=queue_name).get() queue=queue_name).get()
act.finish(result='SUCCESS') act.finish(result='SUCCESS')
def shutdown_async(self, user=None): def shutdown_async(self, user=None):
...@@ -650,7 +653,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -650,7 +653,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
def reset(self, user=None, task_uuid=None): def reset(self, user=None, task_uuid=None):
"""Reset virtual machine (reset button) """Reset virtual machine (reset button)
""" """
act = InstanceActivity(activity_code='vm.Instance.restart') act = InstanceActivity(activity_code='vm.Instance.reset')
act.instance = self act.instance = self
act.user = user act.user = user
act.started = timezone.now() act.started = timezone.now()
...@@ -659,6 +662,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -659,6 +662,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
queue_name = self.node.host.hostname + ".vm" queue_name = self.node.host.hostname + ".vm"
vm_tasks.restart.apply_async(args=[self.vm_name], vm_tasks.restart.apply_async(args=[self.vm_name],
queue=queue_name).get() queue=queue_name).get()
act.finish(result='SUCCESS') act.finish(result='SUCCESS')
def reset_async(self, user=None): def reset_async(self, user=None):
...@@ -679,6 +683,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -679,6 +683,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
queue_name = self.node.host.hostname + ".vm" queue_name = self.node.host.hostname + ".vm"
vm_tasks.reboot.apply_async(args=[self.vm_name], vm_tasks.reboot.apply_async(args=[self.vm_name],
queue=queue_name).get() queue=queue_name).get()
act.finish(result='SUCCESS') act.finish(result='SUCCESS')
def reboot_async(self, user=None): def reboot_async(self, user=None):
......
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