Commit bf61b653 by Bach Dániel

one: GetInstanceStateTask added

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