summaryrefslogtreecommitdiff
path: root/ironic_python_agent/utils.py
diff options
context:
space:
mode:
authorRuby Loo <ruby.loo@intel.com>2016-07-27 16:28:43 -0400
committerRuby Loo <ruby.loo@intel.com>2016-07-27 16:28:43 -0400
commit81ca8a87443a47ece86801b3212e8404d279d2c0 (patch)
tree342a24a4fb9b319913d435dd4fc519b78ce16a6e /ironic_python_agent/utils.py
parent913c2a1ea5d55caa4338f13060faf152948b4cb1 (diff)
downloadironic-python-agent-81ca8a87443a47ece86801b3212e8404d279d2c0.tar.gz
Use ironic_lib's execute()
Use ironic_lib's execute() instead of copying that code. Change-Id: If40c2da5423d0f90cc6661f8cdf2bec9567e1f7d Partial-Bug: #1587199
Diffstat (limited to 'ironic_python_agent/utils.py')
-rw-r--r--ironic_python_agent/utils.py22
1 files changed, 4 insertions, 18 deletions
diff --git a/ironic_python_agent/utils.py b/ironic_python_agent/utils.py
index 8e50987f..421af0b1 100644
--- a/ironic_python_agent/utils.py
+++ b/ironic_python_agent/utils.py
@@ -24,6 +24,7 @@ import tarfile
import tempfile
import time
+from ironic_lib import utils as ironic_utils
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import units
@@ -59,26 +60,11 @@ COLLECT_LOGS_COMMANDS = {
def execute(*cmd, **kwargs):
- """Convenience wrapper around oslo's execute() method.
+ """Convenience wrapper around ironic_lib's execute() method.
- Executes and logs results from a system command. See docs for
- oslo_concurrency.processutils.execute for usage.
-
- :param *cmd: positional arguments to pass to processutils.execute()
- :param log_stdout: keyword-only argument: whether to log the output
- :param **kwargs: keyword arguments to pass to processutils.execute()
- :raises: UnknownArgumentError on receiving unknown arguments
- :raises: ProcessExecutionError
- :raises: OSError
- :returns: tuple of (stdout, stderr)
+ Executes and logs results from a system command.
"""
- log_stdout = kwargs.pop('log_stdout', True)
- result = processutils.execute(*cmd, **kwargs)
- LOG.debug('Execution completed, command line is "%s"', ' '.join(cmd))
- if log_stdout:
- LOG.debug('Command stdout is: "%s"', result[0])
- LOG.debug('Command stderr is: "%s"', result[1])
- return result
+ return ironic_utils.execute(*cmd, **kwargs)
def try_execute(*cmd, **kwargs):