Commit 9c7ba32e by Guba Sándor

vm: refactoring tasks names

parent ba62e349
......@@ -530,30 +530,56 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act.finish(result='SUCCESS')
def destroy(self, user=None, task_uuid=None):
""" Remove Instance with its networks.
"""
act = InstanceActivity(activity_code='vm.Instance.destroy')
act.instance = self
act.user = user
act.started = timezone.now()
act.task_uuid = task_uuid
act.save()
queue_name = self.node.host.hostname + ".vm"
# Delete instance
vm_tasks.destroy.apply_async(args=[self.vm_name],
queue=queue_name).get()
# Delete networks
for net in self.interface_set.all():
net.remove()
act.finish(result="DONE")
def destroy_async(self, user=None):
"""Execute destroy() asyncrhonusly.
"""
local_tasks.destroy.apply_async(args=[self, user],
queue="localhost.man")
def deploy_async(self, user=None):
"""Execute deploy asynchronously.
"""Execute deploy() asynchronously.
"""
local_tasks.deploy.apply_async(args=[self, user],
queue="localhost.man")
def stop(self, user=None, task_uuid=None):
act = InstanceActivity(activity_code='vm.Instance.stop')
def sleep(self, user=None, task_uuid=None):
"""Suspend virtual machine with memory dump.
"""
act = InstanceActivity(activity_code='vm.Instance.sleep')
act.instance = self
act.user = user
act.started = timezone.now()
act.task_uuid = task_uuid
act.save()
queue_name = self.node.host.hostname + ".vm"
vm_tasks.stop.apply_async(args=[self.vm_name],
queue=queue_name).get()
vm_tasks.sleep.apply_async(args=[self.vm_name],
queue=queue_name).get()
act.finish(result='SUCCESS')
def stop_async(self, user=None):
"""Execute stop asynchronously.
def sleep_async(self, user=None):
"""Execute suspend() asynchronously.
"""
local_tasks.stop.apply_async(args=[self, user], queue="localhost.man")
local_tasks.sleep.apply_async(args=[self, user], queue="localhost.man")
def resume(self, user=None, task_uuid=None):
def wake_up(self, user=None, task_uuid=None):
act = InstanceActivity(activity_code='vm.Instance.resume')
act.instance = self
act.user = user
......@@ -565,13 +591,15 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
queue=queue_name).get()
act.finish(result='SUCCESS')
def resume_async(self, user=None):
"""Execute resume asynchronously.
def wake_up_async(self, user=None):
"""Execute resume() asynchronously.
"""
local_tasks.resume.apply_async(args=[self, user],
queue="localhost.man")
def poweroff(self, user=None, task_uuid=None):
def shutdown(self, user=None, task_uuid=None):
"""Shutdown virtual machine with ACPI signal.
"""
act = InstanceActivity(activity_code='vm.Instance.power_off')
act.instance = self
act.user = user
......@@ -579,17 +607,19 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act.task_uuid = task_uuid
act.save()
queue_name = self.node.host.hostname + ".vm"
vm_tasks.power_off.apply_async(args=[self.vm_name],
queue=queue_name).get()
vm_tasks.shutdown.apply_async(args=[self.vm_name],
queue=queue_name).get()
act.finish(result='SUCCESS')
def poweroff_async(self, user=None):
"""Execute poweroff asynchronously.
def shutdown_async(self, user=None):
"""Execute shutdown asynchronously.
"""
local_tasks.power_off.apply_async(args=[self, user],
queue="localhost.man")
local_tasks.shutdown.apply_async(args=[self, user],
queue="localhost.man")
def restart(self, user=None, task_uuid=None):
def reset(self, user=None, task_uuid=None):
"""Reset virtual machine (reset button)
"""
act = InstanceActivity(activity_code='vm.Instance.restart')
act.instance = self
act.user = user
......@@ -601,52 +631,30 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
queue=queue_name).get()
act.finish(result='SUCCESS')
def restart_async(self, user=None):
"""Execute restart asynchronously.
def reset_async(self, user=None):
"""Execute reset asynchronously.
"""
local_tasks.restart.apply_async(args=[self, user],
queue="localhost.man")
def save_as(self, user=None, task_uuid=None):
act = InstanceActivity(activity_code='vm.Instance.restart')
act.instance = self
act.user = user
act.started = timezone.now()
act.task_uuid = task_uuid
act.save()
queue_name = self.node.host.hostname + ".vm"
vm_tasks.save_as.apply_async(args=[self.vm_name],
queue=queue_name).get()
act.finish(result='SUCCESS')
def save_as_async(self, user=None, task_uuid=None):
"""Execute save_as asynchronously.
def reboot(self, user=None, task_uuid=None):
"""Reboot virtual machin with ctr+alt+del signal.
"""
local_tasks.save_as.apply_async(args=[self, user],
queue="localhost.man")
def remove(self, user=None, task_uuid=None):
""" Remove Instance with its networks.
"""
act = InstanceActivity(activity_code='vm.Instance.remove')
act = InstanceActivity(activity_code='vm.Instance.reboot')
act.instance = self
act.user = user
act.started = timezone.now()
act.task_uuid = task_uuid
act.save()
queue_name = self.node.host.hostname + ".vm"
# Delete instance
vm_tasks.delete.apply_async(args=[self.vm_name],
vm_tasks.reboot.apply_async(args=[self.vm_name],
queue=queue_name).get()
# Delete networks
for net in self.interface_set.all():
net.remove()
act.finish(result="DONE")
act.finish(result='SUCCESS')
def remove_async(self, user=None):
""" Asyncron remove()
def reboot_async(self, user=None):
"""Execute reboot asynchronously.
"""
local_tasks.delete.apply_async(args=[self, user],
local_tasks.reboot.apply_async(args=[self, user],
queue="localhost.man")
def renew(self, which='both'):
......@@ -735,8 +743,8 @@ class Interface(Model):
args=[self.get_vmnetwork_desc()],
queue=self.instance.node.host.hostname + '.net')
def remove(self, user=None, task_uuid=None):
net_tasks.delete.apply_async(
def destroy(self, user=None, task_uuid=None):
net_tasks.destroy.apply_async(
args=[self.get_vmnetwork_desc()],
queue=self.instance.node.host.hostname + '.net')
......
from manager.mancelery import celery
# TODO: Keep syncronhised with Instance funcs
@celery.task
def deploy(instance, user):
'''Create new virtual machine from VM class.
''' Call Insance.deploy() from celery task.
'''
instance.deploy(task_uuid=deploy.request.id, user=user)
def delete():
def destroy():
pass
......
......@@ -7,5 +7,5 @@ def create(params):
@celery.task(name='netdriver.delete')
def delete(params):
def destroy(params):
pass
......@@ -2,52 +2,47 @@ from manager.mancelery import celery
@celery.task(name='vmdriver.create')
def create(params):
def deploy(params):
pass
@celery.task(name='vmdriver.suspend')
def stop(params):
pass
@celery.task(name='vmdriver.resume')
def resume(params):
@celery.task(name='vmdriver.delete')
def destroy(params):
pass
@celery.task(name='vmdriver.delete')
def poweroff(params):
@celery.task(name='vmdriver.save')
def sleep(params):
pass
@celery.task(name='vmdriver.shutdown')
def shutdown(params):
@celery.task(name='vmdriver.restore')
def wake_up(params):
pass
@celery.task(name='vmdriver.reset')
def reset(params):
@celery.task(name='vmdriver.suspend')
def suspend(params):
pass
@celery.task(name='vmdriver.start')
def restart(params):
@celery.task(name='vmdriver.resume')
def resume(params):
pass
@celery.task(name='vmdriver.reboot')
def reboot(params):
@celery.task(name='vmdriver.shutdown')
def shutdown(params):
pass
@celery.task(name='vmdriver.save')
def save(params):
@celery.task(name='vmdriver.reset')
def reset(params):
pass
@celery.task(name='vmdriver.restore')
def restore(params):
@celery.task(name='vmdriver.reboot')
def reboot(params):
pass
......@@ -64,8 +59,3 @@ def domain_info(params):
@celery.task(name='vmdriver.list_domains')
def list_domains(params):
pass
@celery.task(name='vmdriver.delete')
def delete(params):
pass
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