Containers¶
Container based factories
- exception saltfactories.daemons.container.PyWinTypesError[source]¶
Bases:
Exception
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class saltfactories.daemons.container.Container(*, display_name=None, cwd=None, environ=None, image, name=None, check_ports=None, docker_client=None, container_run_kwargs=NOTHING, start_timeout=30, max_start_attempts=3, before_start_callbacks=NOTHING, before_terminate_callbacks=NOTHING, after_start_callbacks=NOTHING, after_terminate_callbacks=NOTHING)[source]¶
Bases:
saltfactories.bases.Factory
- Return type
None
- before_start(callback, *args, **kwargs)[source]¶
Register a function callback to run before the container starts
- Parameters
callback (Callable) – The function to call back
args – The arguments to pass to the callback
kwargs – The keyword arguments to pass to the callback
- after_start(callback, *args, **kwargs)[source]¶
Register a function callback to run after the container starts
- Parameters
callback (Callable) – The function to call back
args – The arguments to pass to the callback
kwargs – The keyword arguments to pass to the callback
- before_terminate(callback, *args, **kwargs)[source]¶
Register a function callback to run before the container terminates
- Parameters
callback (Callable) – The function to call back
args – The arguments to pass to the callback
kwargs – The keyword arguments to pass to the callback
- after_terminate(callback, *args, **kwargs)[source]¶
Register a function callback to run after the container terminates
- Parameters
callback (Callable) – The function to call back
args – The arguments to pass to the callback
kwargs – The keyword arguments to pass to the callback
- started(*command, max_start_attempts=None, start_timeout=None)[source]¶
Start the container and return it’s instance so it can be used as a context manager
- get_display_name()¶
Returns a human readable name for the factory
- class saltfactories.daemons.container.SaltDaemon(*, config, python_executable=None, system_install=False, cwd=None, environ=None, script_name, base_script_args=NOTHING, slow_stop=True, check_ports=None, factories_manager=None, start_timeout, max_start_attempts=3, extra_cli_arguments_after_first_start_failure=NOTHING, event_listener=None, started_at=None, image, name=None, docker_client=None, container_run_kwargs=NOTHING, before_start_callbacks=NOTHING, before_terminate_callbacks=NOTHING, after_start_callbacks=NOTHING, after_terminate_callbacks=NOTHING)[source]¶
Bases:
saltfactories.bases.SaltDaemon
,saltfactories.daemons.container.Container
- Return type
None
- cmdline(*args)[source]¶
Construct a list of arguments to use when starting the subprocess
- Parameters
args (str) – Additional arguments to use when starting the subprocess
- before_start(callback, *args, on_container=False, **kwargs)[source]¶
Register a function callback to run before the daemon starts
- after_start(callback, *args, on_container=False, **kwargs)[source]¶
Register a function callback to run after the daemon starts
- before_terminate(callback, *args, on_container=False, **kwargs)[source]¶
Register a function callback to run before the daemon terminates
- after_terminate(callback, *args, on_container=False, **kwargs)[source]¶
Register a function callback to run after the daemon terminates
- started(*extra_cli_arguments, max_start_attempts=None, start_timeout=None)[source]¶
Start the daemon and return it’s instance so it can be used as a context manager
- get_check_events()[source]¶
Return a list of tuples in the form of (master_id, event_tag) check against to ensure the daemon is running
- classmethod configure(factories_manager, daemon_id, root_dir=None, defaults=None, overrides=None, **configure_kwargs)[source]¶
Configure the salt daemon
- get_base_script_args()¶
Returns any additional arguments to pass to the CLI script
- 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
- classmethod load_config(config_file, config)[source]¶
Should return the configuration as the daemon would have loaded after parsing the CLI
- property pid¶
The pid of the running process. None if not running.
- stopped(before_stop_callback=None, after_stop_callback=None, before_start_callback=None, after_start_callback=None)¶
- Parameters
before_stop_callback (Callable) – A callable to run before stopping the daemon. The callback must accept one argument, the daemon instance.
after_stop_callback (Callable) – A callable to run after stopping the daemon. The callback must accept one argument, the daemon instance.
before_start_callback (Callable) – A callable to run before starting the daemon. The callback must accept one argument, the daemon instance.
after_start_callback (Callable) – A callable to run after starting the daemon. The callback must accept one argument, the daemon instance.
This context manager will stop the factory while the context is in place, it re-starts it once out of context.
For example:
assert factory.is_running() is True with factory.stopped(): assert factory.is_running() is False assert factory.is_running() is True
- class saltfactories.daemons.container.SaltMinion(*, config, python_executable=None, system_install=False, cwd=None, environ=None, script_name, base_script_args=NOTHING, slow_stop=True, check_ports=None, factories_manager=None, start_timeout, max_start_attempts=3, extra_cli_arguments_after_first_start_failure=NOTHING, event_listener=None, started_at=None, image, name=None, docker_client=None, container_run_kwargs=NOTHING, before_start_callbacks=NOTHING, before_terminate_callbacks=NOTHING, after_start_callbacks=NOTHING, after_terminate_callbacks=NOTHING)[source]¶
Bases:
saltfactories.daemons.container.SaltDaemon
,saltfactories.daemons.minion.SaltMinion
Salt minion daemon implementation running in a docker container
- Return type
None
- get_check_events()[source]¶
Return a list of tuples in the form of (master_id, event_tag) check against to ensure the daemon is running
- after_start(callback, *args, on_container=False, **kwargs)¶
Register a function callback to run after the daemon starts
- after_terminate(callback, *args, on_container=False, **kwargs)¶
Register a function callback to run after the daemon terminates
- before_start(callback, *args, on_container=False, **kwargs)¶
Register a function callback to run before the daemon starts
- before_terminate(callback, *args, on_container=False, **kwargs)¶
Register a function callback to run before the daemon terminates
- cmdline(*args)¶
Construct a list of arguments to use when starting the subprocess
- Parameters
args (str) – Additional arguments to use when starting the subprocess
- classmethod configure(factories_manager, daemon_id, root_dir=None, defaults=None, overrides=None, **configure_kwargs)¶
Configure the salt daemon
- get_base_script_args()¶
Returns any additional arguments to pass to the CLI script
- get_check_ports()¶
Return a list of ports to check against to ensure the daemon is running
- get_display_name()¶
Returns a human readable name for the factory
- get_script_path()¶
Returns the path to the script to run
- is_running()¶
Returns true if the sub-process is alive
- classmethod load_config(config_file, config)[source]¶
Should return the configuration as the daemon would have loaded after parsing the CLI
- property pid¶
The pid of the running process. None if not running.
- salt_call_cli(factory_class=<class 'saltfactories.cli.call.SaltCall'>, **factory_class_kwargs)[source]¶
Return a salt-call CLI process for this minion instance
- start(*extra_cli_arguments, max_start_attempts=None, start_timeout=None)¶
Start the daemon
- started(*extra_cli_arguments, max_start_attempts=None, start_timeout=None)¶
Start the daemon and return it’s instance so it can be used as a context manager
- stopped(before_stop_callback=None, after_stop_callback=None, before_start_callback=None, after_start_callback=None)¶
- Parameters
before_stop_callback (Callable) – A callable to run before stopping the daemon. The callback must accept one argument, the daemon instance.
after_stop_callback (Callable) – A callable to run after stopping the daemon. The callback must accept one argument, the daemon instance.
before_start_callback (Callable) – A callable to run before starting the daemon. The callback must accept one argument, the daemon instance.
after_start_callback (Callable) – A callable to run after starting the daemon. The callback must accept one argument, the daemon instance.
This context manager will stop the factory while the context is in place, it re-starts it once out of context.
For example:
assert factory.is_running() is True with factory.stopped(): assert factory.is_running() is False assert factory.is_running() is True
- terminate()¶
Terminate the started daemon
- classmethod write_config(config)¶
Write the configuration to file