Python Automation for Network Engineers

Manage your network devices with Python

Many network engineers still configure their devices (e.g. Cisco routers, switches, etc.) by hand. These days there are better ways: using RESTCONF we can automate our ports and interfaces using Python. This course teaches how to do this with in a 4-day, hands-on approach.
4 days
ansible python
Network engineers that want to learn how to automate their workflow
Write simple scripts to automate network setup
Classroom/virtual, blended
Need this for your dev team?

Outline

About labs/exercises

There are exercises available for all topics covered. Participants typically work on their own computers, but if necessary Code Sensei offers an online environment (Jupyter Lab).

Day 1

  • Variables, Types, Operators
  • Input, Output, Type Conversions
  • Booleans and Conditional Execution (if)
  • While loops
  • Using the builtin ipaddress module
  • Reading and writing text files
  • Searching for text in a file
  • Filtering text files
  • Practical application: reading and writing configuration files

Day 2

  • Functions
  • Lists
  • For Loops
  • Import
  • Projects and dependencies: Virtualenv, pip
  • Correctly handling credentials with .env
  • Practical application: Reading and writing CSV files (e.g. interfaces to configure)
  • Practical application: Using netmiko/paramiko to run commands on network equipment

Day 3

  • Dicts
  • Tuples
  • Exceptions
  • Python json support
  • Practical application: Using Jinja to generate files (e.g. configurations)
  • Using Requests to consume REST API’s
  • Practical application: querying network configuration with RESTCONF
  • Practical application: parsing RESTCONF responses with json

Day 4

  • Understanding the YANG network data model
  • Using RESTCONF to automate network management
  • using ncclient to automate network management over NETCONF
  • Application: bulk operations across an inventory of devices
  • Application: automatic config backup

We end with a mini end-to-end project in the afternoon: Jinja template → render config → push via RESTCONF → verify with a GET. everything together.

Optional topics

Depending on your needs, we can cover additional topics, or replace some of the topics mentioned with others. Here are some suggestions:

  • Ansible introduction (infrastructure-as-code)
  • Sending emails
  • Connecting to databases with SqlAlchemy
  • Git introduction
  • Using regular expressions to search and analyze data
Adapt this course to fit your needs