Network Programmability and Automation, 2nd Edition

Book description

Network engineers are finding it harder than ever to rely solely on manual processes to get their jobs done. New protocols, technologies, delivery models, and the need for businesses to become more agile and flexible have made network automation essential. The updated second edition of this practical guide shows network engineers how to use a range of technologies and tools, including Linux, Python, APIs, and Git, to automate systems through code. This edition also includes brand new topics such as network development environments, cloud, programming with Go, and a reference network automation architecture.

Network Programmability and Automation will help you automate tasks involved in configuring, managing, and operating network equipment, topologies, services, and connectivity. Through the course of the book, you'll learn the basic skills and tools you need to make this critical transition.

You'll learn:

  • Programming skills with Python and Go: data types, conditionals, loops, functions, and more
  • New Linux-based networking technologies and cloud native environments, and how to use them to bootstrap development environments for your network projects
  • Data formats and models: JSON, XML, YAML, Protobuf, and YANG
  • Jinja templating for creating network device configurations
  • A holistic approach to architecting network automation services
  • The role of application programming interfaces (APIs) in network automation
  • Source control with Git to manage code changes during the automation process
  • Cloud-native technologies like Docker and Kubernetes
  • How to automate network devices and services using Ansible, Nornir, and Terraform
  • Tools and technologies for developing and continuously integrating network automation

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. What This Book Covers
      1. What’s New in This Edition
    2. How This Book Is Organized
    3. Who Should Read This Book
      1. Network Engineers
      2. Systems Administrators
      3. Software Developers
    4. Tools Used in This Book
    5. Online Resources
    6. Conventions Used in This Book
    7. Using Code Examples
    8. O’Reilly Online Learning
    9. How to Contact Us
    10. Acknowledgments
  2. 1. Network Industry Trends
    1. The Rise of Software-Defined Networking
      1. The Advent of OpenFlow
      2. Why OpenFlow?
    2. What Is Software-Defined Networking?
      1. Opening Up the Data Plane
      2. Network Functions Virtualization
      3. Virtual Switching
      4. Network Virtualization
      5. Device APIs
      6. Network Automation
      7. Bare-Metal Switching
      8. Data Center Network Fabrics
      9. SD-WAN
      10. Controller Networking
      11. Cloud Native Networking
    3. Summary
  3. 2. Network Automation
    1. Why Network Automation?
      1. Simplified Architectures
      2. Deterministic Outcomes
      3. Business Agility
      4. Enhanced Security and Risk Reduction
    2. Types of Network Automation
      1. Device Provisioning
      2. Data Collection and Enrichment
      3. Migrations
      4. Configuration Management
      5. Configuration Compliance
      6. State Validation
      7. Reporting
      8. Troubleshooting
    3. Evolving the Management Plane from SNMP to APIs
      1. Application Programming Interfaces
      2. Impact of Open Networking
    4. Network Automation in the SDN Era
    5. Summary
  4. 3. Linux
    1. Examining Linux in a Network Automation Context
    2. Exploring a Brief History of Linux
    3. Understanding Linux Distributions
      1. Red Hat Enterprise Linux, Fedora, CentOS, and Amazon Linux
      2. Debian, Ubuntu, and Other Derivatives
      3. Other Linux Distributions
    4. Interacting with Linux
      1. Navigating the Filesystem
      2. Manipulating Files and Directories
      3. Running Programs
      4. Working with Daemons
    5. Networking in Linux
      1. Working with Interfaces
      2. Routing as an End Host
      3. Routing as a Router
      4. Bridging (Switching)
    6. Automating Linux with bash Scripting
    7. Evolving the Linux Kernel with eBPF and XDP
    8. Summary
  5. 4. Cloud
    1. Brief Definition of Cloud Computing
    2. Networking Fundamentals in the Cloud
      1. Cloud Networking Building Blocks
      2. Cloud Network Topologies
      3. Network Automation in the Cloud
    3. Containers
      1. What Do Containers Have to Do with the Cloud?
      2. What Do Containers Have to Do with Networking?
      3. Extending Linux Networking for Containers
    4. Kubernetes
      1. Key Kubernetes Concepts
      2. Building Blocks of Networking in Kubernetes
      3. Service Mesh
    5. Summary
  6. 5. Network Developer Environments
    1. Text Editors
      1. Syntax Highlighting
      2. Customization
      3. Intelligent Code Analysis
      4. Text Editors Versus Integrated Development Environments
    2. Development Tools
      1. Virtualenv
      2. Make
      3. Docker
      4. dyff
    3. Emulation/Simulation Tools
      1. VirtualBox
      2. Vagrant
      3. Containerlab
      4. Other Tools
    4. Summary
  7. 6. Python
    1. Should Network Engineers Learn to Code?
    2. Using the Python Interactive Interpreter
    3. Understanding Python Data Types
      1. Strings
      2. Numbers
      3. Booleans
      4. Lists
      5. Python Dictionaries
      6. Sets and Tuples
    4. Adding Conditional Logic to Your Code
    5. Understanding Containment
    6. Using Loops in Python
      1. The while Loop
      2. The for Loop
    7. Using Python Functions
    8. Working with Files
      1. Reading from a File
      2. Writing to a File
    9. Creating Python Programs
      1. Creating a Basic Python Script
      2. Using Comments in Python
      3. Migrating Code from the Python Interpreter to a Python Script
    10. Working with Python Modules
      1. Documenting Functions
    11. Passing Arguments into a Python Script
    12. Using pip and Installing Python Packages
      1. Isolating Your Dependencies with Virtualenv
    13. Understanding Python Classes
      1. Using Classes
      2. Building Your Own Classes
    14. Embracing Failure with try/except
    15. Parallelizing Your Python Programs
    16. Summary
  8. 7. Go
    1. Why Go?
      1. Is Go Faster Than Python?
      2. Is Go Harder than Python?
    2. Fundamental Go Concepts
      1. Types and Variables
      2. Flow Control
      3. Collection Types
      4. Functions
      5. Structs
      6. Methods
      7. Interfaces
    3. Advanced Concepts
      1. Concurrency
      2. Generics
    4. Packages and Modules
      1. Standard Library Packages
      2. Third-Party Modules and Packages
    5. Summary
  9. 8. Data Formats and Models
    1. Benefits and Fundamentals of Structured Data Formats
      1. When Structured Data Isn’t Available: Screen Scraping
      2. Types of Data
      3. Documents Versus Data
      4. Categories of Data Formats
    2. Text-Based Data Formats
      1. YAML
      2. XML
      3. JSON
    3. Binary Data Formats
      1. Protocol Buffers
      2. Other Binary Data Formats
    4. Data Modeling
      1. YANG
      2. JSON Schema
      3. XML Schema Definition
      4. Modeling and Validating Protocol Buffers
    5. Summary
  10. 9. Templates
    1. The Rise of Modern Template Languages
      1. Using Templates for Web Development
      2. Expanding On the Use of Templates
    2. The Value of Templates in Network Automation
    3. Jinja
      1. Rendering a Jinja Template File in Python
      2. Using Conditionals and Loops
      3. Using Jinja Filters
      4. Template Inheritance in Jinja
      5. Variable Creation in Jinja
    4. Extensible Stylesheet Language Transformations
    5. Go Templates
    6. Summary
  11. 10. Working with Network APIs
    1. Understanding Network APIs
      1. Getting Familiar with HTTP-Based APIs
      2. Using NETCONF
      3. Using RESTCONF
      4. Using gRPC and gNMI
      5. Comparing NETCONF, RESTCONF, and gNMI
    2. Using Network APIs for Automation
      1. The Python Requests Library
      2. The Go net/http Package
      3. The Python ncclient Library
      4. The OpenConfig gNMIc Go Package
      5. The Netmiko Python Library
    3. Summary
  12. 11. Source Control with Git
    1. Use Cases for Source Control
    2. Benefits of Source Control
      1. Change Tracking
      2. Accountability
      3. Process and Workflow
    3. Benefits of Source Control for Networking
    4. Enter Git
      1. Brief History of Git
      2. Git Terminology
      3. Overview of Git’s Architecture
    5. Working with Git
      1. Installing Git
      2. Creating a Repository
      3. Adding Files to a Repository
      4. Committing Changes to a Repository
      5. Changing and Committing Tracked Files
      6. Unstaging Files
      7. Excluding Files from a Repository
      8. Viewing More Information About a Repository
      9. Distilling Differences Between Versions of Files
      10. Tagging Commits in Git
    6. Branching in Git
      1. Renaming the Default Branch
      2. Creating a Branch
      3. Checking Out a Branch
      4. Stashing Uncommitted Changes
      5. Merging and Deleting Branches
    7. Collaborating with Git
      1. Collaborating Between Multiple Systems Running Git
      2. Collaborating via Git-Based Online Services
    8. Summary
  13. 12. Automation Tools
    1. Reviewing Automation Tools
    2. Using Ansible
      1. Discovering the Ansible Framework
      2. Understanding How Ansible Works
      3. Constructing an Inventory File
      4. Executing an Ansible Playbook
      5. Using Secrets
      6. Using Variable Files
      7. Writing Ansible Playbooks for Network Automation
      8. Using Third-Party Collections and Modules
      9. Ansible Summary
    3. Automating with Nornir
      1. Getting Started with Nornir
      2. Using NAPALM with Nornir
      3. Nornir Summary
    4. Managing Dynamic Infrastructure with Terraform
      1. Understanding Terraform Architecture
      2. Provisioning Your First Resource with Terraform
      3. Extending Terraform Execution
      4. Managing Terraform at Scale
      5. Terraform Out of Its Comfort Zone
      6. Terraform Summary
    5. Summary
  14. 13. Continuous Integration
    1. Important Prerequisites
      1. Simple Is Better
      2. People, Process, and Technology
      3. Learn to Code
    2. Introduction to Continuous Integration
      1. Basics of Continuous Integration
      2. Continuous Delivery
      3. Test-Driven Development
      4. Why Continuous Integration for Networking?
    3. A Continuous Integration Pipeline for Networking
      1. Peer Review
      2. Build Automation
      3. Deployment Validation and Testing
      4. Test/Dev/Staging Environment
      5. Deployment Tools and Strategies
    4. Summary
  15. 14. Network Automation Architecture
    1. Introducing the Network Automation Architecture
    2. Overview of the Architecture Components
      1. User Interactions
      2. Source of Truth
      3. Automation Engine
      4. Telemetry and Observability
      5. Orchestration
    3. Understanding the Architecture with an Example
      1. Determine the Operation’s Workflow
      2. Translate the Workflow Steps to Automated Tasks
      3. Map the Automated Tasks to Architecture Components
      4. Choose the Tools to Implement Each Component’s Tasks
    4. Summary
  16. Index
  17. About the Authors

Product information

  • Title: Network Programmability and Automation, 2nd Edition
  • Author(s): Matt Oswalt, Christian Adell, Scott S. Lowe, Jason Edelman
  • Release date: August 2023
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781098110833