mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
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:
parent
49993a55e5
commit
1829a72885
13 changed files with 75 additions and 83 deletions
|
@ -131,7 +131,6 @@ options:
|
|||
|
||||
from ansible.errors import AnsibleConnectionFailure, AnsibleError
|
||||
from ansible.plugins.connection import NetworkConnectionBase
|
||||
from ansible.utils.display import Display
|
||||
|
||||
try:
|
||||
from napalm import get_network_driver
|
||||
|
@ -140,8 +139,6 @@ try:
|
|||
except ImportError:
|
||||
HAS_NAPALM = False
|
||||
|
||||
display = Display()
|
||||
|
||||
|
||||
class Connection(NetworkConnectionBase):
|
||||
"""Napalm connections"""
|
||||
|
@ -168,7 +165,7 @@ class Connection(NetworkConnectionBase):
|
|||
'Unable to automatically determine host network os. Please '
|
||||
'manually configure ansible_network_os value for this host'
|
||||
)
|
||||
display.display('network_os is set to %s' % self._network_os, log_only=True)
|
||||
self.queue_message('log', 'network_os is set to %s' % self._network_os)
|
||||
|
||||
try:
|
||||
driver = get_network_driver(self._network_os)
|
||||
|
@ -186,7 +183,7 @@ class Connection(NetworkConnectionBase):
|
|||
self.napalm.open()
|
||||
|
||||
self._sub_plugin = {'type': 'external', 'name': 'napalm', 'obj': self.napalm}
|
||||
display.vvvv('created napalm device for network_os %s' % self._network_os, host=host)
|
||||
self.queue_message('vvvv', 'created napalm device for network_os %s' % self._network_os)
|
||||
self._connected = True
|
||||
|
||||
def close(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue