Allow persistent connection plugins to queue messages back to ansible-connection (#49977)

* Connections can queue messages to be returned from ansible-connection

* Provide fallback for invalid display level

* Strip display from plugins

* Route messages through helper method to try to avoid improper appends
This commit is contained in:
Nathaniel Case 2018-12-19 10:54:42 -05:00 committed by GitHub
parent 49993a55e5
commit 1829a72885
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 75 additions and 83 deletions

View file

@ -60,7 +60,6 @@ from ansible.plugins.httpapi import HttpApiBase
from urllib3 import encode_multipart_formdata
from urllib3.fields import RequestField
from ansible.module_utils.connection import ConnectionError
from ansible.utils.display import Display
BASE_HEADERS = {
'Content-Type': 'application/json',
@ -70,8 +69,6 @@ BASE_HEADERS = {
TOKEN_EXPIRATION_STATUS_CODE = 408
UNAUTHORIZED_STATUS_CODE = 401
display = Display()
class HttpApi(HttpApiBase):
def __init__(self, connection):
@ -224,7 +221,7 @@ class HttpApi(HttpApiBase):
return None
def _display(self, http_method, title, msg=''):
display.vvvv('REST:%s:%s:%s\n%s' % (http_method, self.connection._url, title, msg))
self.connection.queue_message('vvvv', 'REST:%s:%s:%s\n%s' % (http_method, self.connection._url, title, msg))
@staticmethod
def _get_response_value(response_data):