Commit 550924ea by Őry Máté

vm: add non-dummy Node.online code

parent 2703f25a
...@@ -13,6 +13,7 @@ from django.db.models import (Model, ForeignKey, ManyToManyField, IntegerField, ...@@ -13,6 +13,7 @@ from django.db.models import (Model, ForeignKey, ManyToManyField, IntegerField,
from django.utils import timezone from django.utils import timezone
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from celery.exceptions import TimeoutError
from model_utils.models import TimeStampedModel from model_utils.models import TimeStampedModel
from taggit.managers import TaggableManager from taggit.managers import TaggableManager
...@@ -123,9 +124,14 @@ class Node(TimeStampedModel): ...@@ -123,9 +124,14 @@ class Node(TimeStampedModel):
permissions = () permissions = ()
@property @property
@method_cache(30) @method_cache(10, 5)
def online(self): def online(self):
return True r = vm_tasks.ping.apply_async(queue=self.get_remote_queue_name('vm'),
expires=3)
try:
return r.get(timeout=2)
except TimeoutError:
return False
def get_remote_queue_name(self, queue_id): def get_remote_queue_name(self, queue_id):
return self.host.hostname + "." + queue_id return self.host.hostname + "." + queue_id
......
...@@ -59,3 +59,7 @@ def domain_info(params): ...@@ -59,3 +59,7 @@ def domain_info(params):
@celery.task(name='vmdriver.list_domains') @celery.task(name='vmdriver.list_domains')
def list_domains(params): def list_domains(params):
pass pass
@celery.task(name='vmdriver.ping')
def ping(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