def cleanup(config, debug): c = AgentConfig(config) try: initialize(c) (result, errors) = rmtree(c.rundir) if not result: logger.error("\n".join(errors)) sys.exit(result) except Exception as ex: logger.error("Failed to remove %s: %s", c.rundir, ex) sys.exit(1)
def ssh(debug, config, keyfile): c = AgentConfig(config) initialize(c) src = pathlib.Path(keyfile) dest = pathlib.Path(c.installdir, "id_rsa") if not dest.exists(): try: shutil.copyfile(src, dest) except Exception as ex: logger.error("Failed to copy ssh key file %s: %s", src, ex) sys.exit(1)
def activate(debug, config): c = AgentConfig(config) initialize(c) src = pathlib.Path(config) dest = pathlib.Path(c.installdir, "config", "pbench-agent.cfg") if not dest.exists(): try: shutil.copyfile(src, dest) except Exception as ex: logger.error("Failed to copy %s: %s", src, ex) sys.exit(1)
def clear(config, debug): c = AgentConfig(config) initialize(c) rundir = pathlib.Path(c.rundir) if rundir.exists(): for path in rundir.glob("*"): if not (path.name.startswith("tmp") or path.name.startswith("tools") or path.name == "pbench.log"): if path.is_file(): try: os.unlink(path) except Exception as ex: logger.error("Failed to remove %s: %s", path, ex) if path.is_dir(): try: shutil.rmtree(path) except Exception as ex: logger.error("Failed to remove %s: %s", path, ex)
def stop(config, debug, group, benchmark_dir): c = AgentConfig(config) t = ToolState(c) initialize(c) t.process(group, benchmark_dir, get_action(__name__))
def list(config, debug, name, group, options): c = AgentConfig(config) t = ToolState(c) initialize(c) t.list(name, group, options)
def register(config, debug, name, group, no_install, remotes, labels, args): c = AgentConfig(config) t = ToolState(c) initialize(c) t.register(name, group, no_install, remotes, labels, args)
def register(config, debug, group, start_trigger, stop_trigger): initialize(AgentConfig(config)) Trigger(config).register(group, start_trigger, stop_trigger)
def list(config, debug, group): initialize(AgentConfig(config)) Trigger(config).list(group)
def clear(config, debug, name, group, remote): c = AgentConfig(config) t = ToolState(c) initialize(c) t.clear(name, group, remote)