Fix mixed output from ansible and lxd when using the lxd connection plugin (#45246)

* Replace fetch and put operations with Popen instead of call to prevent lxd to mess the Ansible output

* Remove extra blank line
This commit is contained in:
Sofiane Medjkoune 2018-09-19 01:36:51 +02:00 committed by ansibot
parent be199cfe90
commit af40d8c2a5

View file

@ -31,7 +31,7 @@ DOCUMENTATION = """
import os
from distutils.spawn import find_executable
from subprocess import call, Popen, PIPE
from subprocess import Popen, PIPE
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
from ansible.module_utils._text import to_bytes, to_text
@ -103,7 +103,8 @@ class Connection(ConnectionBase):
local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
call(local_cmd)
process = Popen(local_cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
process.communicate()
def fetch_file(self, in_path, out_path):
""" fetch a file from lxd to local """
@ -115,7 +116,8 @@ class Connection(ConnectionBase):
local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
call(local_cmd)
process = Popen(local_cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
process.communicate()
def close(self):
""" close the connection (nothing to do here) """