Interacting with network devices via HTTP
Over the last decade, networking vendors have begun to include application programming interfaces (APIs) to manage their devices as a supplement to the CLI. It’s not uncommon to find network devices with a robust RESTful API that gives you read and write access to it.
A RESTful API is a stateless client-server communication architecture that runs over HTTP. The request and responses generally transport structured data (JSON, XML, and so on), but they might as well carry plain text. This makes the RESTful API a better-suited interface for machine-to-machine interactions.
Using Go’s HTTP package to access network devices
The remaining device to configure is NVIDIA’s Cumulus Linux (cvx
). We will use its OpenAPI-based RESTful API to configure it. We will encode the configuration in a JSON message and send it over an HTTP connection with Go’s net/http
package.
As in the SSH examples, we normally load the input...