summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
authorArata Notsu <notsu@virtualtech.jp>2012-08-26 02:47:53 +0900
committerArata Notsu <notsu@virtualtech.jp>2012-08-28 06:24:28 +0900
commitc2f56b12f48e0f23b3715fe06dbff97416cd66e3 (patch)
tree36d0cfce2559bb887231f563784c00d943965f2b /nova/utils.py
parent0d1e9ef251ce91d72d9671c5b4c8c02c87205d3a (diff)
Correct utils.execute() to check 0 in check_exit_code
If a process exits with returncode 0, the function always returns without raising a exception, regardless of whether its check_exit_code includes 0 or not. This patch fixes it; if check_exit_code does not includes 0 and a process exits with 0, ProcessExecutionError is raised. (No change required to caller-side since no one misses 0 in check_exit_code) Change-Id: I824a9bc5e42038e27df6757cd47c06073681c342
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 6f199e659..479ddaf46 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -188,15 +188,14 @@ def execute(*cmd, **kwargs):
result = obj.communicate()
obj.stdin.close() # pylint: disable=E1101
_returncode = obj.returncode # pylint: disable=E1101
- if _returncode:
- LOG.debug(_('Result was %s') % _returncode)
- if not ignore_exit_code and _returncode not in check_exit_code:
- (stdout, stderr) = result
- raise exception.ProcessExecutionError(
- exit_code=_returncode,
- stdout=stdout,
- stderr=stderr,
- cmd=' '.join(cmd))
+ LOG.debug(_('Result was %s') % _returncode)
+ if not ignore_exit_code and _returncode not in check_exit_code:
+ (stdout, stderr) = result
+ raise exception.ProcessExecutionError(
+ exit_code=_returncode,
+ stdout=stdout,
+ stderr=stderr,
+ cmd=' '.join(cmd))
return result
except exception.ProcessExecutionError:
if not attempts: