This task plugin uses
to send multiple commands to devices pre-processing commands accordingly.
Check and if any - retrieve per-host commands from host’s inventory data
If command is a multi-line string, split it to individual lines or form a list with single command
Iterate over commands list and remove empty strings
Iterate over commands and replace
interval argument provided commands send one by one to device using
napalm_cli task plugin sleeping for given
interval between commands. If
interval argument is not provided, all commands sent at once.
nornir-napalm module required
napalm_send_commands sample usage
Code to invoke
from nornir_salt import napalm_send_commands output = nr.run( task=napalm_send_commands, commands=["show run", "show clock"] )
napalm_send_commands returns Nornir results object with individual tasks
names set equal to commands sent to device.
- nornir_salt.plugins.tasks.napalm_send_commands.napalm_send_commands(task: nornir.core.task.Task, commands=None, interval=None, new_line_char: str = '_br_')
Nornir Task function to send show commands to devices using
commandscan be provided using host’s object
__task__key with value set to dictionary with
commandskey containing a list of or a multiline string of commands to send to device, e.g.:
print(host.data["__task__"]["commands"]) ["ping 126.96.36.199 source 188.8.131.52", "show clock"]
filenamekey with commands string to send to device.
commands – (list or str) list or multiline string of commands to send to device
interval – (int) interval between sending commands, default None
new_line_char – (str) characters to replace in commands with new line
\nbefore sending command to device, default is
_br_, useful to simulate enter key
- Return result
Nornir result object with task results named after commands