def cleanup(): aucont_init_path = util.aucont_tool_path('aucont_init') if (os.path.isfile(aucont_init_path)): os.system(aucont_init_path) os.system( util.aucont_tool_path('aucont_list') + " | xargs -I '{}' " + util.aucont_tool_path('aucont_stop') + " '{}' 9") aucont_cleanup_path = util.aucont_tool_path('aucont_cleanup') if (os.path.isfile(aucont_cleanup_path)): os.system(aucont_cleanup_path)
def cleanup(): aucont_init_path = util.aucont_tool_path('aucont_init') if (os.path.isfile(aucont_init_path)): os.system(aucont_init_path) os.system(util.aucont_tool_path('aucont_list') + " | xargs -I '{}' " + util.aucont_tool_path('aucont_stop') + " '{}' 9" ) aucont_cleanup_path = util.aucont_tool_path('aucont_cleanup') if (os.path.isfile(aucont_cleanup_path)): os.system(aucont_cleanup_path)
def clist(): cont_list_cmd_and_args = [ util.aucont_tool_path('aucont_list') ] output = subprocess.check_output(cont_list_cmd_and_args) pids = output.decode('UTF-8').split('\n') pids = list(filter(lambda pid: pid != '', pids)) util.debug(pids) return pids
def stop(cont_pid, signal=15): signal = str(signal) cont_stop_cmd_and_args = [ util.aucont_tool_path('aucont_stop'), cont_pid, signal ] util.debug(*cont_stop_cmd_and_args) subprocess.check_call(cont_stop_cmd_and_args) util.log('stopped container', cont_pid);
def exec_interactive(cont_pid, *cmd_and_args): cont_exec_cmd_and_args = [ util.aucont_tool_path('aucont_exec'), cont_pid ] cont_exec_cmd_and_args += cmd_and_args util.debug(*cont_exec_cmd_and_args) subprocess.check_call(cont_exec_cmd_and_args, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr )
def exec_capture_output(cont_pid, *cmd_and_args): cont_exec_cmd_and_args = [ util.aucont_tool_path('aucont_exec'), cont_pid ] cont_exec_cmd_and_args += cmd_and_args util.debug(*cont_exec_cmd_and_args) try: output = subprocess.check_output(cont_exec_cmd_and_args, stdin=sys.stdin, stderr=subprocess.STDOUT ) except subprocess.CalledProcessError as err: util.log(err.returncode, err.output) raise return output.decode('UTF-8')
def _make_cont_start_cmd(is_interactive, image_path, cmd_and_args, cpu_perc=None, cont_ip=None): cont_start_opts_list = [] if not is_interactive: cont_start_opts_list.append('-d') if cpu_perc: cont_start_opts_list.extend(['--cpu', str(cpu_perc)]) if cont_ip: cont_start_opts_list.extend(['--net', cont_ip]) cont_start_cmd_and_arg_lists = [ [util.aucont_tool_path('aucont_start')], cont_start_opts_list, [image_path], cmd_and_args ] cont_start_cmd_and_args = list( itertools.chain.from_iterable(cont_start_cmd_and_arg_lists) ) util.debug(*cont_start_cmd_and_args) return cont_start_cmd_and_args
def build_tools(): aucont_build_dir_path = util.aucont_tool_path('../') print(aucont_build_dir_path) os.system('cd ' + aucont_build_dir_path + ' && ./build.sh')
def build_tools(): aucont_build_dir_path = util.aucont_tool_path('../') os.system('cd ' + aucont_build_dir_path + ' && ./build.sh')