Loading ccnode/ccnodehandlers.py +13 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,7 @@ class NodeHandler(RpcHandler): default is SOFT_VM_POWEROFF ''' if vm_names is None: #fetch all vm names in hypervisor vm_names = [vm.get_name() for vm in self.hv_handle._vm_list] logging.debug('stop_vm: stopping vms %s' % vm_names) for vm in vm_names: Loading Loading @@ -197,3 +198,15 @@ class NodeHandler(RpcHandler): logging.warning('Error while starting %s: %s' % (vm ,err)) continue logging.info('start_vm: vm %s starting' % vm) @pure def execute_command(self, command): ''' Excecutes the given command on the local hypervisor :param command: the command to excecute as it would be typed on a shell prompt :type command: :class:`str` ''' result = self.hv_handle.local_excecute(command) return result ccnode/kvm.py +23 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ Two entites belong to this module: a Kvm hypervisor or a Kvm virtual machine from libvirtwrapper import * from exceptions import * import subprocess class KvmHypervisor(LibvirtHypervisor): Loading Loading @@ -65,7 +66,29 @@ class KvmHypervisor(LibvirtHypervisor): raise VMError('Virtual Machine %s not found: '% name) def local_excecute(self, command): ''' Excecutes the command given in command on the local host Returns a tuple with (stdout, stderr) from the process that has been executed ..warning:: This is a dangerous function as it gives the command given in paramter to a shell prompt, anything can then be executed locally ..warning:: If the command given is a long processing one, this may be a deadlock to the node be carefull ! :param command: the command to execute with it's arguments :type command: :class:`str` ''' #FIXME: stop using shell=true and parse arguments with shlex.split() p = subprocess.Popen(command, shell=True, bufsize = -1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) result = p.communicate() return result def get_network_conf(self): raise NotImplementedError Loading Loading
ccnode/ccnodehandlers.py +13 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,7 @@ class NodeHandler(RpcHandler): default is SOFT_VM_POWEROFF ''' if vm_names is None: #fetch all vm names in hypervisor vm_names = [vm.get_name() for vm in self.hv_handle._vm_list] logging.debug('stop_vm: stopping vms %s' % vm_names) for vm in vm_names: Loading Loading @@ -197,3 +198,15 @@ class NodeHandler(RpcHandler): logging.warning('Error while starting %s: %s' % (vm ,err)) continue logging.info('start_vm: vm %s starting' % vm) @pure def execute_command(self, command): ''' Excecutes the given command on the local hypervisor :param command: the command to excecute as it would be typed on a shell prompt :type command: :class:`str` ''' result = self.hv_handle.local_excecute(command) return result
ccnode/kvm.py +23 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ Two entites belong to this module: a Kvm hypervisor or a Kvm virtual machine from libvirtwrapper import * from exceptions import * import subprocess class KvmHypervisor(LibvirtHypervisor): Loading Loading @@ -65,7 +66,29 @@ class KvmHypervisor(LibvirtHypervisor): raise VMError('Virtual Machine %s not found: '% name) def local_excecute(self, command): ''' Excecutes the command given in command on the local host Returns a tuple with (stdout, stderr) from the process that has been executed ..warning:: This is a dangerous function as it gives the command given in paramter to a shell prompt, anything can then be executed locally ..warning:: If the command given is a long processing one, this may be a deadlock to the node be carefull ! :param command: the command to execute with it's arguments :type command: :class:`str` ''' #FIXME: stop using shell=true and parse arguments with shlex.split() p = subprocess.Popen(command, shell=True, bufsize = -1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) result = p.communicate() return result def get_network_conf(self): raise NotImplementedError Loading