netmiko_send_commands

This task plugin uses nornir-netmiko netmiko_send_command task to send multiple commands to devices.

Dependencies:

netmiko_send_commands sample usage

Code to invoke netmiko_send_commands task:

from nornir_salt import netmiko_send_commands

output = nr.run(
    task=netmiko_send_commands,
    commands=["show run", "show clock"]
)

netmiko_send_commands returns

Returns Nornir results object with individual tasks names set equal to commands sent to device.

netmiko_send_commands reference

nornir_salt.plugins.tasks.netmiko_send_commands.netmiko_send_commands(task: nornir.core.task.Task, commands=[], interval=0.01, use_ps: bool = False, split_lines: bool = True, **kwargs)

Nornir Task function to send show commands to devices using nornir_netmiko.tasks.netmiko_send_command plugin

Per-host commands can be provided using host’s object data attribute with __task__ key with value set to dictionary with commands key containing a list of or a multiline string of commands to send to device, e.g.:

print(host.data["__task__"]["commands"])

["ping 1.1.1.1 source 1.1.1.2", "show clock"]

Alternatively, __task__ can contain filename key with commands string to send to device.

Parameters
  • kwargs – (dict) any additional arguments to pass to netmiko_send_command nornir-netmiko task

  • commands – (list or str) list or multiline string of commands to send to device

  • interval – (int) interval between sending commands, default 0.01s

  • use_ps – (bool) set to True to switch to experimental send_command_ps method

  • split_lines – (bool) if True (default) - split multiline string to commands, if False, send multiline string to device as is; honored only when use_ps is True, split_lines ignored if use_ps is False

Return result

Nornir result object with task results named after commands