Loading ccnode/libvirtwrapper.py +10 −13 Original line number Diff line number Diff line # -*- coding: utf-8 -*- import libvirt import re import psutil import xml.dom.minidom from logging import debug, info from logging import error, warning, info, debug from time import sleep from common import Hypervisor, VM, Storage, StoragePool, StorageVolume from utils import RWLock from exceptions import HypervisorError, VMError, StoragePoolError KVM_LIBVIRT_SESSION = 'qemu:///system' Loading @@ -29,10 +29,10 @@ class LibvirtHypervisor(Hypervisor): ''' try: if hv_type == 'kvm': debug("LibvirtHypervisor: initialized as KVM") warning("LibvirtHypervisor: initialized as KVM") self._lvcon_handle = libvirt.open(KVM_LIBVIRT_SESSION) elif hv_type == 'xen': debug("LibvirtHypervisor: initialized as Xen") warning("LibvirtHypervisor: initialized as Xen") self._lvcon_handle = libvirt.open(XEN_LIBVIRT_SESSION) else: raise NotImplemented('Unknown hypervisor type') Loading @@ -55,24 +55,22 @@ class LibvirtHypervisor(Hypervisor): running = {} defined = {} #debug("_vm_cache_rebuild: listing running domains") for dom_id in self._lvcon_handle.listDomainsID(): #debug("domid=%i" % dom_id) try: vm = LibvirtVm(self, self._lvcon_handle.lookupByID(dom_id)) running[vm.get_name()] = vm except Exception as err: debug("%s: %s" % (err,err)) debug("_cache_vm_rebuild: listDomainsID: `%s` -> `%s`", repr(err), err) #debug("_vm_cache_rebuild: listing defined domains") for dom_name in self._lvcon_handle.listDefinedDomains(): #debug("domid=%s" % dom_name) try: vm = LibvirtVm(self, self._lvcon_handle.lookupByName(dom_name)) defined[vm.get_name()] = vm except Exception as err: debug("%s: %s" % (err,err)) debug("_cache_vm_rebuild: listDefinedDomains: `%s` -> `%s`", repr(err), err) with self._vm_cache_lock.write: self._vm_cache_running = running Loading @@ -93,7 +91,6 @@ class LibvirtHypervisor(Hypervisor): data = self._lvcon_handle.getVersion() if data: version = data except: pass return version Loading ccnode/utils.py +12 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ class RWLock(object): ''' ''' def __init__(self): ''' ''' self._mutex = Lock() self._writemutex = Lock() self._readers = 0 Loading @@ -17,17 +19,23 @@ class RWLock(object): ''' ''' def __init__(self, rwlock): ''' ''' self._parent = rwlock class _WLock(_Lock): ''' ''' def __enter__(self): ''' ''' with self._parent._mutex: self._parent._writers += 1 self._parent._writemutex.acquire() def __exit__(self, exc_type, exc_value, traceback): ''' ''' with self._parent._mutex: self._parent._writers -= 1 self._parent._writemutex.release() Loading @@ -36,6 +44,8 @@ class RWLock(object): ''' ''' def __enter__(self): ''' ''' self._parent._mutex.acquire() if self._parent._writers > 0 or self._parent._readers == 0: self._parent._mutex.release() Loading @@ -45,6 +55,8 @@ class RWLock(object): self._parent._mutex.release() def __exit__(self, exc_type, exc_value, traceback): ''' ''' self._parent._mutex.acquire() self._parent._readers -= 1 if self._parent._readers == 0: Loading etc/cc-node.conf +9 −9 Original line number Diff line number Diff line [node] # address and port of the CloudControl server address = address = 10.15.255.42 #port = 1984 # account created for this node on the server login = password = login = $$LOGIN$$ password = $$PASSWORD$$ # logging verbosity level 0-3 verbosity = #verbosity = 0 # hypervisor detection and connection, set to 'no' on regular hosts or when # the node should not attempt to use local hypervisors detect_hypervisor = yes #detect_hypervisor = yes # allow remote command execution (or host shutdown/reboot) #command_execution = yes # TO BE REMOVED IN LATER RELEASES # force usage of Xen force_xen = no # allow remote command execution (or host shutdown/reboot) command_execution = yes #force_xen = no No newline at end of file Loading
ccnode/libvirtwrapper.py +10 −13 Original line number Diff line number Diff line # -*- coding: utf-8 -*- import libvirt import re import psutil import xml.dom.minidom from logging import debug, info from logging import error, warning, info, debug from time import sleep from common import Hypervisor, VM, Storage, StoragePool, StorageVolume from utils import RWLock from exceptions import HypervisorError, VMError, StoragePoolError KVM_LIBVIRT_SESSION = 'qemu:///system' Loading @@ -29,10 +29,10 @@ class LibvirtHypervisor(Hypervisor): ''' try: if hv_type == 'kvm': debug("LibvirtHypervisor: initialized as KVM") warning("LibvirtHypervisor: initialized as KVM") self._lvcon_handle = libvirt.open(KVM_LIBVIRT_SESSION) elif hv_type == 'xen': debug("LibvirtHypervisor: initialized as Xen") warning("LibvirtHypervisor: initialized as Xen") self._lvcon_handle = libvirt.open(XEN_LIBVIRT_SESSION) else: raise NotImplemented('Unknown hypervisor type') Loading @@ -55,24 +55,22 @@ class LibvirtHypervisor(Hypervisor): running = {} defined = {} #debug("_vm_cache_rebuild: listing running domains") for dom_id in self._lvcon_handle.listDomainsID(): #debug("domid=%i" % dom_id) try: vm = LibvirtVm(self, self._lvcon_handle.lookupByID(dom_id)) running[vm.get_name()] = vm except Exception as err: debug("%s: %s" % (err,err)) debug("_cache_vm_rebuild: listDomainsID: `%s` -> `%s`", repr(err), err) #debug("_vm_cache_rebuild: listing defined domains") for dom_name in self._lvcon_handle.listDefinedDomains(): #debug("domid=%s" % dom_name) try: vm = LibvirtVm(self, self._lvcon_handle.lookupByName(dom_name)) defined[vm.get_name()] = vm except Exception as err: debug("%s: %s" % (err,err)) debug("_cache_vm_rebuild: listDefinedDomains: `%s` -> `%s`", repr(err), err) with self._vm_cache_lock.write: self._vm_cache_running = running Loading @@ -93,7 +91,6 @@ class LibvirtHypervisor(Hypervisor): data = self._lvcon_handle.getVersion() if data: version = data except: pass return version Loading
ccnode/utils.py +12 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ class RWLock(object): ''' ''' def __init__(self): ''' ''' self._mutex = Lock() self._writemutex = Lock() self._readers = 0 Loading @@ -17,17 +19,23 @@ class RWLock(object): ''' ''' def __init__(self, rwlock): ''' ''' self._parent = rwlock class _WLock(_Lock): ''' ''' def __enter__(self): ''' ''' with self._parent._mutex: self._parent._writers += 1 self._parent._writemutex.acquire() def __exit__(self, exc_type, exc_value, traceback): ''' ''' with self._parent._mutex: self._parent._writers -= 1 self._parent._writemutex.release() Loading @@ -36,6 +44,8 @@ class RWLock(object): ''' ''' def __enter__(self): ''' ''' self._parent._mutex.acquire() if self._parent._writers > 0 or self._parent._readers == 0: self._parent._mutex.release() Loading @@ -45,6 +55,8 @@ class RWLock(object): self._parent._mutex.release() def __exit__(self, exc_type, exc_value, traceback): ''' ''' self._parent._mutex.acquire() self._parent._readers -= 1 if self._parent._readers == 0: Loading
etc/cc-node.conf +9 −9 Original line number Diff line number Diff line [node] # address and port of the CloudControl server address = address = 10.15.255.42 #port = 1984 # account created for this node on the server login = password = login = $$LOGIN$$ password = $$PASSWORD$$ # logging verbosity level 0-3 verbosity = #verbosity = 0 # hypervisor detection and connection, set to 'no' on regular hosts or when # the node should not attempt to use local hypervisors detect_hypervisor = yes #detect_hypervisor = yes # allow remote command execution (or host shutdown/reboot) #command_execution = yes # TO BE REMOVED IN LATER RELEASES # force usage of Xen force_xen = no # allow remote command execution (or host shutdown/reboot) command_execution = yes #force_xen = no No newline at end of file