Skip to content
Snippets Groups Projects
Commit 53696d3c authored by Antoine Millet's avatar Antoine Millet
Browse files

Added memremaining tag

parent 012be518
No related branches found
No related tags found
No related merge requests found
......@@ -125,7 +125,7 @@ class Handler(HostHandler):
# we must refresh those tags only when domains tags are registered to
# have the calculated values
for tag in ('cpualloc', 'cpurunning', 'memalloc', 'memrunning'):
for tag in ('cpualloc', 'cpurunning', 'memalloc', 'memrunning', 'memremaining'):
self.tag_db['__main__'][tag].update_value()
# register libvirt handlers
......
......@@ -20,6 +20,7 @@ from functools import wraps
import libvirt
from cloudcontrol.node.utils import and_
from cloudcontrol.common.client.tags import ttl, refresh
logger = logging.getLogger(__name__)
......@@ -175,3 +176,11 @@ def memalloc(handl):
"""Memory used by all VMs on the hypervisor."""
return sum(int(vm.tag_db['__main__']['mem'].value) for vm in
handl.hypervisor.domains.itervalues() if vm.tag_db['__main__']['mem'].value)
@_check_virt_connected
def memremaining(handl):
"""Allocatable memory remaining on the hypervisor."""
mem = int(handl.tag_db['__main__']['mem'].value)
memalloc = int(handl.tag_db['__main__']['memalloc'].value)
return mem - memalloc
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment