Commit 31b28ef0 by Bach Dániel

one: GetInstanceStateTask added

parent b459396f
...@@ -229,6 +229,7 @@ CELERY_ROUTES = { ...@@ -229,6 +229,7 @@ CELERY_ROUTES = {
'one.tasks.SaveAsTask': {'queue': 'opennebula'}, 'one.tasks.SaveAsTask': {'queue': 'opennebula'},
'one.tasks.CreateInstanceTask': {'queue': 'opennebula'}, 'one.tasks.CreateInstanceTask': {'queue': 'opennebula'},
'one.tasks.DeleteInstanceTask': {'queue': 'opennebula'}, 'one.tasks.DeleteInstanceTask': {'queue': 'opennebula'},
'one.tasks.GetInstanceStateTask': {'queue': 'opennebula'},
} }
......
...@@ -164,6 +164,10 @@ def t(one_id): ...@@ -164,6 +164,10 @@ def t(one_id):
except: except:
pass pass
@task(name="one.tasks.GetInstanceStateTask")
def t(one_id):
update_state(one_id)
def update_state(one_id): def update_state(one_id):
"""Get and update VM state from OpenNebula.""" """Get and update VM state from OpenNebula."""
proc = subprocess.Popen(["/opt/occi.sh", "compute", "show", proc = subprocess.Popen(["/opt/occi.sh", "compute", "show",
......
from one.models import * from one.models import *
from one.tasks import GetInstanceStateTask
from django_extensions.management.jobs import HourlyJob from django_extensions.management.jobs import HourlyJob
class Job(HourlyJob): class Job(HourlyJob):
...@@ -7,6 +8,6 @@ class Job(HourlyJob): ...@@ -7,6 +8,6 @@ class Job(HourlyJob):
def execute(self): def execute(self):
Disk.update() Disk.update()
Network.update() Network.update()
# for i in Instance.objects.filter(state__in=['ACTIVE', 'STOPPED'], time_of_delete__isnull=False): for i in Instance.objects.filter(state__in=['ACTIVE', 'STOPPED'], time_of_delete__isnull=False, waiting=True):
# i.update_state() GetInstanceStateTask.delay(i.one_id)
pass pass
...@@ -61,3 +61,6 @@ class UpdateNetworkTask(Task): ...@@ -61,3 +61,6 @@ class UpdateNetworkTask(Task):
def run(self): def run(self):
pass pass
class GetInstanceStateTask(Task):
def run(self, one_id):
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