mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -07:00
Network load_config: Capture configuration output and display as warnings (#27851)
* Capture configuration output and display as warnings * Don't break on nxapi nxapi errors very loudly instead, so no need to muck about with warnings
This commit is contained in:
parent
2af759e9f9
commit
c1bf74283e
4 changed files with 9 additions and 3 deletions
|
@ -165,16 +165,21 @@ class Cli:
|
|||
def load_config(self, config):
|
||||
"""Sends configuration commands to the remote device
|
||||
"""
|
||||
|
||||
rc, out, err = self.exec_command('configure')
|
||||
if rc != 0:
|
||||
self._module.fail_json(msg='unable to enter configuration mode', output=to_text(err, errors='surrogate_then_replace'))
|
||||
|
||||
msgs = []
|
||||
for cmd in config:
|
||||
rc, out, err = self.exec_command(cmd)
|
||||
if rc != 0:
|
||||
self._module.fail_json(msg=to_text(err, errors='surrogate_then_replace'))
|
||||
elif out:
|
||||
msgs.append(out)
|
||||
|
||||
self.exec_command('end')
|
||||
return msgs
|
||||
|
||||
|
||||
class Nxapi:
|
||||
|
@ -343,6 +348,7 @@ class Nxapi:
|
|||
"""
|
||||
commands = to_list(commands)
|
||||
self.send_request(commands, output='config')
|
||||
return []
|
||||
|
||||
|
||||
def is_json(cmd):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue