示例#1
0
def main():
    namespace = parse_job_mode()

    if namespace.jmx_username:
        namespace.jmx_password = getpass.getpass(prompt="JMX Password ")
    else:
        namespace.jmx_password = None

    if bool(namespace.seed_host) + bool(namespace.host) + bool(
            namespace.host_file) != 1:
        error(
            "Exactly one of --seed-host, --host and --host-file must be used",
            print_traceback=False)

    hosts = None

    if namespace.host_file:
        with open(namespace.host_file) as f:
            hosts = f.readlines()

    if namespace.host:
        hosts = namespace.host

    cstar.output.configure(namespace.verbose)

    with cstar.job.Job() as job:
        env = {}
        job_id = str(uuid.uuid4())
        msg("Job id is", emph(job_id))

        cstar.signalhandler.print_message_and_save_on_sigint(job, job_id)

        job.setup(hosts=hosts,
                  seeds=namespace.seed_host,
                  command=namespace.command,
                  job_id=job_id,
                  strategy=cstar.strategy.parse(
                      fallback(namespace.strategy, "topology")),
                  cluster_parallel=fallback(namespace.cluster_parallel, False),
                  dc_parallel=fallback(namespace.dc_parallel, False),
                  max_concurrency=namespace.max_concurrency,
                  timeout=namespace.timeout,
                  env=env,
                  stop_after=namespace.stop_after,
                  job_runner=cstar.jobrunner.LocalJobRunner,
                  key_space=namespace.key_space,
                  output_directory=namespace.output_directory,
                  ignore_down_nodes=False,
                  dc_filter=namespace.dc_filter,
                  sleep_on_new_runner=namespace.ssh_pause_time,
                  sleep_after_done=namespace.node_done_pause_time,
                  ssh_username=namespace.ssh_username,
                  ssh_password=namespace.ssh_password,
                  ssh_identity_file=namespace.ssh_identity_file,
                  ssh_lib=namespace.ssh_lib,
                  jmx_username=namespace.jmx_username,
                  jmx_password=namespace.jmx_password,
                  resolve_hostnames=namespace.resolve_hostnames,
                  hosts_variables=namespace.hosts_variables)
        job.run()
示例#2
0
def execute_command(args):
    cstar.output.debug(args)
    command = args.command
    if bool(args.seed_host) + bool(args.host) + bool(args.host_file) != 1:
        error(
            "Exactly one of --seed-host, --host and --host-file must be used",
            print_traceback=False)

    hosts = None

    if args.host_file:
        with open(args.host_file) as f:
            hosts = f.readlines()

    if args.host:
        hosts = args.host

    with cstar.job.Job() as job:
        env = dict(
            (arg.name, getattr(args, arg.name)) for arg in command.arguments)
        if bool(args.enforced_job_id) == 1:
            job_id = args.enforced_job_id
            if not (validate_uuid4(job_id)):
                raise BadArgument("Job id is not a valid UUID v4 value.")
        else:
            job_id = str(uuid.uuid4())
        msg("Job id is", emph(job_id))
        msg("Running", command.file)

        cstar.signalhandler.print_message_and_save_on_sigint(job, job_id)

        job.setup(hosts=hosts,
                  seeds=args.seed_host,
                  command=command.file,
                  job_id=job_id,
                  strategy=cstar.strategy.parse(
                      fallback(args.strategy, command.strategy, "topology")),
                  cluster_parallel=fallback(args.cluster_parallel,
                                            command.cluster_parallel, False),
                  dc_parallel=fallback(args.dc_parallel, command.dc_parallel,
                                       False),
                  max_concurrency=args.max_concurrency,
                  timeout=args.timeout,
                  env=env,
                  stop_after=args.stop_after,
                  job_runner=cstar.jobrunner.RemoteJobRunner,
                  key_space=args.key_space,
                  output_directory=args.output_directory,
                  ignore_down_nodes=args.ignore_down_nodes,
                  dc_filter=args.dc_filter,
                  sleep_on_new_runner=args.ssh_pause_time,
                  sleep_after_done=args.node_done_pause_time,
                  ssh_username=args.ssh_username,
                  ssh_password=args.ssh_password,
                  ssh_identity_file=args.ssh_identity_file,
                  ssh_lib=args.ssh_lib,
                  jmx_username=args.jmx_username,
                  jmx_password=args.jmx_password,
                  jmx_passwordfile=args.jmx_passwordfile)
        job.run()
示例#3
0
def run_job(context, command, strategy, job_id, stop_after=None):
    run_command = cstar.command.load("run")
    env = dict()
    env["COMMAND"] = command
    with open("/tmp/cstar_output.out", "w") as f:
        with stdout_redirected(f):
            with cstar.job.Job() as job:
                cstar.signalhandler.print_message_and_save_on_sigint(
                    job, job_id)
                job.setup(seeds=[context.seed_node],
                          command=run_command.file,
                          job_id=job_id,
                          strategy=cstar.strategy.parse(strategy),
                          cluster_parallel=False,
                          dc_parallel=False,
                          max_concurrency=None,
                          timeout=None,
                          env=env,
                          stop_after=stop_after,
                          job_runner=cstar.jobrunner.RemoteJobRunner,
                          key_space=None,
                          output_directory=None,
                          ignore_down_nodes=False,
                          dc_filter=None,
                          sleep_on_new_runner=0,
                          sleep_after_done=0,
                          ssh_username=None,
                          ssh_password="******",
                          ssh_identity_file=None,
                          ssh_lib="paramiko",
                          jmx_username=None,
                          jmx_password=None,
                          jmx_passwordfile=None,
                          resolve_hostnames=True,
                          hosts=None,
                          hosts_variables=dict())
                job.run()
                context.job = job