Labs / The Architect / Automation: REST APIs, Ansible & SDN

Lab 1 of 3 · Automation: REST APIs, Ansible & SDN

A REST API that changes the network

Change the network through a controller's REST API with curl and JSON.

Open this lab Pro 7 steps

The idea

Programs change the network through a REST API: JSON sent over HTTP to URLs. Here the laptop uses curl to ask the controller, which logs in to the routers edgeRouter and branchRouter over SSH, for the route that lets it reach webServer.

Northbound and southbound
Northbound and southbound
PATCH merges, PUT replaces
PATCH merges, PUT replaces

Steps

  1. No way to the servers yet

    The laptop sends to its gateway, edgeRouter, which knows only its own two networks. Nothing will be typed on the routers in this lab: the fix comes through the API, so you see one request change the network.

    laptop:~# ping -c 2 -W 1 10.0.2.10
  2. 401 first, then a password in every request

    An API that changes routers must know who is asking. Ask it for its devices, a GET (the method that reads) to /api/devices, first without saying who you are, then with a user name and password.

    laptop:~# curl -si http://10.0.1.10:8080/api/devices
    laptop:~# curl -sv -u admin:netlab http://10.0.1.10:8080/api/devices

Pro

5 more steps in the app

  1. Read the JSON with jq
  2. A token or an API key instead of the password
  3. POST a route, and the network changes
  4. PATCH changes a field, PUT replaces the whole
  5. DELETE: 204, and the path is gone
Get Pro

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Open this lab