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.plugins.tasks 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_', split_lines: bool = True)
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 220.127.116.11 source 18.104.22.168", "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
split_lines – (bool) if True split multiline string to commands, send multiline string to device as is otherwise
- Return result
Nornir result object with task results named after commands