Practical Network Programming in Python (PNPP)


This 5-day course balances lecture and lab exercises to ensure students can apply key Python programming knowledge and skills required to address network automation challenges in a multi-vendor infrastructure.

This course is designed for network architects and network engineers that have experience designing, building and maintaining enterprise and/or service provider networks. It is expected that student has a strong network engineering background but may have limited programming or scripting experience.

Ideally, students should be experienced Route/Switch or Data Center professionals that are working with these technologies daily. Recommended prerequisite certifications or equivalent knowledge and skills include Cisco CCNP or Juniper JNCIP level professionals. Our course developer’s most important quote, ’You can’t automate what you don’t understand’. 

  • Explain what Python is and why it is the language of choice for network automation
  • Describe how a Python script executes
  • Explain data types, application flow control, and libraries
  • Use an Integrated Development Environment (IDE) to develop, debug and run scripts
  • Use different techniques to capture and use network device output from a variety of equipment
  • Apply configuration via multiple libraries
  • Validate that executed scripts achieve the desired network functionality
  • Demonstrate a programmatic way of planning and implementing a new network service
  • Build custom libraries for frequently used functions
  • Apply learned skills to data center services including routing, switching, security and more
  • Implement techniques for managing code and applying version control
  • Apply Continuous Improvement Continuous Development (CICD) for network engineers
  • Prepares engineers for hybrid cloud deployments

Module 1 – Intro to Python

Lesson 1

Introduction to Python:

In this lesson students will review programming basics, learn the fundamentals of Python and examine its code structure and program flows. They will also learn how libraries are used to communicate with networking equipment.

Lesson Objectives:

After completing this lesson, the student will be able to: 

  • Demonstrate basic programming knowledge
  • Use the PyCharm IDE to create, edit, execute and debug and manage Python applications
  • Describe Python code flow and execution
  • List various network programming libraries and describe how to use them to communicate with various network devices through a Python application
  • Examine network device configuration from a Python perspective

Day 1:

  • Introduction to Python and Programming Languages
    • Interpreted vs Compiled Languages
    • How a script executes
  • IDE – Intro to PyCharm Community Edition
    • Creating a project
    • Editing code, code completion
    • Running a program
    • Breakpoints and debugging
    • Version control – Gitlab
  • Data-types in Python
    • Numerics, Strings, Lists, Tuples, Dictionaries
  • Flow control
    • For loops
    • If/then/elif
    • While loops
  • Network Programming Library Overview
    • Sshpass, pexpect and calling command line tools from python
    • Netmmiko
    • Yang Explained
    • Netconf, ncclient
    • Restconf

Lesson 2

Exploring Network Device Data Formats:

This lesson focuses on communicating with network devices and the various formats of data produced through interactions with those pieces of networking equipment. Through this exploration students will become comfortable with working with network programming libraries.

Lesson Objectives:

After completing this lesson, the student will be able to:

  • Issue commands and Inspect/manipulate varied network device output using Python libraries
  • Describe the type of output provided by different network programming libraries
  • Use the IDE to examine capabilities and limitations of various network programming libraries
  • Use the IDE debugger to step through Python code to discover how to communicate with a device programmatically

Day 2

  • Modeling Network Configuration CLI in python
    • Templates in Jinja2/Yaml
  • Configuration Management
  • Auditing and State Validation
    • JSON vs XML vs raw CLI
  • ‘Show command’ parsing
    • Python string operations
    • TextFSM
    • Genie parser
    • Json-pretty filter
  • Device Capabilities:
    • Cisco: IOS, XE, XR, NXOS (all different approaches)
      • YDK, Yang Explorer
      • pyATS
    • Juniper JUNOS:
      • Unified library: pyez
    • Arista EOS:
      • Unified library: pyeapi
  • Device Real-time Interaction and debugging
    • Netmiko programming
    • Nexus NX-API
    • IOS-XE Rest API

Module 2 – Network Operations Automation

Lesson 1

Network Device Orchestration

In this lesson students will leverage their strong understanding of the network from an architectural view and how to use a services-model approach to plan, automate and validate network functionality. Students will learn how to think like a programmer when addressing network configuration challenges; this insight will also help improve communications in environments where their developers and network engineers exist in separate teams.

Lesson Objectives:

After completing this lesson, the student will be able to:

  • Approach network configuration from a programmer’s perspective
  • Use a service-chaining approach to building applications
  • Validate and audit operational state and configurations ensuring performance as expected

Day 3

  • Intro to device orchestration
  • Environment and command line variables and Python
    • Code re-use/abstraction
  • Working with a Datacenter Design
    • Service chain definition – enabling a new application launch in the datacenter
      • Vlan management automation
        • Layer 2 validation
      • Interface management automation
        • Layer 3 validation
      • BGP/OSPF/Routing configuration automation
        • Routing and Protocol validation
      • Security Automation
        • ACL Validation
        • CDP/LLDP Validation

Lesson 2

Configuration, Validation and Auditing:

In this lesson students will create/modify live device configurations. Topics covered include non-destructive configuration modifications, configuration management, sequential vs. parallel execution and other best practices. Students will apply what they learned in the previous model to validate and audit their automated network configuration changes.

Lesson Objectives:

After completing this lesson, the student will be able to:

  • Build and modify device configurations
  • Validate and audit applied configurations and changes
  • Plan for practical deployments and assess dependencies and scaling requirements
  • Turn large configuration files into a database structure for querying

Day 4

  • Multi Device and Dependency Management – Sequencing
  • Full configuration management
    • Jinja2 / YAML config creation
    • Artifact storage
      • Configlets (Jinja)
      • Devce state templates (Genie, TextFSM)
    • CMDB – Device Inventory
    • Data based python scripting
      • SQLite

Lesson 3

Network Automation Ecosystems:

In this lesson students will explore the principles of Continuous Integration/Continuous Development (CICD) for the purposes of version control and pipeline execution. Additionally, students will learn to use the RobotFramework to drive their custom automation solutions and to call 3rd party Python libraries, import their own custom libraries, and leverage its powerful validation, auditing and reporting functionality.

Lesson Objectives:

After completing this lesson, the student will be able to:

  • Customize their automation toolset to address their specific device mix and functional needs
  • Use RobotFramework to call Python libraries and audit network functionality
  • Discuss how they can apply the solutions developed in this course to automation frameworks beyond RobotFramework such as Ansible.

Day 5

  • Gitlab – CICD Introduction
    • Version Control
    • Pipeline execution

  • RobotFramework
    • Why Robot – a look at the automation ecosystems available
      • Ansible, Puppet, Chef, Salt
    • Robot scripts and keywords
    • Calling 3rd party and custom python libraries from Robot scripts
    • Combining:
      • Configuration Management
      • Health Checks
      • Auditing and Reporting
SLI Main Menu