Home > Articles

  • Print
  • + Share This
This chapter is from the book

The Programming Language

Good scripts are based on good application programming interfaces (APIs). An API is a set of functions and procedures that allow the creation of applications that access the features or data of an operating system, application, or other service. Fundamentally, an API should provide the following features:

  • Abstraction: The programmable API should abstract away the complexities of the underlying implementation. The network programmer should not need to know unnecessary details, such as a specific order of configurations or specific steps to take if something fails. Configurations should function more like filling in a high-level checklist (these are the settings you need; now the system can go figure out how to properly group and order them).

  • Data specification: The key thing an API does—whether it is a software or network API—is provide a specification for the data. First, it answers the question of what the data is—integer, string, or other type of value. Next, it specifies how that data is organized. In traditional programming, that would be called the data structure—though in the world of network programmability, the more common term is “schema,” also known as “data models.”

  • Means of accessing the data: Finally, the API provides a standardized framework for how to read and manipulate the device’s data.

You saw a YANG Development Kit (YDK)25 example earlier (refer to Example 2-1). The main goal of YDK is to reduce the learning curve of YANG data models by expressing the model semantics in an API and abstracting protocol/encoding details. YDK is composed of a core package that defines services and providers, plus one or more module bundles26 that are based on YANG models. Each module bundle is generated using a bundle profile and the ydk-gen tool. YDK-Py27 provides Python APIs for several model bundles. Similarly, YDK-Cpp28 includes C++ and Go APIs for the same bundles. A similar bundle exists for the C language.

Taking some more examples from the OpenConfig world this time, here are some more tools currently available:

  • Ygot29 (YANG Go Tools): For generating Go structures or protobufs from YANG modules.

  • Goyang:30 A YANG parser and compiler in the Go language.

  • Pyangbind:31 A plug-in for pyang that converts YANG data models into a Python class hierarchy.

These examples prove one more time the importance of the toolchain, of which the programming language (C, C++, Python, Go, you name it) is just one component. Assuming that the operations engineers were developing and supporting scripts based on a specific language, it makes perfect sense to continue developing the YANG-based automation scripts in the same programming language.

  • + Share This
  • 🔖 Save To Your Account