summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorJohannes Erdfelt <johannes.erdfelt@rackspace.com>2014-02-28 15:35:34 +0000
committerJohannes Erdfelt <johannes.erdfelt@rackspace.com>2014-02-28 16:25:21 +0000
commit27c80860280ca5f7983d207cdbfd217ac1a2d68d (patch)
treed74b04d24893e83ae105758a349801ea653c6d9c /plugins
parentf35c63df24d8f47927d055729e9ca08c7bc3fe8c (diff)
downloadnova-27c80860280ca5f7983d207cdbfd217ac1a2d68d.tar.gz
xenapi plugins: Make sure subprocesses finish executing
Fixes bug 1286187 Neither execute_get_output() nor execute() would wait for the process to fully finish executing. This could potentially create a race condition where commands execute in a different order than intended. Also, for execute() it could cause a process to never finish executing if it generates enough output to block writing to the pipe. Change-Id: I3404f4b3ca1cddeec2f3e7b393817a6ccc42bec7
Diffstat (limited to 'plugins')
-rw-r--r--plugins/xenserver/networking/etc/xensource/scripts/novalib.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/plugins/xenserver/networking/etc/xensource/scripts/novalib.py b/plugins/xenserver/networking/etc/xensource/scripts/novalib.py
index 4785b63d71..17da30c7d7 100644
--- a/plugins/xenserver/networking/etc/xensource/scripts/novalib.py
+++ b/plugins/xenserver/networking/etc/xensource/scripts/novalib.py
@@ -26,13 +26,13 @@ def execute_get_output(*command):
proc = subprocess.Popen(command, close_fds=True,
stdout=subprocess.PIPE, stderr=devnull)
devnull.close()
- return proc.stdout.read().strip()
+ stdout = proc.communicate()[0]
+ return stdout.strip()
def execute(*command):
"""Execute without returning stdout."""
devnull = open(os.devnull, 'w')
command = map(str, command)
- proc = subprocess.Popen(command, close_fds=True,
- stdout=subprocess.PIPE, stderr=devnull)
+ subprocess.call(command, close_fds=True, stdout=devnull, stderr=devnull)
devnull.close()