spm#

spm CLI factory.

class saltfactories.cli.spm.Spm(*, 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

spm CLI factory.

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

Overridden method because spm does not target minions.

static default_config(root_dir, master_factory, defaults=None, overrides=None)[source]#

Return the default configuration for the daemon.

classmethod configure(master_factory, root_dir=None, defaults=None, overrides=None)[source]#

Configure the CLI.

classmethod verify_config(config)[source]#

Verify the configuration dictionary.

classmethod write_config(config)[source]#

Verify the loaded configuration.

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.

process_output(stdout, stderr, cmdline=None)#

Process the output. When possible JSON is loaded from the output.

Returns:

Returns a tuple in the form of (stdout, stderr, loaded_json)

Return type:

tuple

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