def construct_remote_exec_copy_patterns(args): # default remote cmd patterns args.remote_cmds_cleanup_pattern = "" args.remote_exec_pattern = None args.remote_copy_pattern = None # Determine forcing IPv4/IPv6 options if any, only for # default remote commands. if args.force_ipv: force_addr_opt = " -{}".format(args.force_ipv) else: force_addr_opt = "" args_dict = vars(args) # if remote-exec and/or remote-copy args are None then user # didn't specify command line options nor env vars: # inspect multiplexing options for default cdist.REMOTE_COPY/EXEC if (args_dict['remote_copy'] is None or args_dict['remote_exec'] is None): mux_opts = inspect_ssh_mux_opts() if args_dict['remote_exec'] is None: args.remote_exec_pattern = (cdist.REMOTE_EXEC + force_addr_opt + mux_opts) if args_dict['remote_copy'] is None: args.remote_copy_pattern = (cdist.REMOTE_COPY + force_addr_opt + mux_opts) if mux_opts: cleanup_pattern = cdist.REMOTE_CMDS_CLEANUP_PATTERN else: cleanup_pattern = "" args.remote_cmds_cleanup_pattern = cleanup_pattern
def _check_and_prepare_args(cls, args): if args.manifest == '-' and args.hostfile == '-': raise cdist.Error(("Cannot read both, manifest and host file, " "from stdin")) # if no host source is specified then read hosts from stdin if not (args.hostfile or args.host): args.hostfile = '-' initial_manifest_tempfile = None if args.manifest == '-': # read initial manifest from stdin try: handle, initial_manifest_temp_path = tempfile.mkstemp( prefix='cdist.stdin.') with os.fdopen(handle, 'w') as fd: fd.write(sys.stdin.read()) except (IOError, OSError) as e: raise cdist.Error(("Creating tempfile for stdin data " "failed: %s" % e)) args.manifest = initial_manifest_temp_path import atexit atexit.register(lambda: os.remove(initial_manifest_temp_path)) # default remote cmd patterns args.remote_exec_pattern = None args.remote_copy_pattern = None args_dict = vars(args) # if remote-exec and/or remote-copy args are None then user # didn't specify command line options nor env vars: # inspect multiplexing options for default cdist.REMOTE_COPY/EXEC if (args_dict['remote_copy'] is None or args_dict['remote_exec'] is None): mux_opts = inspect_ssh_mux_opts() if args_dict['remote_exec'] is None: args.remote_exec_pattern = cdist.REMOTE_EXEC + mux_opts if args_dict['remote_copy'] is None: args.remote_copy_pattern = cdist.REMOTE_COPY + mux_opts
def construct_remote_exec_copy_patterns(args): # default remote cmd patterns args.remote_cmds_cleanup_pattern = "" args.remote_exec_pattern = None args.remote_copy_pattern = None args_dict = vars(args) # if remote-exec and/or remote-copy args are None then user # didn't specify command line options nor env vars: # inspect multiplexing options for default cdist.REMOTE_COPY/EXEC if (args_dict['remote_copy'] is None or args_dict['remote_exec'] is None): mux_opts = inspect_ssh_mux_opts() if args_dict['remote_exec'] is None: args.remote_exec_pattern = cdist.REMOTE_EXEC + mux_opts if args_dict['remote_copy'] is None: args.remote_copy_pattern = cdist.REMOTE_COPY + mux_opts if mux_opts: cleanup_pattern = cdist.REMOTE_CMDS_CLEANUP_PATTERN else: cleanup_pattern = "" args.remote_cmds_cleanup_pattern = cleanup_pattern