Why to use a REST API

Python and the REST API to the ArubaOS-CX database provide powerful tools to support network automation. For example, Aruba Network Analytics Engine (NAE) scripts are written in Python and use the REST API and resource URIs to identify and monitor switch resources. The NAE provides a built-in Python interpreter.

Python is the go-to language for network engineers:

  • Python is high-level and human-readable.

  • Python is popular with an active development community.

  • There are many libraries (code written for you that you can use in your programs) available.

By using Python and the REST API, you can move far beyond CLI scripting in network automation. As an application programming interface, the REST API is optimized for machine-to-machine interactions. In contrast, a CLI is optimized for human-to-machine interactions.

In the past, a network engineer might have used Perl scripts to automate show and configure CLI commands. This scheme provided some automation, but it was inefficient because it still used the CLI to interact with the switch. CLI inputs and outputs are in an unstructured, human-readable format. You must use text processing based on specific CLI output to extract the information you want.

For example, you would have to write code to detect a MAC address in the large continuous string of text that is the CLI output. The CLI output might have many things to make it human-readable, such as table formatting, column headings, and introductory text. The way MAC addresses are presented can vary by CLI, operating system version, and sometimes even by individual command output. In addition, minor changes in CLI output from software release to software release might require you to change multiple existing scripts.

In contrast, by using programmatic interfaces such as the ArubaOS-CX REST API:

  • You can get the information you are looking for in a predictable and structured way. For example, you can ask for and get just the MAC address.

  • Error conditions are presented in a predictable and structured way. For example, if you execute an API to set the hostname to a new value, the results of the API call provides your program or script with a verification that it successfully executed the request. The success or failure of the operation is signaled to your program through response messages and status codes from the API call. Your program can use these result codes to trigger the execution of other business logic.

  • Changes to APIs from software release to software tend to be specific, controlled, and identified using API version information. In contrast, changes in formatting and layout of CLI output can be more frequent and difficult to detect.

For more information about Python, see: www.python.org

For more information about the Aruba Network Analytics Engine (NAE) and obtaining examples of NAE scripts written in Python, see the ArubaOS-CX Network Analytics Engine Guide for your software release.