Commit 6a39ca6c by Őry Máté

vm: make cached properties' getters reachable on Node

parent 36e51381
...@@ -54,20 +54,22 @@ class Node(TimeStampedModel): ...@@ -54,20 +54,22 @@ class Node(TimeStampedModel):
def __unicode__(self): def __unicode__(self):
return self.name return self.name
@property
@method_cache(10, 5) @method_cache(10, 5)
def online(self): def get_online(self):
return self.remote_query(vm_tasks.ping, timeout=1, default=False) return self.remote_query(vm_tasks.ping, timeout=1, default=False)
@property online = property(get_online)
@method_cache(300) @method_cache(300)
def num_cores(self): def get_num_cores(self):
"""Number of CPU threads available to the virtual machines. """Number of CPU threads available to the virtual machines.
""" """
return self.remote_query(vm_tasks.get_core_num) return self.remote_query(vm_tasks.get_core_num)
num_cores = property(get_num_cores)
@property @property
def state(self): def state(self):
"""Node state. """Node state.
...@@ -94,14 +96,15 @@ class Node(TimeStampedModel): ...@@ -94,14 +96,15 @@ class Node(TimeStampedModel):
self.enabled = True self.enabled = True
self.save() self.save()
@property
@method_cache(300) @method_cache(300)
def ram_size(self): def get_ram_size(self):
"""Bytes of total memory in the node. """Bytes of total memory in the node.
""" """
return self.remote_query(vm_tasks.get_ram_size) return self.remote_query(vm_tasks.get_ram_size)
ram_size = property(get_ram_size)
@property @property
def ram_size_with_overcommit(self): def ram_size_with_overcommit(self):
"""Bytes of total memory including overcommit margin. """Bytes of total memory including overcommit margin.
......
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