oslo_concurrency.processutils
¶System-level utilities and helper functions.
oslo_concurrency.processutils.
InvalidArgumentError
(message=None)¶Bases: Exception
oslo_concurrency.processutils.
LogErrors
¶Bases: enum.IntEnum
Enumerations that affect if stdout and stderr are logged on error.
New in version 2.7.
ALL
= 1¶Log an error on each occurence of an error.
DEFAULT
= 0¶No logging on errors.
FINAL
= 2¶Log an error on the last attempt that errored only.
oslo_concurrency.processutils.
NoRootWrapSpecified
(message=None)¶Bases: Exception
oslo_concurrency.processutils.
ProcessExecutionError
(stdout=None, stderr=None, exit_code=None, cmd=None, description=None)¶Bases: Exception
oslo_concurrency.processutils.
ProcessLimits
(**kw)¶Bases: object
Resource limits on a process.
Attributes:
This object can be used for the prlimit parameter of execute()
.
prlimit_args
()¶Create a list of arguments for the prlimit command line.
oslo_concurrency.processutils.
UnknownArgumentError
(message=None)¶Bases: Exception
oslo_concurrency.processutils.
execute
(*cmd, **kwargs)¶Helper method to shell out and execute a command through subprocess.
Allows optional retry.
Parameters: |
|
---|---|
Returns: | (stdout, stderr) from process execution |
Raises: |
|
Raises: | |
Raises: |
|
The prlimit parameter can be used to set resource limits on the child process. If this parameter is used, the child process will be spawned by a wrapper process which will set limits before spawning the command.
Changed in version 3.17: process_input can now be either bytes or string on python3.
Changed in version 3.4: Added prlimit optional parameter.
Changed in version 1.5: Added cwd optional parameter.
Changed in version 1.9: Added binary optional parameter. On Python 3, stdout and stderr are now returned as Unicode strings by default, or bytes if binary is true.
Changed in version 2.1: Added on_execute and on_completion optional parameters.
Changed in version 2.3: Added preexec_fn optional parameter.
oslo_concurrency.processutils.
get_worker_count
()¶Utility to get the default worker count.
Returns: | The number of CPUs if that can be determined, else a default worker count of 1 is returned. |
---|
oslo_concurrency.processutils.
ssh_execute
(ssh, cmd, process_input=None, addl_env=None, check_exit_code=True, binary=False, timeout=None, sanitize_stdout=True)¶Run a command through SSH.
Parameters: |
|
---|---|
Returns: | (stdout, stderr) from command execution through SSH. |
Changed in version 1.9: Added binary optional parameter.
oslo_concurrency.processutils.
trycmd
(*args, **kwargs)¶A wrapper around execute() to more easily handle warnings and errors.
Returns an (out, err) tuple of strings containing the output of the command’s stdout and stderr. If ‘err’ is not empty then the command can be considered to have failed.
Parameters: | discard_warnings (boolean) – True | False. Defaults to False. If set to True, then for succeeding commands, stderr is cleared |
---|---|
Returns: | (out, err) from process execution |
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.