Yearly Archive: 2020

Netmiko Delay Factor

Global delay factor Delay factor #ConnectHandler from pprint import pprint from netmiko import Netmiko from getpass import getpass password = getpass() devices = {‘host’: ‘100.96.0.18’, ‘username’: ‘ntc’, ‘password’: ‘ntc123’, ‘device_type’: ‘cisco_xe’, ‘secret’: password, ‘session_log’: ‘my_output.txt’, ‘global_delay_factor’:10} 2 would multiple by .1,…
Read more

Tshoot

Trick to TSHOOT Netmiko Turn on Logging : import logging logging.basicConfig(filename=’log.log’, level=logging.DEBUG) log = logging.getLogger(‘netmiko’)  

TextFSM

pip list pip install txtfsm pip install colorama Install the template for NTC git clone https://github.com/networktocode/ntc-templates export NET_TEXTFSM=/path/to/ntc-templates/templates/ #ConnectHandler from netmiko import Netmiko from getpass import getpass password = ‘cisco’ devices = {‘host’: ‘100.96.0.18’, ‘username’: ‘ntc’, ‘password’: ‘ntc123’, ‘dev> net_conn…
Read more

Show Commands

#ConnectHandler from pprint import pprint from netmiko import Netmiko from getpass import getpass password = getpass() devices = {‘host’: ‘100.96.0.18’, ‘username’: ‘ntc’, ‘password’: ‘ntc123’, ‘device_type’: ‘cisco_xe’, ‘secret’: password} net_conn = Netmiko(**devices) net_conn.enable() output = net_conn.send_command(“show arp”) print(output) with open(“show_arp.txt”, “w”)…
Read more

Basics

Netmiko is a multi-vendor library base on Paramiko Base Config : #ConnectHandler from pprint import pprint from netmiko import Netmiko from getpass import getpass import re net_conn = Netmiko(host=’100.96.0.18′, username=’ntc’, password=getpass(), device_type=’cisco_xe’) if you use an invalid device type it…
Read more

Classes

Function gives you one level of usability and Classes with methods give you a second level of usability. When you passing the same information more then once for the same thing you can then use Classes instead of repetitive same function. In…
Read more

Functions

Creating a function : def function_name(): ….action function_name()  <— calling the function function_name  <— referencing the function def function_ip(ip): ….print(“My ip is:{}”.format(ip)) or print(f’My ip is :{ip}’) ….return function_ip(‘10.1.1.1′) def function_ip(ip, mask, gtw): ….print(“My ip is:{} mask is : {}…
Read more