This is a personal project to learn python but also try to do something with python in terms of my job with network configuration and troubleshooting. I'm trying to write functions to return data from mainly Cisco devices but would like to try other devices in the future (it's just I currently work with Cisco the majority of the time)
I try to provide examples with my functions and will even try to provide real world examples when I've used them, some might be totally useless but others may be of help for other network engineers. I'm no expert at python, although I hope this project helps other people with looking into what you can do with python and network configuration etc..
- Create a directory, change directory and run:
git clone https://github.com/BSpendlove/BCPTools
- Change directory into 'BCPTools' and run:
pip3 install -r requirements.txt
and then finally:
pip3 install .
The majority of functions returns some data in json type format. I've used a function from the NAPALM library (https://github.com/napalm-automation/napalm) instead of using the inbuilt textfsm with Netmiko because I felt like it was limiting what I wanted to do. This is so I could use textfsm templates to structure the data from various 'show' commands on the devices. I would highly recommend using textfsm when working with large amounts of unstructured data like majority of 'show' commands on any vendors equipment.
session - This is normally the SSH session you can pass into the function (I normally use the bcp_create_session to pass into my other functions)
I also need to possibly arrange the below functions in alphabetical order... Not important right now since I keep adding to the list
-Establishes SSH connection into global configuration mode using netmiko, you just need to pass the normal netmiko variables such as:
device_type, ip, username, password, secret | etc....
-Creates directory 'backups' if it doesn't exist and then creates a backup, RemovePasswords is False by default but if True: it will remove any enable/username passwords, snmp communities, ospf authentication, tacacs+/radius secrets and key-string in a 'key chain'
-Returns JSON format of the following:
capabilities, destination_host, local_port, management_ip, platform, remote_port, software_version
-Returns JSON format of the following:
address, age interface, mac, type
-Returns JSON format of the following:
destination_address, destination_port, type, vlan
-Not really useful, it's the same command as send_command() in netmiko but returns the output
-Returns JSON format of the following:
config_register, hardware, hostname, reload_reason, rommon, running_image, serial, uptime, version, descr, name, pid, sn, vid
-Returns JSON format of the following:
interface, ipaddress, protocol, status
-Returns JSON format of the following:
address, bandwidth, bia, delay, description, duplex, encapsulation, hardware_type, input_rate, interface, ip_address, link_status, mtu, output_rate, protocol_status, queue_strategy, speed
-Returns JSON format of the following:
interfaces, name, status, vlan_id
-Runs a include filter on the IOS command itself, a regex to filter out interfaces that haven't seen traffic in (or out) for more than 19 weeks...