From d4a89c8ead35bc2020ae41542027a1dba44cae88 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 30 Jan 2015 15:09:09 -0500 Subject: [PATCH] moved from callback_output to popen to keep 2.6 compat --- plugins/inventory/vbox.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/inventory/vbox.py b/plugins/inventory/vbox.py index 0850a9119cd..ff31785d7e3 100755 --- a/plugins/inventory/vbox.py +++ b/plugins/inventory/vbox.py @@ -16,7 +16,7 @@ # along with Ansible. If not, see . import sys -from subprocess import check_output +from subprocess import Popen,PIPE try: import json @@ -32,17 +32,17 @@ def get_hosts(host=None): returned = {} try: if host: - results = check_output([VBOX, 'showvminfo', host]) + p = Popen([VBOX, 'showvminfo', host], stdout=PIPE) else: returned = { 'all': set(), '_metadata': {} } - results = check_output([VBOX, 'list', '-l', 'vms']) + p = Popen([VBOX, 'list', '-l', 'vms'], stdout=PIPE) except: sys.exit(1) hostvars = {} prevkey = pref_k = '' - for line in results.splitlines(): + for line in p.stdout.readlines(): try: k,v = line.split(':',1) @@ -58,9 +58,10 @@ def get_hosts(host=None): curname = v hostvars[curname] = {} try: # try to get network info - ip_info = check_output([VBOX, 'guestproperty', 'get', curname,"/VirtualBox/GuestInfo/Net/0/V4/IP"]) - if 'Value' in ip_info: - a,ip = ip_info.split(':',1) + x = Popen([VBOX, 'guestproperty', 'get', curname,"/VirtualBox/GuestInfo/Net/0/V4/IP"],stdout=PIPE) + ipinfo = x.stdout.read() + if 'Value' in ipinfo: + a,ip = ipinfo.split(':',1) hostvars[curname]['ansible_ssh_host'] = ip.strip() except: pass