Introduction _ Network Programmability and Automation Fundamentals
Introduction _ Network Programmability and Automation Fundamentals
For more than three decades, network management has been entirely
based on the command-line interface (CLI) and legacy protocols such as
SNMP. These protocols and methods are severely limited. The CLI, for ex-
ample, is vendor specific, lacks a unified data hierarchy (sometimes even
for platforms from the same vendor), and was designed primarily as a
human interface. SNMP suffers major scaling problems, is not fit for writ-
ing configuration to devices, and overall, is very complex to implement
and customize.
This book covers all the major programmable interfaces used in the mar-
ket today for network management. The book discusses the protocols,
tools, techniques, and technologies on which network programmability is
based. Programming, operating systems, and APIs are not new technolo-
gies. However, programmable interfaces on network platforms, and using
these programmable interfaces to fully operate and maintain a network,
along with the culture accompanying these new methods and protocols,
may be (relatively) new. This book explains, in detail, all the major com-
ponents of this new ecosystem.
The last chapter provides a way forward, discussing tools and technolo-
gies that you might want to explore after you are done with this book.
This book is meant for the following individuals and roles, among others:
This book covers the information you need to transition from having a fo-
cus on networking technology to focusing on software and network pro-
grammability. This book covers six main focus areas:
Each chapter in this book either explicitly covers one of these focus areas
or prepares you for one of them. Special consideration has been given to
the ordering of topics to minimize forward referencing. Following an in-
troduction to the programmability landscape, Linux is covered first be-
cause to get anything done in network programmability, you will almost
always find yourself working with Linux. The book next covers Python
because the vast majority of the rest of the book includes coverage of
Python in the context of working with various protocols. The following
chapters present an organic flow of topics: transport, encoding, modeling,
and the protocols that build on all the previous sections. For example, un-
derstanding NETCONF requires you to understand SSH, XML, and YANG,
and understanding RESTCONF requires that you understand HTTP,
XML/JSON, and YANG. Both NETCONF and RESTCONF require knowledge
of Python, most likely running on a Linux machine.
The book is organized into nine parts, described in the following sections.
PART I, “Introduction”
Chapter 7, “HTTP and REST”: This is one of the most important chapters
in this book. It introduces the HTTP protocol and the REST architectural
framework, as well as the relationship between them. This chapter covers
HTTP connections based on TCP. It also covers the anatomy of HTTP mes-
sages and dives into the details of HTTP request methods and response
status codes. It also provides a comprehensive explanation of the most
common header fields. The chapter discusses the syntax rules that govern
the use of URIs and then walks through working with HTTP, using tools
such as Postman, cURL, and Python libraries, such as the requests
library.
PART V, “Encoding”
Chapter 10, “XML”: This chapter covers XML, the first of three encoding
protocols covered in this book. XML is the oldest of the three protocols
and is probably the most sophisticated. This chapter describes the general
structure of an XML document as well as XML elements, attributes, com-
ments, and namespaces. It also covers advanced XML topics such as creat-
ing document templates using DTD and XML-based schemas using XSD,
and it compares the two. This chapter also covers XPath, XSLT, and work-
ing with XML using Python.
Chapter 11, “JSON”: JSON is less sophisticated, newer, and more human-
readable than XML, and it is therefore a little more popular that XML.
This chapter covers JSON data formats and data types, as well as the gen-
eral format of a JSON-encoded document. The chapter also covers JSON
Schema Definition (JSD) for data validation and how JSD coexists with
YANG.
Chapter 12, “YAML”: YAML is frequently described as a superset of JSON.
YAML is slightly more human-readable than JSON, but data encoded in
YAML tends to be significantly lengthier than its JSON-encoded counter-
part. YAML is a very popular encoding format and is required for effec-
tive use of tools such as Ansible. This chapter covers the differences be-
tween XML, JSON, and YAML and discusses the structure of a YAML docu-
ment. It also explains collections, scalers, tags, and anchors. Finally, the
chapter discusses working with YAML in Python.
Chapter 13, “YANG”: At the heart of the new paradigm of network pro-
grammability is data modeling. This is a very important chapter that cov-
ers both generic modeling and the YANG modeling language. This chapter
starts with a data modeling primer, explaining what a data model is and
why it is important to have data models. Then it explains the structure of
a data model. This chapter describes the different node types in YANG
and their place in a data model hierarchy. It also delves into more ad-
vanced topics, such as augmentations and deviations in YANG. It de-
scribes the difference between open-standard and vendor-specific YANG
models and where to get each type. Finally, the chapter covers a number
of tools for working with YANG modules, including pyang and pyang-
bind.
Chapter 14, “NETCONF and RESTCONF”: NETCONF was the first proto-
col developed to replace SNMP. RESTCONF was developed later and is
commonly referred to as the RESTful version of NETCONF. Building on
earlier chapters, this chapter takes a deep dive into both NETCONF and
RESTCONF. The chapter covers the protocol architecture as well as the
transport, message, operations, and content layers of each of the two pro-
tocols. It also covers working with these protocols using Python.
Chapter 15, “gRPC, Protobuf, and gNMI”: The gRPC protocol was ini-
tially developed by Google for network programmability that borrows its
operational concepts from the communications models of distributed ap-
plications. This chapter provides an overview of the motivation that
drove the development of gRPC. It covers the communication flow of
gRPC and protocol buffers (Protobuf) used to serialize data for gRPC com-
munications. The chapter also shows how to work with gRPC using
Python. The chapter then takes a deep dive into gNMI, a gRPC-based spec-
ification. Finally, the chapter shows how gRPC and gNMI are used to man-
age a Cisco IOS XE device.
Chapter 19, “Ansible”: This chapter covers a very popular tool that has
become synonymous with network automation: Ansible. As a matter of
fact, Ansible is used in the application and compute automation domains
as well. Ansible is a very simple, yet extremely powerful, automation tool
that provides a not-so-steep learning curve, and hence a quick and effec-
tive entry point into network automation. This is quite a lengthy chapter
that takes you from zero to hero in Ansible.
PART IX, “Looking Ahead”