summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Carrez <thierry@openstack.org>2011-08-05 14:02:55 +0200
committerThierry Carrez <thierry@openstack.org>2011-08-05 14:02:55 +0200
commit2a89883297f6b5398abb7486e9e26c12ab0fc0ec (patch)
tree2e7d16a791102f9aac5919f7a9262726984e411a
parent502801bfff0015ed3aa93b9d65a87cb6b80fd11d (diff)
Remove spurious direct use of subprocess
-rw-r--r--nova/console/xvp.py1
-rw-r--r--nova/utils.py4
-rw-r--r--nova/virt/libvirt/connection.py3
3 files changed, 5 insertions, 3 deletions
diff --git a/nova/console/xvp.py b/nova/console/xvp.py
index 3cd287183..2d6842044 100644
--- a/nova/console/xvp.py
+++ b/nova/console/xvp.py
@@ -20,7 +20,6 @@
import fcntl
import os
import signal
-import subprocess
from Cheetah import Template
diff --git a/nova/utils.py b/nova/utils.py
index 1e2dbebb1..3a2049464 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -137,6 +137,8 @@ def execute(*cmd, **kwargs):
:delay_on_retry True | False. Defaults to True. If set to True, wait a
short amount of time before retrying.
:attempts How many times to retry cmd.
+ :shell True | False. Defaults to False. If set to True,
+ Popen command is called shell=True.
:raises exception.Error on receiving unknown arguments
:raises exception.ProcessExecutionError
@@ -147,6 +149,7 @@ def execute(*cmd, **kwargs):
check_exit_code = kwargs.pop('check_exit_code', 0)
delay_on_retry = kwargs.pop('delay_on_retry', True)
attempts = kwargs.pop('attempts', 1)
+ shell = kwargs.pop('shell', False)
if len(kwargs):
raise exception.Error(_('Got unknown keyword args '
'to utils.execute: %r') % kwargs)
@@ -164,6 +167,7 @@ def execute(*cmd, **kwargs):
stdin=_PIPE,
stdout=_PIPE,
stderr=_PIPE,
+ shell=shell,
env=env)
result = None
if process_input is not None:
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 0b93a8399..ec202a4ef 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -43,7 +43,6 @@ import os
import random
import re
import shutil
-import subprocess
import sys
import tempfile
import time
@@ -684,7 +683,7 @@ class LibvirtConnection(driver.ComputeDriver):
cmd = '%s/tools/ajaxterm/ajaxterm.py --command "%s" -t %s -p %s' \
% (utils.novadir(), ajaxterm_cmd, token, port)
- subprocess.Popen(cmd, shell=True)
+ utils.execute(cmd, shell=True)
return {'token': token, 'host': host, 'port': port}
def get_host_ip_addr(self):