Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
check_python_version()
log.install_default_log_config()
log.configure_logging()
console.init()
parser = argparse.ArgumentParser(prog=PROGRAM_NAME,
description=BANNER + "\n\n Rally daemon to support remote benchmarks",
epilog="Find out more about Rally at {}".format(console.format.link(doc_link())),
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('--version', action='version', version="%(prog)s " + version.version())
subparsers = parser.add_subparsers(
title="subcommands",
dest="subcommand",
help="")
subparsers.required = True
start_command = subparsers.add_parser("start", help="Starts the Rally daemon")
restart_command = subparsers.add_parser("restart", help="Restarts the Rally daemon")
for p in [start_command, restart_command]:
p.add_argument(
"--node-ip",
required=True,
help="The IP of this node.")
def print_help_on_errors():
heading = "Getting further help:"
console.println(console.format.bold(heading))
console.println(console.format.underline_for(heading))
console.println("* Check the log files in {} for errors.".format(paths.logs()))
console.println("* Read the documentation at {}".format(console.format.link(doc_link())))
console.println("* Ask a question on the forum at {}".format(console.format.link("https://discuss.elastic.co/c/elasticsearch/rally")))
console.println("* Raise an issue at {} and include the log files in {}."
.format(console.format.link("https://github.com/elastic/rally/issues"), paths.logs()))
def warn_if_plugin_build_task_is_in_use(config):
if "source" not in config:
return
for k, v in config["source"].items():
plugin_match = re.match(r"^plugin\.([^.]+)\.build\.task$",k)
if plugin_match != None and len(plugin_match.groups()) > 0 :
plugin_name = plugin_match.group(1)
new_key = "plugin.{}.build.command".format(plugin_name)
out("\n"
"WARNING:"
" The build.task property for plugins has been obsoleted in favor of the full build.command."
" You will need to edit the plugin [{}] section in {} and change from:"
" [{} = {}] to [{} = ]."
" Please refer to the documentation for more details:"
" {}.\n".format(plugin_match.group(1), config_file.location, k, v, new_key,
console.format.link(doc_link("elasticsearch_plugins.html#running-a-benchmark-with-plugins"))))
if not client_cert and not client_key:
self.logger.info("SSL client authentication: off")
elif bool(client_cert) != bool(client_key):
self.logger.error(
"Supplied client-options contain only one of client_cert/client_key. "
)
defined_client_ssl_option = "client_key" if client_key else "client_cert"
missing_client_ssl_option = "client_cert" if client_key else "client_key"
console.println(
"'{}' is missing from client-options but '{}' has been specified.\n"
"If your Elasticsearch setup requires client certificate verification both need to be supplied.\n"
"Read the documentation at {}\n".format(
missing_client_ssl_option,
defined_client_ssl_option,
console.format.link(doc_link("command_line_reference.html#client-options")))
)
raise exceptions.SystemSetupError(
"Cannot specify '{}' without also specifying '{}' in client-options.".format(
defined_client_ssl_option,
missing_client_ssl_option))
elif client_cert and client_key:
self.logger.info("SSL client authentication: on")
self.ssl_context.load_cert_chain(certfile=client_cert,
keyfile=client_key)
else:
self.logger.info("SSL support: off")
self.client_options["scheme"] = "http"
if self._is_set(self.client_options, "basic_auth_user") and self._is_set(self.client_options, "basic_auth_password"):
self.logger.info("HTTP basic authentication: on")
self.client_options["http_auth"] = (self.client_options.pop("basic_auth_user"), self.client_options.pop("basic_auth_password"))
def print_help_on_errors():
heading = "Getting further help:"
console.println(console.format.bold(heading))
console.println(console.format.underline_for(heading))
console.println("* Check the log files in %s for errors." % application_log_dir_path())
console.println("* Read the documentation at %s" % console.format.link(DOC_LINK))
console.println("* Ask a question on the forum at %s" % console.format.link("https://discuss.elastic.co/c/elasticsearch/rally"))
console.println("* Raise an issue at %s and include the log files in %s." %
(console.format.link("https://github.com/elastic/rally/issues"), application_log_dir_path()))
def warn_if_plugin_build_task_is_in_use(config):
if "source" not in config:
return
for k, v in config["source"].items():
plugin_match = re.match('^plugin\.([^.]+)\.build\.task$',k)
if plugin_match != None and len(plugin_match.groups()) > 0 :
plugin_name = plugin_match.group(1)
new_key = "plugin.{}.build.command".format(plugin_name)
out("\n"
"WARNING:"
" The build.task property for plugins has been obsoleted in favor of the full build.command."
" You will need to edit the plugin [{}] section in {} and change from:"
" [{} = {}] to [{} = ]."
" Please refer to the documentation for more details:"
" {}.\n".format(plugin_match.group(1), config_file.location, k, v, new_key,
console.format.link("%selasticsearch_plugins.html#running-a-benchmark-with-plugins" % DOC_LINK)))
value = int(v)
if value <= 0:
raise argparse.ArgumentTypeError("must be positive but was %s" % value)
return value
# try to preload configurable defaults, but this does not work together with `--configuration-name` (which is undocumented anyway)
cfg = config.Config()
if cfg.config_present():
cfg.load_config()
preserve_install = cfg.opts("defaults", "preserve_benchmark_candidate", default_value=False, mandatory=False)
else:
preserve_install = False
parser = argparse.ArgumentParser(prog=PROGRAM_NAME,
description=BANNER + "\n\n You know for benchmarking Elasticsearch.",
epilog="Find out more about Rally at %s" % console.format.link(DOC_LINK),
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('--version', action='version', version="%(prog)s " + version.version())
subparsers = parser.add_subparsers(
title="subcommands",
dest="subcommand",
help="")
race_parser = subparsers.add_parser("race", help="Run the benchmarking pipeline. This sub-command should typically be used.")
# change in favor of "list telemetry", "list tracks", "list pipelines"
list_parser = subparsers.add_parser("list", help="List configuration options")
list_parser.add_argument(
"configuration",
metavar="configuration",
help="The configuration for which Rally should show the available options. "
"Possible values are: telemetry, tracks, pipelines, races, cars, elasticsearch-plugins",
def print_help_on_errors():
heading = "Getting further help:"
console.println(console.format.bold(heading))
console.println(console.format.underline_for(heading))
console.println("* Check the log files in {} for errors.".format(paths.logs()))
console.println("* Read the documentation at {}".format(console.format.link(doc_link())))
console.println("* Ask a question on the forum at {}".format(console.format.link("https://discuss.elastic.co/c/elasticsearch/rally")))
console.println("* Raise an issue at {} and include the log files in {}."
.format(console.format.link("https://github.com/elastic/rally/issues"), paths.logs()))
def print_help_on_errors():
heading = "Getting further help:"
console.println(console.format.bold(heading))
console.println(console.format.underline_for(heading))
console.println("* Check the log files in {} for errors.".format(paths.logs()))
console.println("* Read the documentation at {}".format(console.format.link(doc_link())))
console.println("* Ask a question on the forum at {}".format(console.format.link("https://discuss.elastic.co/c/elasticsearch/rally")))
console.println("* Raise an issue at {} and include the log files in {}."
.format(console.format.link("https://github.com/elastic/rally/issues"), paths.logs()))