Loading ccnode/handlers.py +28 −13 Original line number Diff line number Diff line # -*- coding: utf-8 -*- from __init__ import __version__ from common import LocalHost from sjrpc.utils import RpcHandler from sjrpc.utils import pure from logging import debug, info from exceptions import FeatureNotImplemented from fnmatch import fnmatchcase from exceptions import FeatureNotImplemented from common import LocalHost _MOD_KVM = True try: import kvm except ImportError: _MOD_KVM = False else: _MOD_KVM = True _MOD_XEN = True try: import xen except ImportError: _MOD_XEN = False class NodeHandler(RpcHandler): Loading @@ -27,15 +34,22 @@ class NodeHandler(RpcHandler): self._connection = connection self._allow_cmd_exec = allow_exec if not detect_hv: debug('Hypervisor detection disabled, running as regular' ' node') self._host_handle = LocalHost() else: self._host_handle = None if detect_hv: debug('Hypervisor detection in progress') if _MOD_KVM: debug('Hypervisor detection...') debug('Initializing connection to the KVM hypervisor') debug('Initializing connection to the local KVM hypervisor') self._host_handle = kvm.KvmHypervisor() elif _MOD_XEN: debug('Initializing connection to the local Xen hypervisor') self._host_handle = xen.XenHypervisor() if self._host_handle is None: debug('Hypervisor detection failed') if not detect_hv or self._host_handle is None: debug('Hypervisor detection disabled, running as regular node') self._host_handle = LocalHost() self.EXEC_METHODS = ['execute_command', 'shutdown'] Loading @@ -55,7 +69,8 @@ class NodeHandler(RpcHandler): 'uname' : self._tag_map_direct('get_uname'), 'uptime' : self._tag_map_direct('get_uptime'), 'hvm' : self._tag_map_direct('get_hvm_available'), 'libvirtver': self._tag_map_direct('get_hv_version'), 'libvirtver': self._tag_map_direct('get_libvirt_version'), 'hvver' : self._tag_map_direct('get_hv_version'), 'load' : self._tag_map_direct('get_loadavg'), 'cpu' : self._tag_map_direct('get_cpu'), 'cpucore' : self._tag_map_direct('get_cpu_core'), Loading ccnode/libvirtwrapper.py +2 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ class LibvirtHypervisor(Hypervisor): try: if hv_type == 'kvm': self._lvcon_handle = libvirt.open(KVM_LIBVIRT_SESSION) elif hv_type == 'xen': self._lvcon_handle = libvirt.open(KVM_LIBVIRT_SESSION) else: raise NotImplemented('Unknown hypervisor type') except libvirt.libvirtError as error: Loading Loading
ccnode/handlers.py +28 −13 Original line number Diff line number Diff line # -*- coding: utf-8 -*- from __init__ import __version__ from common import LocalHost from sjrpc.utils import RpcHandler from sjrpc.utils import pure from logging import debug, info from exceptions import FeatureNotImplemented from fnmatch import fnmatchcase from exceptions import FeatureNotImplemented from common import LocalHost _MOD_KVM = True try: import kvm except ImportError: _MOD_KVM = False else: _MOD_KVM = True _MOD_XEN = True try: import xen except ImportError: _MOD_XEN = False class NodeHandler(RpcHandler): Loading @@ -27,15 +34,22 @@ class NodeHandler(RpcHandler): self._connection = connection self._allow_cmd_exec = allow_exec if not detect_hv: debug('Hypervisor detection disabled, running as regular' ' node') self._host_handle = LocalHost() else: self._host_handle = None if detect_hv: debug('Hypervisor detection in progress') if _MOD_KVM: debug('Hypervisor detection...') debug('Initializing connection to the KVM hypervisor') debug('Initializing connection to the local KVM hypervisor') self._host_handle = kvm.KvmHypervisor() elif _MOD_XEN: debug('Initializing connection to the local Xen hypervisor') self._host_handle = xen.XenHypervisor() if self._host_handle is None: debug('Hypervisor detection failed') if not detect_hv or self._host_handle is None: debug('Hypervisor detection disabled, running as regular node') self._host_handle = LocalHost() self.EXEC_METHODS = ['execute_command', 'shutdown'] Loading @@ -55,7 +69,8 @@ class NodeHandler(RpcHandler): 'uname' : self._tag_map_direct('get_uname'), 'uptime' : self._tag_map_direct('get_uptime'), 'hvm' : self._tag_map_direct('get_hvm_available'), 'libvirtver': self._tag_map_direct('get_hv_version'), 'libvirtver': self._tag_map_direct('get_libvirt_version'), 'hvver' : self._tag_map_direct('get_hv_version'), 'load' : self._tag_map_direct('get_loadavg'), 'cpu' : self._tag_map_direct('get_cpu'), 'cpucore' : self._tag_map_direct('get_cpu_core'), Loading
ccnode/libvirtwrapper.py +2 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ class LibvirtHypervisor(Hypervisor): try: if hv_type == 'kvm': self._lvcon_handle = libvirt.open(KVM_LIBVIRT_SESSION) elif hv_type == 'xen': self._lvcon_handle = libvirt.open(KVM_LIBVIRT_SESSION) else: raise NotImplemented('Unknown hypervisor type') except libvirt.libvirtError as error: Loading