Loading cloudcontrol/node/hypervisor/__init__.py +11 −1 Original line number Diff line number Diff line Loading @@ -100,6 +100,11 @@ class Handler(HostHandler): for dom in self.hypervisor.domains.itervalues(): self.tag_db.add_sub_object(dom.name, dom.tags.itervalues()) # we must refresh those tags only when domains tags are registered to # have the calculated values for tag in ('cpualloc', 'cpurunning', 'memalloc', 'memrunning'): self.tag_db['__main__'][tag].update_value() self.rpc_handler.update(dict( vm_define=self.vm_define, vm_undefine=self.vm_undefine, Loading Loading @@ -149,6 +154,10 @@ class Handler(HostHandler): logger.error('Connection to libvirt lost, trying to restart') # update connection state self.virt_connected = False # refresh those tags for tag in ('cpualloc', 'cpurunning', 'memalloc', 'memrunning'): self.tag_db['__main__'][tag].update_value() # unregister tags that will be re registered later for storage in self.hypervisor.storage.storages: self.tag_db.remove_tags(( Loading Loading @@ -817,7 +826,8 @@ class Hypervisor(object): def update_domain_count(self): """Update domain state count tags.""" # update domain state counts for tag in ('nvm', 'vmpaused', 'vmstarted', 'vmstopped'): for tag in ('nvm', 'vmpaused', 'vmstarted', 'vmstopped', 'cpualloc', 'cpurunning', 'memalloc', 'memrunning'): self.handler.tag_db['__main__'][tag].update_value() def vm_define(self, xml_desc): Loading cloudcontrol/node/hypervisor/tags.py +30 −0 Original line number Diff line number Diff line Loading @@ -129,3 +129,33 @@ def vmstarted(handl): def vmstopped(handl): """Count of VMs Stopped.""" return handl.hypervisor.vm_stopped @_check_virt_connected def cpurunning(handl): """CPU total used by running VMs on the hypervisor.""" return sum(int(vm.tags['cpu'].value) for vm in handl.hypervisor.domains.itervalues() if vm.tags['cpu'].value and vm.state == 'running') @_check_virt_connected def cpualloc(handl): """CPU total used by all VMs on the hypervisor.""" return sum(int(vm.tags['cpu'].value) for vm in handl.hypervisor.domains.itervalues() if vm.tags['cpu'].value) @_check_virt_connected def memrunning(handl): """Memory used by running VMs on the hypervisor.""" return sum(int(vm.tags['mem'].value) for vm in handl.hypervisor.domains.itervalues() if vm.tags['mem'].value and vm.state == 'running') @_check_virt_connected def memalloc(handl): """Memory used by all VMs on the hypervisor.""" return sum(int(vm.tags['mem'].value) for vm in handl.hypervisor.domains.itervalues() if vm.tags['mem'].value) Loading
cloudcontrol/node/hypervisor/__init__.py +11 −1 Original line number Diff line number Diff line Loading @@ -100,6 +100,11 @@ class Handler(HostHandler): for dom in self.hypervisor.domains.itervalues(): self.tag_db.add_sub_object(dom.name, dom.tags.itervalues()) # we must refresh those tags only when domains tags are registered to # have the calculated values for tag in ('cpualloc', 'cpurunning', 'memalloc', 'memrunning'): self.tag_db['__main__'][tag].update_value() self.rpc_handler.update(dict( vm_define=self.vm_define, vm_undefine=self.vm_undefine, Loading Loading @@ -149,6 +154,10 @@ class Handler(HostHandler): logger.error('Connection to libvirt lost, trying to restart') # update connection state self.virt_connected = False # refresh those tags for tag in ('cpualloc', 'cpurunning', 'memalloc', 'memrunning'): self.tag_db['__main__'][tag].update_value() # unregister tags that will be re registered later for storage in self.hypervisor.storage.storages: self.tag_db.remove_tags(( Loading Loading @@ -817,7 +826,8 @@ class Hypervisor(object): def update_domain_count(self): """Update domain state count tags.""" # update domain state counts for tag in ('nvm', 'vmpaused', 'vmstarted', 'vmstopped'): for tag in ('nvm', 'vmpaused', 'vmstarted', 'vmstopped', 'cpualloc', 'cpurunning', 'memalloc', 'memrunning'): self.handler.tag_db['__main__'][tag].update_value() def vm_define(self, xml_desc): Loading
cloudcontrol/node/hypervisor/tags.py +30 −0 Original line number Diff line number Diff line Loading @@ -129,3 +129,33 @@ def vmstarted(handl): def vmstopped(handl): """Count of VMs Stopped.""" return handl.hypervisor.vm_stopped @_check_virt_connected def cpurunning(handl): """CPU total used by running VMs on the hypervisor.""" return sum(int(vm.tags['cpu'].value) for vm in handl.hypervisor.domains.itervalues() if vm.tags['cpu'].value and vm.state == 'running') @_check_virt_connected def cpualloc(handl): """CPU total used by all VMs on the hypervisor.""" return sum(int(vm.tags['cpu'].value) for vm in handl.hypervisor.domains.itervalues() if vm.tags['cpu'].value) @_check_virt_connected def memrunning(handl): """Memory used by running VMs on the hypervisor.""" return sum(int(vm.tags['mem'].value) for vm in handl.hypervisor.domains.itervalues() if vm.tags['mem'].value and vm.state == 'running') @_check_virt_connected def memalloc(handl): """Memory used by all VMs on the hypervisor.""" return sum(int(vm.tags['mem'].value) for vm in handl.hypervisor.domains.itervalues() if vm.tags['mem'].value)