Network Automation with Go

Book description

Understand the world of modern network automation with Go and deepen your knowledge with insights from 10+ experts who have real-world hands-on experience with network automation and/or are using Go for network-related tasks

Key Features

  • A comprehensive guide to the world of modern network automation
  • Use Go to build anything from repetitive task automation to complex distributed systems
  • Over 30 practical, ready-to-use sample programs

Book Description

Go’s built-in first-class concurrency mechanisms make it an ideal choice for long-lived low-bandwidth I/O operations, which are typical requirements of network automation and network operations applications.

This book provides a quick overview of Go and hands-on examples within it to help you become proficient with Go for network automation. It’s a practical guide that will teach you how to automate common network operations and build systems using Go.

The first part takes you through a general overview, use cases, strengths, and inherent weaknesses of Go to prepare you for a deeper dive into network automation, which is heavily reliant on understanding this programming language. You’ll explore the common network automation areas and challenges, what language features you can use in each of those areas, and the common software tools and packages. To help deepen your understanding, you’ll also work through real-world network automation problems and apply hands-on solutions to them.

By the end of this book, you’ll be well-versed with Go and have a solid grasp on network automation.

What you will learn

  • Understand Go programming language basics via network-related examples
  • Find out what features make Go a powerful alternative for network automation
  • Explore network automation goals, benefits, and common use cases
  • Discover how to interact with network devices using a variety of technologies
  • Integrate Go programs into an automation framework
  • Take advantage of the OpenConfig ecosystem with Go
  • Build distributed and scalable systems for network observability

Who this book is for

This book is for all network engineers, administrators, and other network practitioners looking to understand what network automation is and how the Go programming language can help develop network automation solutions. As the first part of the book offers a comprehensive overview of Go’s main features, this book is suitable for beginners with a solid grasp on programming basics.

Table of contents

  1. Network Automation with Go
  2. Contributors
  3. About the authors
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
    9. Download a free PDF copy of this book
  6. Part 1: The Go Programming Language
  7. Chapter 1: Introduction
    1. Technical requirements
    2. Networking and Go
    3. Why Go?
      1. Non-technical reasons
    4. The future of Go
      1. Technical reasons
      2. Go for networking
    5. Go versus Python
      1. Code execution
      2. Type system
      3. Performance
      4. Ease of use
      5. Memory management
      6. Syntax
      7. Failure handling
      8. Concurrency
      9. Community
    6. Installing Go on your computer
      1. Windows
      2. Mac
      3. Linux
    7. Summary
    8. Further reading
  8. Chapter 2: Go Basics
    1. Technical requirements
    2. What is Go?
    3. Go Proverbs
    4. Go source code files
      1. Packages
      2. Go modules
      3. Importing packages
      4. Comments
      5. Names
      6. Executing your Go code
    5. Running Go programs online
      1. The Go Playground
      2. The Go Play Space
      3. A look into the Future
    6. The Go tool
      1. Build
      2. Run
      3. Mod
      4. Get
      5. Install
      6. Fmt
      7. Test
      8. Env
    7. Summary
    8. Further reading
  9. Chapter 3: Getting Started with Go
    1. Technical requirements
    2. Go’s type system
      1. Basic types
      2. Container types
      3. User-defined types
    3. Arithmetic, comparison, and logical operators
      1. Arithmetic operators
      2. Logical operators
      3. Comparison operators
    4. Control flow
      1. for loops
      2. Conditional statements
      3. goto statements
    5. Functions
      1. Function arguments
      2. Error handling
      3. Methods
      4. Variadic functions
      5. Closures
      6. Defer
    6. Interfaces
      1. Network automation example
      2. Standard library example
      3. Interfaces as contracts
    7. Input and output operations
      1. The io.Reader interface
      2. The io.Writer interface
      3. The io.Copy function
      4. Composition
    8. Decoding and encoding
      1. Decoding
      2. Encoding
    9. Concurrency
      1. Goroutines
      2. Channels
      3. Channels and Timers
      4. Shared data access
      5. Concurrency caveats
    10. Summary
    11. Further reading
  10. Chapter 4: Networking (TCP/IP) with Go
    1. Technical requirements
    2. The link layer
      1. Network interfaces
      2. Ethernet
    3. The internet layer
      1. The net package
      2. The New netip package
      3. Working with IP addresses
      4. Route lookups
    4. The transport layer
      1. UDP ping application
    5. The application layer
      1. Working with an HTTP client
      2. Working with an HTTP (server)
    6. Summary
    7. Further reading
  11. Part 2: Common Tools and Frameworks
  12. Chapter 5: Network Automation
    1. Technical requirements
    2. What is network automation?
      1. Why network automation exists
      2. Bottom-up view
      3. Top-down view
    3. Automating network operation tasks
      1. Configuration management
      2. Network state analysis
      3. Network audits and reporting
    4. Systems approach
      1. Closed-loop automation
      2. Demo application
    5. Summary
    6. Further reading
  13. Chapter 6: Configuration Management
    1. Technical requirements
    2. Environment setup
      1. Creating the topology
    3. Interacting with network devices via SSH
      1. Describing the network device configurations
      2. Using Go’s SSH package to access network devices
      3. Automating routine SSH tasks
    4. Interacting with network devices via HTTP
      1. Using Go’s HTTP package to access network devices
      2. Getting config inputs from other systems via HTTP
    5. State validation
      1. Checking routing information
      2. Validating end-to-end reachability
    6. Summary
    7. Further reading
  14. Chapter 7: Automation Frameworks
    1. Technical requirements
    2. Ansible
      1. Overview of Ansible components
      2. Working with Ansible modules
      3. Developing an Ansible module
      4. Running the playbook
    3. Terraform
      1. Overview of Terraform components
      2. Working with Terraform
      3. Developing a Terraform provider
      4. Networking providers
    4. Other automation frameworks
      1. Gornir
      2. Consul-Terraform-Sync
      3. mgmt
      4. Looking into the future
    5. Summary
    6. Further reading
  15. Part 3: Interacting with APIs
  16. Chapter 8: Network APIs
    1. Technical requirements
    2. API data modeling
    3. OpenAPI
      1. Data modeling
      2. Data input
      3. Device configuration
    4. JSON-RPC
      1. Code generation
      2. Building configuration
      3. Device configuration
    5. RESTCONF
      1. Code generation
      2. Building configuration
      3. Device configuration
    6. State validation
      1. Operational state modeling
      2. Operational state processing
    7. gRPC
      1. Protobuf
      2. gRPC transport
      3. Defining gRPC services
      4. Configuring network devices with gRPC
      5. Streaming telemetry from a network device with gRPC
    8. Summary
    9. Further reading
  17. Chapter 9: OpenConfig
    1. Technical requirements
    2. Device provisioning
      1. Set RPC
      2. Using gNMI to configure network interfaces
    3. Streaming telemetry
      1. Subscribe RPC
      2. Streaming telemetry processing pipelines with gNMI
      3. Event-manager sample program
      4. Visualizing the data
    4. Network operations
      1. Traceroute RPC
      2. Path verifier application
    5. Summary
    6. Further reading
  18. Chapter 10: Network Monitoring
    1. Technical requirements
    2. Data plane telemetry processing
      1. Packet capturing
      2. Packet filtering
      3. Packet processing
      4. Generating traffic
    3. Debugging Go programs
      1. Debugging from an IDE
    4. Data plane telemetry aggregation
      1. Top talkers
      2. Testing Go programs
    5. Measuring control plane performance
    6. Measuring BGP Update propagation time
      1. Event-driven BGP state machine
      2. Encoding and decoding BGP messages
      3. Collecting and exposing metrics
      4. Storing and visualizing metrics
    7. Developing distributed applications
    8. Summary
    9. Further reading
  19. Chapter 11: Expert Insights
    1. David Barroso
    2. Stuart Clark
    3. Claudia de Luna
      1. Network automation truths... so far...
    4. Alexis de Talhouët
    5. John Doak
    6. Roman Dodin
    7. David Gee
      1. My journey toward a decade of Go
      2. Go’s type system
      3. A note on version control
      4. Growing your code
      5. Comments
      6. Being blindsided
    8. Daniel Hertzberg
    9. Marcus Hines
      1. In a nutshell
      2. Reasoning about automation
      3. Background
      4. Ability to impact the industry
    10. Sneha Inguva
    11. Antonio Ojea
    12. Carl Montanari
    13. Brent Salisbury
    14. Maximilian Wilhelm
      1. A little bit of history
      2. Mental shift to holistic automation
      3. This is the way
    15. Matt Oswalt
    16. Further reading
  20. Chapter 12: Appendix : Building a Testing Environment
    1. What is a testing environment?
      1. Step 1 – building a testing environment
      2. Step 2 – uploading container images
      3. Step 3 – iInteracting with the testing environment
    2. Launching a virtual network topology
      1. Connecting to the devices
      2. Destroying the network topology
      3. Step 4 – cleaning up of the cloud-hosted environment
    3. Further reading
  21. Index
    1. Why subscribe?
  22. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: Network Automation with Go
  • Author(s): Nicolas Leiva, Michael Kashin
  • Release date: January 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781800560925