def run(args): if not cere_configure.init(): return False if(args.region): invocations = find_invocations(args.invocation, args.region) if not invocations: return False for invocation in invocations: if not args.force: if utils.dump_exist(args.region, invocation): logger.info("Dump already exists for region {0} invocation {1}".format(args.region, invocation)) return True if not args.no_io_trace: #Check IOs if not cere_check_io.run_io_checker(args.region, None, invocation, args.force): utils.mark_invalid(args.region, "Failed to run IO checker") if utils.is_invalid(args.region): logger.warning("{0} is invalid. Skipping capture".format(args.region)) return False else: shutil.rmtree(os.path.join(var.CERE_DUMPS_PATH, args.region, str(invocation)), ignore_errors=True) logger.info("Compiling capture mode for region {0} invocation {1}".format(args.region, invocation)) try: logger.debug(subprocess.check_output("{0} MODE=\"dump --region={1} --invocation={2}\" -B".format(cere_configure.cere_config["build_cmd"], args.region, invocation), stderr=subprocess.STDOUT, shell=True)) except subprocess.CalledProcessError as err: logger.error(str(err)) logger.error(err.output) logger.error("Compiling capture mode for region {0} invocation {1} failed".format(args.region, invocation)) utils.mark_invalid(args.region, cere_error.EDUMP) return False if not args.norun: logger.info("Capturing invocation {1} for region {0}".format(args.region, invocation)) try: logger.info(subprocess.check_output("LD_BIND_NOW=1 " + cere_configure.cere_config["run_cmd"], stderr=subprocess.STDOUT, shell=True)) except subprocess.CalledProcessError as err: #even if the capture run fails, maybe the region is dumped. logger.error(str(err)) logger.error(err.output) if not os.path.isdir("{0}/{1}/{2}".format(var.CERE_DUMPS_PATH, args.region, invocation)): logger.error("Capture failed for region {0} invocation {1}".format(args.region, invocation)) utils.mark_invalid(args.region, cere_error.EDUMP) return False else: logger.info("Invocation {1} succesfully captured for region {0} ".format(args.region, invocation)) #Global dump else: logger.info("Compiling capture mode for all regions") try: logger.debug(subprocess.check_output("{0} MODE=\"dump\" -B".format(cere_configure.cere_config["build_cmd"]), stderr=subprocess.STDOUT, shell=True)) except subprocess.CalledProcessError as err: logger.error(str(err)) logger.error(err.output) logger.info("Compiling capture mode for all regions failed") return False if not args.norun: logger.info("Capturing all regions") try: logger.debug(subprocess.check_output("LD_BIND_NOW=1 " + cere_configure.cere_config["run_cmd"], stderr=subprocess.STDOUT, shell=True)) except subprocess.CalledProcessError as err: logger.error(str(err)) logger.error(err.output) logger.error("Capturing all regions failed") return False else: logger.info("All regions succesfully captured") return True
def run_io_checker(trace_filename): cere_check_io.run_io_checker(None, trace_filename, 0, False)