From 2a89883297f6b5398abb7486e9e26c12ab0fc0ec Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Fri, 5 Aug 2011 14:02:55 +0200 Subject: Remove spurious direct use of subprocess --- nova/console/xvp.py | 1 - nova/utils.py | 4 ++++ nova/virt/libvirt/connection.py | 3 +-- 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): -- cgit