Commit d8650c62 by Dudás Ádám

vm, storage: reorder and add comments to *_async methods

parent 7b28a03d
...@@ -113,9 +113,6 @@ class Disk(TimeStampedModel): ...@@ -113,9 +113,6 @@ class Disk(TimeStampedModel):
def __unicode__(self): def __unicode__(self):
return u"%s (#%d)" % (self.name, self.id) return u"%s (#%d)" % (self.name, self.id)
def deploy_async(self):
local_tasks.deploy.apply_async(self)
def deploy(self): def deploy(self):
"""Reify the disk model on the associated data store. """Reify the disk model on the associated data store.
...@@ -143,6 +140,11 @@ class Disk(TimeStampedModel): ...@@ -143,6 +140,11 @@ class Disk(TimeStampedModel):
self.save() self.save()
return True return True
def deploy_async(self):
"""Execute deploy asynchronously.
"""
local_tasks.deploy.apply_async(self)
def delete(self): def delete(self):
# TODO # TODO
# StorageDriver.delete_disk.delay(instance.to_json()).get() # StorageDriver.delete_disk.delay(instance.to_json()).get()
......
...@@ -476,12 +476,6 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -476,12 +476,6 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
'raw_data': "" if not self.raw_data else self.raw_data 'raw_data': "" if not self.raw_data else self.raw_data
} }
def deploy_async(self, user=None):
""" Launch celery task to handle the job asynchronously.
"""
local_tasks.deploy.apply_async(args=[self, user],
queue="localhost.man")
def deploy(self, user=None, task_uuid=None): def deploy(self, user=None, task_uuid=None):
""" Deploy new virtual machine with network """ Deploy new virtual machine with network
1. Schedule 1. Schedule
...@@ -521,8 +515,11 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -521,8 +515,11 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act.finish(result='SUCCESS') act.finish(result='SUCCESS')
def stop_async(self, user=None): def deploy_async(self, user=None):
local_tasks.stop.apply_async(args=[self, user], queue="localhost.man") """Execute deploy asynchronously.
"""
local_tasks.deploy.apply_async(args=[self, user],
queue="localhost.man")
def stop(self, user=None, task_uuid=None): def stop(self, user=None, task_uuid=None):
act = InstanceActivity(activity_code='vm.Instance.stop') act = InstanceActivity(activity_code='vm.Instance.stop')
...@@ -535,9 +532,10 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -535,9 +532,10 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
remote_tasks.stop.apply_async(args=[self.get_vm_desc()], remote_tasks.stop.apply_async(args=[self.get_vm_desc()],
queue=queue_name).get() queue=queue_name).get()
def resume_async(self, user=None): def stop_async(self, user=None):
local_tasks.resume.apply_async(args=[self, user], """Execute stop asynchronously.
queue="localhost.man") """
local_tasks.stop.apply_async(args=[self, user], queue="localhost.man")
def resume(self, user=None, task_uuid=None): def resume(self, user=None, task_uuid=None):
act = InstanceActivity(activity_code='vm.Instance.resume') act = InstanceActivity(activity_code='vm.Instance.resume')
...@@ -550,8 +548,10 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -550,8 +548,10 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
remote_tasks.resume.apply_async(args=[self.vm_name], remote_tasks.resume.apply_async(args=[self.vm_name],
queue=queue_name).get() queue=queue_name).get()
def poweroff_async(self, user=None): def resume_async(self, user=None):
local_tasks.power_off.apply_async(args=[self, user], """Execute resume asynchronously.
"""
local_tasks.resume.apply_async(args=[self, user],
queue="localhost.man") queue="localhost.man")
def poweroff(self, user=None, task_uuid=None): def poweroff(self, user=None, task_uuid=None):
...@@ -565,8 +565,10 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -565,8 +565,10 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
remote_tasks.power_off.apply_async(args=[self.get_vm_desc()], remote_tasks.power_off.apply_async(args=[self.get_vm_desc()],
queue=queue_name).get() queue=queue_name).get()
def restart_async(self, user=None): def poweroff_async(self, user=None):
local_tasks.restart.apply_async(args=[self, user], """Execute poweroff asynchronously.
"""
local_tasks.power_off.apply_async(args=[self, user],
queue="localhost.man") queue="localhost.man")
def restart(self, user=None, task_uuid=None): def restart(self, user=None, task_uuid=None):
...@@ -580,8 +582,10 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -580,8 +582,10 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
remote_tasks.restart.apply_async(args=[self.get_vm_desc()], remote_tasks.restart.apply_async(args=[self.get_vm_desc()],
queue=queue_name).get() queue=queue_name).get()
def save_as_async(self, user=None): def restart_async(self, user=None):
local_tasks.save_as.apply_async(args=[self, user], """Execute restart asynchronously.
"""
local_tasks.restart.apply_async(args=[self, user],
queue="localhost.man") queue="localhost.man")
def save_as(self, user=None, task_uuid=None): def save_as(self, user=None, task_uuid=None):
...@@ -595,6 +599,12 @@ class Instance(BaseResourceConfigModel, TimeStampedModel): ...@@ -595,6 +599,12 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
remote_tasks.save_as.apply_async(args=[self.get_vm_desc()], remote_tasks.save_as.apply_async(args=[self.get_vm_desc()],
queue=queue_name).get() queue=queue_name).get()
def save_as_async(self, user=None):
"""Execute save_as asynchronously.
"""
local_tasks.save_as.apply_async(args=[self, user],
queue="localhost.man")
def renew(self, which='both'): def renew(self, which='both'):
"""Renew virtual machine instance leases. """Renew virtual machine instance leases.
""" """
......
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