Loading ccnode/hypervisor/__init__.py +14 −6 Original line number Diff line number Diff line import logging import weakref import libvirt Loading @@ -17,10 +18,11 @@ class Handler(HostHandler): def __init__(self, *args, **kwargs): """ :param proxy: sjRpc proxy :param hypervisor_name: hypervisor name """ HostHandler.__init__(self, *args, **kwargs) for t in tag_inspector(tags): for t in tag_inspector(tags, self): self.tags[t.name] = t # set tag hv Loading @@ -29,7 +31,9 @@ class Handler(HostHandler): # initialize hypervisor instance global hypervisor if hypervisor is None: hypervisor = Hypervisor() hypervisor = Hypervisor(kwargs.pop('hypervisor_name', None)) self.hypervisor = weakref.proxy(hypervisor) # register domains proxy = kwargs.pop('proxy') Loading Loading @@ -74,7 +78,11 @@ class Handler(HostHandler): class Hypervisor(object): """Container for all hypervisor related state.""" def __init__(self): def __init__(self, name=None): #: hv attributes self.name = name self.type = u'kvm' self.event_loop = EventLoop() # This tells libvirt what event loop implementation it # should use Loading Loading @@ -135,17 +143,17 @@ class Hypervisor(object): @property def vm_started(self): """Number of VMs started.""" return self._count_domain(lambda d: d.status == 'started') return self._count_domain(lambda d: d.state == 'running') @property def vm_stopped(self): """Number of VMs stopped.""" return self._count_domain(lambda d: d.status == 'stopped') return self._count_domain(lambda d: d.state == 'stopped') @property def vm_paused(self): """Number of VMs paused.""" return self._count_domain(lambda d: d.status == 'paused') return self._count_domain(lambda d: d.state == 'paused') @property def vm_total(self): Loading ccnode/hypervisor/tags.py +13 −5 Original line number Diff line number Diff line from ccnode.hypervisor import lib as libvirt_ from ccnode.utils import and_ Loading @@ -8,10 +9,11 @@ def htype(): return u'kvm' def hv(): def hv(handl): """Hypervisor name.""" # What is the point of this tag ? if the information not already in a and id # ? return handl.hypervisor.name def hvm(): Loading Loading @@ -39,10 +41,12 @@ def hvm(): def hvver(): """Hypervisor version.""" return libvirt_.connection.getVersion() def libvirtver(): """Version of running libvirt.""" return libvirt_.connection.getLibVersion() # jobs Loading @@ -58,17 +62,21 @@ def sto(): # dynamic sto # Vm related tags def nvm(): def nvm(handl): """Number of VMS in the current hypervisor.""" return handl.hypervisor.vm_total def vmpaused(): def vmpaused(handl): """Count of VMs paused.""" return handl.hypervisor.vm_paused def vmstarted(): def vmstarted(handl): """Count of VMs started.""" return handl.hypervisor.vm_started def vmstopped(): def vmstopped(handl): """Count of VMs Stopped.""" return handl.hypervisor.vm_stopped ccnode/node.py +2 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ class Node(Thread): elif role == u'hv': logger.debug(u'Role hypervisor affected.') from ccnode.hypervisor import Handler as HypervisorHandler self.connection.rpc.set_handler(HypervisorHandler(proxy=self.proxy)) self.connection.rpc.set_handler(HypervisorHandler( proxy=self.proxy, hypervisor_name=self.user_name)) self.role = u'hv' else: logger.debug(u'Wrong role returned: %s', role) Loading Loading
ccnode/hypervisor/__init__.py +14 −6 Original line number Diff line number Diff line import logging import weakref import libvirt Loading @@ -17,10 +18,11 @@ class Handler(HostHandler): def __init__(self, *args, **kwargs): """ :param proxy: sjRpc proxy :param hypervisor_name: hypervisor name """ HostHandler.__init__(self, *args, **kwargs) for t in tag_inspector(tags): for t in tag_inspector(tags, self): self.tags[t.name] = t # set tag hv Loading @@ -29,7 +31,9 @@ class Handler(HostHandler): # initialize hypervisor instance global hypervisor if hypervisor is None: hypervisor = Hypervisor() hypervisor = Hypervisor(kwargs.pop('hypervisor_name', None)) self.hypervisor = weakref.proxy(hypervisor) # register domains proxy = kwargs.pop('proxy') Loading Loading @@ -74,7 +78,11 @@ class Handler(HostHandler): class Hypervisor(object): """Container for all hypervisor related state.""" def __init__(self): def __init__(self, name=None): #: hv attributes self.name = name self.type = u'kvm' self.event_loop = EventLoop() # This tells libvirt what event loop implementation it # should use Loading Loading @@ -135,17 +143,17 @@ class Hypervisor(object): @property def vm_started(self): """Number of VMs started.""" return self._count_domain(lambda d: d.status == 'started') return self._count_domain(lambda d: d.state == 'running') @property def vm_stopped(self): """Number of VMs stopped.""" return self._count_domain(lambda d: d.status == 'stopped') return self._count_domain(lambda d: d.state == 'stopped') @property def vm_paused(self): """Number of VMs paused.""" return self._count_domain(lambda d: d.status == 'paused') return self._count_domain(lambda d: d.state == 'paused') @property def vm_total(self): Loading
ccnode/hypervisor/tags.py +13 −5 Original line number Diff line number Diff line from ccnode.hypervisor import lib as libvirt_ from ccnode.utils import and_ Loading @@ -8,10 +9,11 @@ def htype(): return u'kvm' def hv(): def hv(handl): """Hypervisor name.""" # What is the point of this tag ? if the information not already in a and id # ? return handl.hypervisor.name def hvm(): Loading Loading @@ -39,10 +41,12 @@ def hvm(): def hvver(): """Hypervisor version.""" return libvirt_.connection.getVersion() def libvirtver(): """Version of running libvirt.""" return libvirt_.connection.getLibVersion() # jobs Loading @@ -58,17 +62,21 @@ def sto(): # dynamic sto # Vm related tags def nvm(): def nvm(handl): """Number of VMS in the current hypervisor.""" return handl.hypervisor.vm_total def vmpaused(): def vmpaused(handl): """Count of VMs paused.""" return handl.hypervisor.vm_paused def vmstarted(): def vmstarted(handl): """Count of VMs started.""" return handl.hypervisor.vm_started def vmstopped(): def vmstopped(handl): """Count of VMs Stopped.""" return handl.hypervisor.vm_stopped
ccnode/node.py +2 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ class Node(Thread): elif role == u'hv': logger.debug(u'Role hypervisor affected.') from ccnode.hypervisor import Handler as HypervisorHandler self.connection.rpc.set_handler(HypervisorHandler(proxy=self.proxy)) self.connection.rpc.set_handler(HypervisorHandler( proxy=self.proxy, hypervisor_name=self.user_name)) self.role = u'hv' else: logger.debug(u'Wrong role returned: %s', role) Loading