mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
Fixes to httpapi for EAPI (#40675)
* Replace errant uses of str * Hook up become to eapi * Hook become up to nxapi, too
This commit is contained in:
parent
38c86b7eef
commit
0ad4b7b785
4 changed files with 36 additions and 17 deletions
|
@ -22,12 +22,19 @@ class HttpApi:
|
|||
self.connection = connection
|
||||
|
||||
def _run_queue(self, queue, output):
|
||||
if self._become:
|
||||
display.vvvv('firing event: on_become')
|
||||
queue.insert(0, 'enable')
|
||||
request = request_builder(queue, output)
|
||||
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
|
||||
response = self.connection.send('/ins', request, headers=headers, method='POST')
|
||||
response = json.loads(to_text(response.read()))
|
||||
return handle_response(response)
|
||||
results = handle_response(response)
|
||||
|
||||
if self._become:
|
||||
results = results[1:]
|
||||
return results
|
||||
|
||||
def send_request(self, data, **message_kwargs):
|
||||
output = None
|
||||
|
@ -62,6 +69,10 @@ class HttpApi:
|
|||
return responses[0]
|
||||
return responses
|
||||
|
||||
def set_become(self, play_context):
|
||||
self._become = play_context.become
|
||||
self._become_pass = getattr(play_context, 'become_pass') or ''
|
||||
|
||||
# Migrated from module_utils
|
||||
def edit_config(self, command):
|
||||
responses = self.send_request(command, output='config')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue