scrapli_send_commands

This test plugin uses nornir-scrapli send_command task to send multiple commands to devices.

Dependencies:

scrapli_send_commands sample usage

Code to invoke scrapli_send_commands task:

from nornir import InitNornir
from nornir_salt import scrapli_send_commands

nr = InitNornir(config_file="config.yaml")

output = nr.run(
    task=scrapli_send_commands,
    commands=["show run", "show clock"],
    scrapli_kwargs={}
)

scrapli_send_commands returns

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

scrapli_send_commands reference

nornir_salt.plugins.tasks.scrapli_send_commands.scrapli_send_commands(task: nornir.core.task.Task, commands=[], interval=0.01, **kwargs)

Nornir Task function to send show commands to devices using nornir_scrapli.tasks.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"]
Parameters
  • commands – (list or str) list or multiline string of commands to send to device

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

  • kwargs – (dict) any additional arguments to pass to scrapli send_command

Return result

Nornir result object with task execution results