Salt Factories Manager#
Salt Factories Manager.
- class saltfactories.manager.FactoriesManager(*, root_dir, log_server_port, log_server_level, log_server_host, python_executable=None, scripts_dir=None, code_dir=None, coverage_db_path=None, coverage_rc_path=None, inject_sitecustomize=False, cwd=_Nothing.NOTHING, environ=_Nothing.NOTHING, slow_stop=True, start_timeout=None, stats_processes=None, system_service=False, event_listener)[source]#
Bases:
object
Factories manager implementation.
The
FactoriesManager
is responsible for configuring and spawning Salt Daemons and making sure that any salt CLI tools are “targeted” to the right daemon.It also keeps track of which daemons were started and adds their termination routines to PyTest’s request finalization routines.
If process statistics are enabled, it also adds the started daemons to those statistics.
- Arguments:
- root_dir:
The root directory from where to base all paths. For example, in a salt system installation, this would be
/
.- log_server_port:
The port the log server should listen at
- log_server_level:
The level of the log server
- log_server_host:
The hostname/ip address of the host running the logs server. Defaults to “localhost”.
- Keyword Arguments:
- python_executable:
The python executable to use, where needed. If
scripts_dir
is notNone
, thenpython_executable
will default toNone
, otherwise, defaults to py:attr:sys.executable.- scripts_dir:
The paths to the directory containing the Salt CLI scripts. The several scripts to the Salt daemons and CLI’s must exist. Passing this option will also make salt-factories NOT generate said scripts and set
python_executable
toNone
.- code_dir:
The path to the code root directory of the project being tested. This is important for proper code-coverage paths.
- coverage_db_path:
The path to the .coverage DB file
- coverage_rc_path:
The path to the .coveragerc file
- inject_sitecustomize:
Inject code in the generated CLI scripts in order for our sitecustomise.py to be loaded by subprocesses.
- cwd:
The path to the current working directory
- environ:
A dictionary of key, value pairs to add to the environment.
- slow_stop:
Whether to terminate the processes by sending a
SIGTERM
signal or by callingterminate()
on the sub-process. When code coverage is enabled, one will want slow_stop set to True so that coverage data can be written down to disk.- start_timeout:
The amount of time, in seconds, to wait, until a subprocess is considered as not started.
- stats_processes:
This will be an
pytestsysstats.plugin.StatsProcesses
class instantiated on thepytest_sessionstart()
hook accessible as a session scoped stats_processes fixture.- system_service:
If true, the daemons and CLI’s are run against a system installed salt setup, ie, the default salt system paths apply and the daemon and CLI scripts will be searched for in
$PATH
.
- static get_salt_log_handlers_path()[source]#
Returns the path to the Salt log handler this plugin provides.
- salt_master_daemon(master_id, order_masters=False, master_of_masters=None, defaults=None, overrides=None, max_start_attempts=3, start_timeout=None, factory_class=<class 'saltfactories.daemons.master.SaltMaster'>, **factory_class_kwargs)[source]#
Return a salt-master instance.
- Args:
- master_id(str):
The master ID
- order_masters(bool):
Boolean flag to set if this master is going to control other masters(ie, master of masters), like, for example, in a Syndic topology scenario
- master_of_masters(
saltfactories.daemons.master.SaltMaster
): A
saltfactories.daemons.master.SaltMaster
instance, like, for example, in a Syndic topology scenario- defaults(dict):
A dictionary of default configuration to use when configuring the master
- overrides(dict):
A dictionary of configuration overrides to use when configuring the master
- max_start_attempts(int):
How many attempts should be made to start the master in case of failure to validate that its running
- factory_class_kwargs(dict):
Extra keyword arguments to pass to
saltfactories.daemons.master.SaltMaster
- Returns:
saltfactories.daemons.master.SaltMaster
:The master process class instance
- salt_minion_daemon(minion_id, master=None, defaults=None, overrides=None, max_start_attempts=3, start_timeout=None, factory_class=<class 'saltfactories.daemons.minion.SaltMinion'>, **factory_class_kwargs)[source]#
Return a salt-minion instance.
- Args:
- minion_id(str):
The minion ID
- master(
saltfactories.daemons.master.SaltMaster
): An instance of
saltfactories.daemons.master.SaltMaster
that this minion will connect to.- defaults(dict):
A dictionary of default configuration to use when configuring the minion
- overrides(dict):
A dictionary of configuration overrides to use when configuring the minion
- max_start_attempts(int):
How many attempts should be made to start the minion in case of failure to validate that its running
- factory_class_kwargs(dict):
Extra keyword arguments to pass to
SaltMinion
- Returns:
SaltMinion
:The minion process class instance
- salt_syndic_daemon(syndic_id, master_of_masters=None, defaults=None, overrides=None, max_start_attempts=3, start_timeout=None, factory_class=<class 'saltfactories.daemons.syndic.SaltSyndic'>, master_defaults=None, master_overrides=None, master_factory_class=<class 'saltfactories.daemons.master.SaltMaster'>, minion_defaults=None, minion_overrides=None, minion_factory_class=<class 'saltfactories.daemons.minion.SaltMinion'>, **factory_class_kwargs)[source]#
Return a salt-syndic instance.
- Args:
- syndic_id(str):
The Syndic ID. This ID will be shared by the
salt-master
,salt-minion
andsalt-syndic
processes.- master_of_masters(
saltfactories.daemons.master.SaltMaster
): An instance of
saltfactories.daemons.master.SaltMaster
that the master configured in this Syndic topology scenario shall connect to.- defaults(dict):
A dictionary of default configurations with three top level keys,
master
,minion
andsyndic
, to use when configuring thesalt-master
,salt-minion
andsalt-syndic
respectively.- overrides(dict):
A dictionary of configuration overrides with three top level keys,
master
,minion
andsyndic
, to use when configuring thesalt-master
,salt-minion
andsalt-syndic
respectively.- max_start_attempts(int):
How many attempts should be made to start the syndic in case of failure to validate that its running
- factory_class_kwargs(dict):
Extra keyword arguments to pass to
SaltSyndic
- Returns:
SaltSyndic
:The syndic process class instance
- salt_proxy_minion_daemon(proxy_minion_id, master=None, defaults=None, overrides=None, max_start_attempts=3, start_timeout=None, factory_class=<class 'saltfactories.daemons.proxy.SaltProxyMinion'>, **factory_class_kwargs)[source]#
Return a salt proxy-minion instance.
- Args:
- proxy_minion_id(str):
The proxy minion ID
- master(
saltfactories.daemons.master.SaltMaster
): An instance of
saltfactories.daemons.master.SaltMaster
that this minion will connect to.- defaults(dict):
A dictionary of default configuration to use when configuring the proxy minion
- overrides(dict):
A dictionary of configuration overrides to use when configuring the proxy minion
- max_start_attempts(int):
How many attempts should be made to start the proxy minion in case of failure to validate that its running
- factory_class_kwargs(dict):
Extra keyword arguments to pass to
SaltProxyMinion
- Returns:
SaltProxyMinion
:The proxy minion process class instance
- salt_api_daemon(master, max_start_attempts=3, start_timeout=None, factory_class=<class 'saltfactories.daemons.api.SaltApi'>, **factory_class_kwargs)[source]#
Return a salt-api instance.
Please see py:class:~saltfactories.manager.FactoriesManager.salt_master_daemon for argument documentation.
- Returns:
SaltApi
:The salt-api process class instance
- get_sshd_daemon(config_dir=None, listen_address=None, listen_port=None, sshd_config_dict=None, display_name=None, script_name='sshd', max_start_attempts=3, start_timeout=None, factory_class=<class 'saltfactories.daemons.sshd.Sshd'>, **factory_class_kwargs)[source]#
Return an SSHD daemon instance.
- Args:
- max_start_attempts(int):
How many attempts should be made to start the proxy minion in case of failure to validate that its running
- config_dir(pathlib.Path):
The path to the sshd config directory
- listen_address(str):
The address where the sshd server will listen to connections. Defaults to 127.0.0.1
- listen_port(int):
The port where the sshd server will listen to connections
- sshd_config_dict(dict):
A dictionary of key-value pairs to construct the sshd config file
- script_name(str):
The name or path to the binary to run. Defaults to
sshd
.- factory_class_kwargs(dict):
Extra keyword arguments to pass to
Sshd
- Returns:
Sshd
:The sshd process class instance
- get_container(container_name, image_name, display_name=None, factory_class=<class 'saltfactories.daemons.container.Container'>, max_start_attempts=3, start_timeout=None, **factory_class_kwargs)[source]#
Return a container instance.
- Args:
- container_name(str):
The name to give the container
- image_name(str):
The image to use
- display_name(str):
Human readable name for the factory
- factory_class:
A factory class. (Default
Container
)- max_start_attempts(int):
How many attempts should be made to start the container in case of failure to validate that its running.
- start_timeout(int):
The amount of time, in seconds, to wait, until the container is considered as not started.
- factory_class_kwargs(dict):
Extra keyword arguments to pass to
Container
- Returns:
Container
:The factory instance