def get_java_run_command(path, time_limit, mem_limit, lib_folder_path=("./", )): return (command("cd", args=(dirname(path), )).__str__(), command( "java", args=(basename(path), ), time_limit=time_limit, flags=("-mx{}m".format(mem_limit), "-classpath {}".format(":".join(lib_folder_path))), ).__str__())
def _copy_disk(self, arch, vm_name): self._logger.debug('copying a new disk.. %s' % arch) src_disk = Config.get_src_disk_path(arch) dst_disk = Config.get_disk_path(arch, vm_name) if not os.path.exists(dst_disk): command('cp %s %s' % (src_disk, dst_disk)) else: self._logger.error('disk [%s] already exist.' % dst_disk) return dst_disk
def create_pipe(self, name): pipe = ["/tmp/{0}-pipe.in", "/tmp/{0}-pipe.out"] self._logger.info('creating pipe ..') for i, s in enumerate(pipe): pipe[i] = s.format(name) if not os.path.exists(pipe[i]): command('mkfifo %s' % pipe[i], timeout=5) else: self._logger.error('pipe [%s] already exist.' % pipe[i]) return
def create_vm(self, arch, vm_name): if self.vm_is_exist(vm_name): self._logger.error('VM [%s] already exist.' % vm_name) return if not have_privileges(): self._logger.error('You need root permissions to create VM [%s]' % vm_name) return disk_path = self._copy_disk(arch, vm_name) kernel_path = Config.get_kernel_path(arch) ram = Config.get_ram_size(arch) if arch == VMArch.x86_64.value: create_cmd = 'virt-install --connect %s --name %s'\ ' --ram %s --arch x86_64' \ ' --disk %s,bus=virtio,format=raw' \ ' --boot kernel=%s,kernel_args="root=/dev/vda console=ttyS0"' \ ' --network network=default' \ ' --hvm --noautoconsole' \ % (self._target, vm_name, ram, disk_path, kernel_path) self._logger.info('creating VM [%s] ...' % vm_name) self._logger.debug(create_cmd) self._logger.debug(command(create_cmd)) self._add_libvmi_conf(arch, vm_name) return
def get_java_compile_commands(path, lib_folder_path=("./", )): return (command("cd", args=(dirname(path), )).__str__(), command("javac", flags=("-classpath {}".format( ":".join(lib_folder_path)), ), args=(basename(path), )).__str__())