salt-run#

salt-run CLI factory.

class saltfactories.cli.run.SaltRun(*, config, config_dir=_Nothing.NOTHING, python_executable=None, system_service=False, cwd=_Nothing.NOTHING, environ=_Nothing.NOTHING, slow_stop=True, system_encoding=_Nothing.NOTHING, timeout=_Nothing.NOTHING, script_name, base_script_args=_Nothing.NOTHING, hard_crash=False, merge_json_output=True)[source]#

Bases: SaltCli

salt-run CLI factory.

Parameters:
get_minion_tgt(minion_tgt=None)[source]#

Overridden method because salt-run does not target minions.

process_output(stdout, stderr, cmdline=None)[source]#

Process the returned output.

cmdline(*args, minion_tgt=None, merge_json_output=None, **kwargs)#

Construct a list of arguments to use when starting the subprocess.

Parameters:
  • args (str) – Additional arguments to use when starting the subprocess

  • minion_tgt (str) – The minion ID to target

  • merge_json_output (bool) – The default behavior of salt outputters is to print one line per minion return, which makes parsing the whole output as JSON impossible when targeting multiple minions. If this value is True, an attempt is made to merge each JSON line into a single dictionary.

  • kwargs – Additional keyword arguments will be converted into key=value pairs to be consumed by the salt CLI’s

get_base_script_args()#

Returns any additional arguments to pass to the CLI script.

Return type:

List[str]

get_display_name()#

Returns a human readable name for the factory.

get_script_args()#

Returns any additional arguments to pass to the CLI script.

get_script_path()#

Returns the path to the script to run.

Return type:

str

is_running()#

Returns true if the sub-process is alive.

Return type:

bool

property pid: int | None#

The pid of the running process. None if not running.

run(*args, env=None, _timeout=None, **kwargs)#

Run the given command synchronously.

Keyword Arguments:
args:

The list of arguments to pass to cmdline() to construct the command to run

env:

Pass a dictionary of environment key, value pairs to inject into the subprocess.

_timeout:

The timeout value for this particular run() call. If this value is not None, it will be used instead of timeout, the default timeout.

Parameters:
Return type:

ProcessResult

terminate()#

Terminate the started subprocess.

Return type:

ProcessResult