The cinder.openstack.common.processutils Module

System-level utilities and helper functions.

exception InvalidArgumentError(message=None)

Bases: exceptions.Exception

exception NoRootWrapSpecified(message=None)

Bases: exceptions.Exception

exception ProcessExecutionError(stdout=None, stderr=None, exit_code=None, cmd=None, description=None)

Bases: exceptions.Exception

exception UnknownArgumentError(message=None)

Bases: exceptions.Exception

execute(*cmd, **kwargs)

Helper method to shell out and execute a command through subprocess.

Allows optional retry.

Parameters:
  • cmd (string) – Passed to subprocess.Popen.
  • process_input – Send to opened process.
  • check_exit_code (boolean, int, or [int]) – Single bool, int, or list of allowed exit codes. Defaults to [0]. Raise ProcessExecutionError unless program exits with one of these code.
  • delay_on_retry (boolean) – True | False. Defaults to True. If set to True, wait a short amount of time before retrying.
  • attempts (int) – How many times to retry cmd.
  • run_as_root (boolean) – True | False. Defaults to False. If set to True, the command is prefixed by the command specified in the root_helper kwarg.
  • root_helper (string) – command to prefix to commands called with run_as_root=True
  • shell (boolean) – whether or not there should be a shell used to execute this command. Defaults to false.
  • loglevel (int. (Should be logging.DEBUG or logging.INFO)) – log level for execute commands.
Returns:

(stdout, stderr) from process execution

Raises:

UnknownArgumentError on receiving unknown arguments

Raises:

ProcessExecutionError

ssh_execute(ssh, cmd, process_input=None, addl_env=None, check_exit_code=True)
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.

:discard_warnings True | False. Defaults to False. If set to True,
then for succeeding commands, stderr is cleared

Previous topic

The cinder.openstack.common.policy Module

Next topic

The cinder.openstack.common.request_utils Module

This Page