Loading cloudcontrol/node/hypervisor/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -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 Loading cloudcontrol/node/hypervisor/tags.py +9 −0 Original line number Diff line number Diff line Loading @@ -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__) Loading Loading @@ -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 Loading
cloudcontrol/node/hypervisor/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
cloudcontrol/node/hypervisor/tags.py +9 −0 Original line number Diff line number Diff line Loading @@ -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__) Loading Loading @@ -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