Latest Posts

Complex Data Structure

When dealing with very large output data structure , and need to extract data from it : Example : Devices = { ‘sw1’: { ‘ip_addr’: ‘10.10.10.1’, ‘username’: ‘admin’, ‘password’: ‘cisco’, ‘bgp_peer’: ‘10.10.20.1’, ‘10.10.30.1’, ‘10.10.40.1’}, ‘sw2’: { ‘ip_addr’: ‘10.10.10.2’, ‘username’: ‘admin’,…
Read more

YAML Basics

Example of a YAML file : List : — – 10.10.10.1 – 10.10.10.2 – 10.10.10.3 Dictionary : — Key:value device1: 10.10.10.1 device2: this is a string device3: “this can nclude special characters” device4: True or true or yes or no…
Read more

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