Loading ccnode/common.py +34 −41 Original line number Diff line number Diff line Loading @@ -30,50 +30,46 @@ class LocalHost(Host): 'x86_64' : 'x64', } def __init__(self): ''' ''' super(LocalHost, self).__init__() def scheduler_run(self): ''' ''' pass def get_hw_serial(self): ''' ''' serial = None try: data = open('/sys/class/dmi/id/product_serial').read().strip() if data: serial = data except: pass return serial def get_hw_vendor(self): ''' ''' vendor = None try: data = open('/sys/class/dmi/id/sys_vendor').read().strip() if data: vendor = data except: pass return vendor def get_hw_product(self): ''' ''' product = None try: data = open('/sys/class/dmi/id/product_name').read().strip() if data: product = data except: pass return product def get_hw_bios(self): ''' ''' bios = '' try: bios_ver = open('/sys/class/dmi/id/bios_version').read().strip() bios_date = open('/sys/class/dmi/id/bios_date').read().strip() if bios_ver: Loading @@ -82,32 +78,24 @@ class LocalHost(Host): bios += ' (%s)' % bios_date if not bios: bios = None except: pass return bios def get_name(self): ''' ''' result = None try: hostname = gethostname() fqdn = gethostbyaddr(hostname)[0] result = fqdn if fqdn else hostname except: pass return result def get_uname(self): ''' ''' uname = None try: data = ' '.join(os.uname()) if data: uname = data except: pass return uname def get_platform(self): Loading Loading @@ -277,6 +265,11 @@ class Hypervisor(LocalHost): ''' ''' def __init__(self): ''' ''' super(Hypervisor, self).__init__() def storage(self): ''' ''' Loading ccnode/handlers.py +23 −6 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ class NodeHandler(RpcHandler): 'hvm' : self._tag_map_direct('get_hvm_available', -1), 'cpu' : self._tag_map_direct('get_cpu', -1), 'cpucore' : self._tag_map_direct('get_cpu_core', -1), 'cputhread' : self._tag_map_direct('get_cpu_threads', -1), 'cputhread' : self._tag_map_direct('get_cpu_thread', -1), # one day 'hbios' : self._tag_map_direct('get_hw_bios', 24*3600), 'hvver' : self._tag_map_direct('get_hv_version', 24*3600), Loading Loading @@ -280,6 +280,10 @@ class NodeHandler(RpcHandler): debug("REGISTER except `%s`:`%s`" % (repr(e), e)) pass ################################## # Tag query ################################## @pure def get_tags(self, tags=None, noresolve_tags=None): ''' Loading Loading @@ -507,6 +511,10 @@ class NodeHandler(RpcHandler): warning('sub_tags: global: `%s` -> `%s`' % (repr(err), err)) return result ################################## # Host control ################################## @pure def node_shutdown(self, reboot=True, gracefull=True): ''' Loading @@ -522,10 +530,18 @@ class NodeHandler(RpcHandler): info('node_shutdown: in progress ... action returned `%s`', result) return result else: warning('node_shutdown: unable to proceed, this feature is not available') error('node_shutdown: unable to proceed, this feature is not available') raise NotImplementedError('host handler has no method `%s`' %method) @pure def execute_command(self, command): ''' ''' error('execute_command: starting execution of `%s`' % command) output = self._host_handle.execute(command) info('execute_command: finished execution of `%s`' % command) return output ################################## # VM management ################################## Loading Loading @@ -571,10 +587,11 @@ class NodeHandler(RpcHandler): else: raise NotImplementedError('host handler has not method `vm_get`') @pure def vm_stop(self, vm_names=None, force=False): ''' ''' info('vm_stop: server requested stop of `%s`' % vm_names) warning('vm_stop: server requested stop of `%s`' % vm_names) debug('vm_stop: force stop is `%s`' % force) if vm_names is None: vm_names = self._host_handle.vm_list_running() Loading @@ -596,7 +613,7 @@ class NodeHandler(RpcHandler): def vm_start(self, vm_names=None): ''' ''' info('vm_start: server requested start of `%s`' % vm_names) warning('vm_start: server requested start of `%s`' % vm_names) if vm_names is None: vm_names = self._host_handle.vm_list_stopped() debug('vm_start: no vm specified, expanded list to `%s`' % vm_names) Loading @@ -613,7 +630,7 @@ class NodeHandler(RpcHandler): def vm_suspend(self, vm_names=None): ''' ''' info('vm_suspend: server requested suspend of `%s`' % vm_names) warning('vm_suspend: server requested suspend of `%s`' % vm_names) if vm_names is None: vm_names = self._host_handle.vm_list_running() debug('vm_suspend: no vm specified, expanded list to `%s`' Loading @@ -631,7 +648,7 @@ class NodeHandler(RpcHandler): def vm_resume(self, vm_names=None): ''' ''' info('vm_resume: server requested resume of `%s`' % vm_names) warning('vm_resume: server requested resume of `%s`' % vm_names) if vm_names is None: vm_names = self._host_handle.vm_list_running() debug('vm_resume: no vm specified, expanded list to `%s`'% vm_names) Loading ccnode/libvirtwrapper.py +5 −3 Original line number Diff line number Diff line Loading @@ -116,7 +116,7 @@ class LibvirtHypervisor(Hypervisor): def get_cpu_threads(self): ''' ''' return self._lvcon_handle.getInfo()[7] return self._lvcon_handle.getInfo()[7] * self.get_cpu_core() def get_cpu_frequency(self): ''' Loading Loading @@ -493,7 +493,8 @@ class LibvirtVm(VM): try: self._domain.suspend() except libvirt.libvirtError: raise VMError('`%s` is not running' % self.get_name()) raise VMError('`%s` is not running, or already paused' % self.get_name()) def power_resume(self): ''' Loading @@ -501,7 +502,8 @@ class LibvirtVm(VM): try: self._domain.resume() except libvirt.libvirtError: raise VMError('`%s` is not running' % self.get_name()) raise VMError('`%s` is not paused, or not running' % self.get_name()) def is_active(self): ''' Loading Loading
ccnode/common.py +34 −41 Original line number Diff line number Diff line Loading @@ -30,50 +30,46 @@ class LocalHost(Host): 'x86_64' : 'x64', } def __init__(self): ''' ''' super(LocalHost, self).__init__() def scheduler_run(self): ''' ''' pass def get_hw_serial(self): ''' ''' serial = None try: data = open('/sys/class/dmi/id/product_serial').read().strip() if data: serial = data except: pass return serial def get_hw_vendor(self): ''' ''' vendor = None try: data = open('/sys/class/dmi/id/sys_vendor').read().strip() if data: vendor = data except: pass return vendor def get_hw_product(self): ''' ''' product = None try: data = open('/sys/class/dmi/id/product_name').read().strip() if data: product = data except: pass return product def get_hw_bios(self): ''' ''' bios = '' try: bios_ver = open('/sys/class/dmi/id/bios_version').read().strip() bios_date = open('/sys/class/dmi/id/bios_date').read().strip() if bios_ver: Loading @@ -82,32 +78,24 @@ class LocalHost(Host): bios += ' (%s)' % bios_date if not bios: bios = None except: pass return bios def get_name(self): ''' ''' result = None try: hostname = gethostname() fqdn = gethostbyaddr(hostname)[0] result = fqdn if fqdn else hostname except: pass return result def get_uname(self): ''' ''' uname = None try: data = ' '.join(os.uname()) if data: uname = data except: pass return uname def get_platform(self): Loading Loading @@ -277,6 +265,11 @@ class Hypervisor(LocalHost): ''' ''' def __init__(self): ''' ''' super(Hypervisor, self).__init__() def storage(self): ''' ''' Loading
ccnode/handlers.py +23 −6 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ class NodeHandler(RpcHandler): 'hvm' : self._tag_map_direct('get_hvm_available', -1), 'cpu' : self._tag_map_direct('get_cpu', -1), 'cpucore' : self._tag_map_direct('get_cpu_core', -1), 'cputhread' : self._tag_map_direct('get_cpu_threads', -1), 'cputhread' : self._tag_map_direct('get_cpu_thread', -1), # one day 'hbios' : self._tag_map_direct('get_hw_bios', 24*3600), 'hvver' : self._tag_map_direct('get_hv_version', 24*3600), Loading Loading @@ -280,6 +280,10 @@ class NodeHandler(RpcHandler): debug("REGISTER except `%s`:`%s`" % (repr(e), e)) pass ################################## # Tag query ################################## @pure def get_tags(self, tags=None, noresolve_tags=None): ''' Loading Loading @@ -507,6 +511,10 @@ class NodeHandler(RpcHandler): warning('sub_tags: global: `%s` -> `%s`' % (repr(err), err)) return result ################################## # Host control ################################## @pure def node_shutdown(self, reboot=True, gracefull=True): ''' Loading @@ -522,10 +530,18 @@ class NodeHandler(RpcHandler): info('node_shutdown: in progress ... action returned `%s`', result) return result else: warning('node_shutdown: unable to proceed, this feature is not available') error('node_shutdown: unable to proceed, this feature is not available') raise NotImplementedError('host handler has no method `%s`' %method) @pure def execute_command(self, command): ''' ''' error('execute_command: starting execution of `%s`' % command) output = self._host_handle.execute(command) info('execute_command: finished execution of `%s`' % command) return output ################################## # VM management ################################## Loading Loading @@ -571,10 +587,11 @@ class NodeHandler(RpcHandler): else: raise NotImplementedError('host handler has not method `vm_get`') @pure def vm_stop(self, vm_names=None, force=False): ''' ''' info('vm_stop: server requested stop of `%s`' % vm_names) warning('vm_stop: server requested stop of `%s`' % vm_names) debug('vm_stop: force stop is `%s`' % force) if vm_names is None: vm_names = self._host_handle.vm_list_running() Loading @@ -596,7 +613,7 @@ class NodeHandler(RpcHandler): def vm_start(self, vm_names=None): ''' ''' info('vm_start: server requested start of `%s`' % vm_names) warning('vm_start: server requested start of `%s`' % vm_names) if vm_names is None: vm_names = self._host_handle.vm_list_stopped() debug('vm_start: no vm specified, expanded list to `%s`' % vm_names) Loading @@ -613,7 +630,7 @@ class NodeHandler(RpcHandler): def vm_suspend(self, vm_names=None): ''' ''' info('vm_suspend: server requested suspend of `%s`' % vm_names) warning('vm_suspend: server requested suspend of `%s`' % vm_names) if vm_names is None: vm_names = self._host_handle.vm_list_running() debug('vm_suspend: no vm specified, expanded list to `%s`' Loading @@ -631,7 +648,7 @@ class NodeHandler(RpcHandler): def vm_resume(self, vm_names=None): ''' ''' info('vm_resume: server requested resume of `%s`' % vm_names) warning('vm_resume: server requested resume of `%s`' % vm_names) if vm_names is None: vm_names = self._host_handle.vm_list_running() debug('vm_resume: no vm specified, expanded list to `%s`'% vm_names) Loading
ccnode/libvirtwrapper.py +5 −3 Original line number Diff line number Diff line Loading @@ -116,7 +116,7 @@ class LibvirtHypervisor(Hypervisor): def get_cpu_threads(self): ''' ''' return self._lvcon_handle.getInfo()[7] return self._lvcon_handle.getInfo()[7] * self.get_cpu_core() def get_cpu_frequency(self): ''' Loading Loading @@ -493,7 +493,8 @@ class LibvirtVm(VM): try: self._domain.suspend() except libvirt.libvirtError: raise VMError('`%s` is not running' % self.get_name()) raise VMError('`%s` is not running, or already paused' % self.get_name()) def power_resume(self): ''' Loading @@ -501,7 +502,8 @@ class LibvirtVm(VM): try: self._domain.resume() except libvirt.libvirtError: raise VMError('`%s` is not running' % self.get_name()) raise VMError('`%s` is not paused, or not running' % self.get_name()) def is_active(self): ''' Loading