Commit 263a1380 authored by Antoine Millet's avatar Antoine Millet
Browse files

Implemented cpuremaining tag

parent 53696d3c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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', 'memremaining'):
        for tag in ('cpualloc', 'cpurunning', 'cpuremaining', 'memalloc', 'memrunning', 'memremaining'):
            self.tag_db['__main__'][tag].update_value()

        # register libvirt handlers
+8 −0
Original line number Diff line number Diff line
@@ -163,6 +163,14 @@ def cpualloc(handl):
               handl.hypervisor.domains.itervalues() if vm.tag_db['__main__']['cpu'].value)


@_check_virt_connected
def cpuremaining(handl):
    """Allocatable CPU remaining on the hypervisor."""
    cpu = int(handl.tag_db['__main__']['cpu'].value)
    cpualloc = int(handl.tag_db['__main__']['cpualloc'].value)
    return cpu - cpualloc


@_check_virt_connected
def memrunning(handl):
    """Memory used by running VMs on the hypervisor."""