Monthly Archive: July 2020

Jinja2 Basics

The Basic : Example of a configuration in one script : import jinja2 dict_variables = {‘key’:  ‘value’, etc…} template_cfg = ”’ config…{{ .key }} config…{{ .key }} config….{{ .key }} “”” template = jinja2.Template(template_cfg) print(template.render(dict_variables) To access : a key…
Read more

Date Time

This can be useful for tracking delay for mass update or can be use for saving file and many other options : from datetime import datetime start_time = datetime.now() end_time = datetime.now() print(f”Execution Time :{end_time} : {start_time}”) Reference : Python for Network Engineers

Devices Type as 2020 07 30

Simple references to all device type available : a10 accedian alcatel_aos alcatel_sros apresia_aeos arista_eos aruba_os avaya_ers avaya_vsp brocade_fastiron brocade_netiron brocade_nos brocade_vdx brocade_vyos calix_b6 checkpoint_gaia ciena_saos cisco_asa cisco_ios cisco_nxos cisco_s300 cisco_tp cisco_wlc cisco_xe cisco_xr cloudgenix_ion coriant dell_dnos9 dell_force10 dell_isilon dell_os10 dell_os6…
Read more

Fast CLI

Add to the elements “fast_cli”: True, Will change the Global delay Factor. This will perform faster but any process requirement more time to process will become less reliable.   Reference : Python for Network Engineers      

Files Transfer

from netmiko import ConnectHandler, file_transfer source_file = “file.ext” dest_file = “file.ext” direction = “put”   /  “get” file_system = “bootflash:” # Create the Netmiko SSH connection ssh_conn = ConnectHandler(**devices) transfer_dict = file_transfer( ssh_conn, source_file=source_file, dest_file=dest_file, file_system=file_system, direction=direction, overwrite_file=True, ) print(transfer_dict)  …
Read more

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’)