def join(cli, config): """Perform a domain join. The cli supports specificying different methods from which data needed to perform the join will be sourced. """ # maybe in the future we'll have more secure methods joiner = joinutil.Joiner(cli.join_marker) _add_join_sources(joiner, cli, config) try: joiner.join() except joinutil.JoinError as err: _print_join_error(err) raise Fail("failed to join to a domain")
def join(cli, config) -> None: """Perform a domain join. The supported sources for join can be provided by supplying command line arguments. This includes an *insecure* mode that sources the password from the CLI or environment. Use this only on testing/non-production purposes. """ # maybe in the future we'll have more secure methods joiner = joinutil.Joiner(cli.join_marker) _add_join_sources(joiner, cli, config) try: joiner.join() except joinutil.JoinError as err: _print_join_error(err) raise Fail("failed to join to a domain")
def must_join(cli, config) -> None: """If possible, perform an unattended domain join. Otherwise, exit or block until a join has been perfmed by another process. """ joiner = joinutil.Joiner(cli.join_marker) if joiner.did_join(): print("already joined") return # Interactive join is not allowed on must-join setattr(cli, "interactive", False) _add_join_sources(joiner, cli, config) if cli.wait: waiter = best_waiter(cli.join_marker, max_timeout=120) joinutil.join_when_possible(joiner, waiter, error_handler=_print_join_error) else: try: joiner.join() except joinutil.JoinError as err: _print_join_error(err) raise Fail( "failed to join to a domain - waiting for join is disabled")
def must_join(cli, config): """Perform a domain join if possible, otherwise wait or fail. If waiting is enabled the marker file is polled. """ joiner = joinutil.Joiner(cli.join_marker) if joiner.did_join(): print("already joined") return # Interactive join is not allowed on must-join setattr(cli, "interactive", False) _add_join_sources(joiner, cli, config) try: joiner.join() except joinutil.JoinError as err: _print_join_error(err) if not cli.wait: raise Fail( "failed to join to a domain and waiting for join is disabled") while True: if joiner.did_join(): print("found valid join marker") return time.sleep(WAIT_SECONDS)