Commit 6e78d75a by Bach Dániel

manager: use data from monitor in scheduler

parent 6fe3ab17
...@@ -50,9 +50,7 @@ def has_enough_ram(ram_size, node): ...@@ -50,9 +50,7 @@ def has_enough_ram(ram_size, node):
"""True, if the node has enough memory to accomodate a guest requiring """True, if the node has enough memory to accomodate a guest requiring
ram_size mebibytes of memory; otherwise, false. ram_size mebibytes of memory; otherwise, false.
""" """
total = node.ram_size unused = node.ram_size * (1 - node.ram_usage)
used = 512 # TODO replace mock value with data from monitor
unused = total - used
overcommit = node.ram_size_with_overcommit overcommit = node.ram_size_with_overcommit
reserved = node.instance_set.aggregate(r=Sum('ram_size'))['r'] or 0 reserved = node.instance_set.aggregate(r=Sum('ram_size'))['r'] or 0
...@@ -66,7 +64,7 @@ def free_cpu_time(node): ...@@ -66,7 +64,7 @@ def free_cpu_time(node):
Higher values indicate more idle time. Higher values indicate more idle time.
""" """
activity = 0 activity = node.cpu_usage
inactivity = 1 - activity inactivity = 1 - activity
cores = node.num_cores cores = node.num_cores
return cores * inactivity # TODO replace mock value with data from monitor return cores * inactivity
...@@ -163,11 +163,13 @@ class Node(TimeStampedModel): ...@@ -163,11 +163,13 @@ class Node(TimeStampedModel):
collected[metric] = cache collected[metric] = cache
return collected return collected
@property
def cpu_usage(self): def cpu_usage(self):
return self.get_monitor_info()["cpu.usage"] return float(self.get_monitor_info()["cpu.usage"]) / 100
@property
def ram_usage(self): def ram_usage(self):
return self.get_monitor_info()["memory.usage"] return float(self.get_monitor_info()["memory.usage"]) / 100
def update_vm_states(self): def update_vm_states(self):
domains = {} domains = {}
......
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