Sources¶
Inputs can uses various sources to retrieve data for parsing.
Source | Description |
---|---|
Netmiko | uses Netmiko library to retrieve data from devices over SSH or Telnet |
Nornir | uses Nornir library with Netmiko plugin to retrieve data from devices |
Netmiko¶
Prerequisites: Netmiko library need to be installed on the system
This source allows to retrieve configuration or state data from network devices using SSH or Telnet by connecting to devices one by one (serial execution).
Supported attributes
commands
list of commands to retrieve from devicesdevices
list of devices to retrieve commands fromusername
device username, if value isget_user_input
prompts user for inputpassword
device password, if value isget_user_pass
prompts user for inputNetmiko kwargs
- any other arguments to pass on to Netmiko ConnectHandler method
Example
Template:
<vars>
hostname="gethostname"
</vars>
<input source="netmiko" name="arp">
devices = ["192.168.217.10", "192.168.217.7"]
device_type = "cisco_ios"
username = "cisco"
password = "cisco"
commands = ["show ip arp"]
</input>
<group name="arp" input="arp">
Internet {{ ip }} {{ age }} {{ mac }} ARPA {{ interface }}
{{ hostname | set(hostname) }}
</group>
<input source="netmiko" name="interfaces">
host = "192.168.217.10"
device_type = "cisco_ios"
username = "get_user_input"
password = "get_user_pass"
commands = ["show run"]
</input>
<group name="interfaces" input="interfaces">
interface {{ interface }}
description {{ description | ORPHRASE }}
encapsulation dot1Q {{ dot1q }}
ip address {{ ip }} {{ mask }}
{{ hostname | set(hostname) }}
</group>
Nornir¶
Prerequisites: Nornir library need to be installed on the system
This source allows to retrieve configuration or state data from network devices using Nornir library. Nornir runs connection to devices asynchronously (in parallel), allowing significantly reduce the time required to retrieve data.
This source uses netmiko_send_command task plugin to send commands to devices.
Supported attributes
hosts
Nornir hosts inventory data with devices’ detailscommands
list of commands to execute on devicesusername
devices username, if value isget_user_input
prompts user for inputpassword
devices password, if value isget_user_pass
prompts user for inputnum_workers
default is 100, maximum number of worker threads to instantiate for tasks executionnetmiko_kwargs
arguments to pass on to netmiko_send_command task plugin, default values:strip_prompt = False strip_command = False
Nornir normally uses inventory data to get username and password values, TTP allows to specify these attributes separately and share them with each host in inventory. Username and password provided within hosts inventory considered to be more specific and not overridden.
Example
Template:
<input source="nornir" name="arp">
hosts = {
"R1": {
"hostname": "192.168.1.151",
"platform": "cisco_ios"
},
"R2": {
"hostname": "192.168.1.153",
"username": "cisco",
"password": "cisco",
"platform": "cisco_ios"
}
}
username = "get_user_input"
password = "get_user_pass"
commands = ["show ip arp"]
netmiko_kwargs = {
"strip_prompt": False,
"strip_command": False
}
</input>
<group name="arp" input="arp">
Internet {{ ip }} {{ age }} {{ mac }} ARPA {{ interface }}
{{ hostname | set(hostname) }}
</group>