Skip to content

nextgen-network-academy/arista-eapi-python

Repository files navigation

Arista eAPI with Python

A NextGen Network Academy guide. Companion code lives here; the conceptual walkthrough and learning objectives live on the netops site.

This repo contains a self-contained lab — a containerlab topology with a pre-staged Arista cEOS-lab node — plus the Python script, starter skeleton, and challenge brief for retrieving switch information from the device using eAPI.

No physical switch required. containerlab deploy and you have a working environment.

What's inside

Path Purpose
topo/topology.clab.yml Containerlab topology — single cEOS node, eAPI pre-enabled
topo/configs/eos1.cfg Startup config baked into the cEOS device
reference/eapi_show_version.py Complete working solution. Read after you've tried the challenge.
starter/eapi_starter.py Skeleton with TODO blocks. This is your starting point.
examples/sample_output.json Captured eAPI response — useful for offline iteration.
docs/instructor-guide.md Walkthrough notes for instructors using this in class.
docs/student-challenge.md The hands-on challenge brief and grading rubric.
docs/instructor-notes.md Answer key, common failure modes, time-box guidance.

Lab prerequisites

Install once on your machine:

Tool Purpose Install
Docker Container runtime docs.docker.com/get-docker
Containerlab Topology orchestrator containerlab.dev/install
cEOS-lab image The switch itself Free download from arista.com (account required)
Python 3.9+ The script python.org/downloads

After downloading the cEOS-lab tarball, import it once:

docker import cEOSarm-lab-4.34.4M.tar ceosarm:4.34.4M
docker images | grep ceos       # confirm it's there

Linux users will need sudo for containerlab. macOS (Docker Desktop or OrbStack) and Windows-WSL2 typically don't.

Quick start

# 1. Clone
git clone https://github.com/nextgen-network-academy/arista-eapi-python.git
cd arista-eapi-python

# 2. Bring up the lab
sudo containerlab deploy -t topo/topology.clab.yml

# 3. Set up the Python environment
python3 -m venv .venv
source .venv/bin/activate          # Windows: .venv\Scripts\activate
pip install -r requirements.txt

# 4. Configure (defaults already match the lab — no edits needed)
cp .env.example .env

# 5. Run the reference solution
python reference/eapi_show_version.py

You should see two GitHub-flavored markdown tables in your terminal — show version and show interfaces status, both pulled from the running cEOS node over eAPI.

Tear down when you're done

sudo containerlab destroy -t topo/topology.clab.yml --cleanup

A word on terminology

You will hear engineers call eAPI a "REST API." Strictly speaking, it isn't — eAPI uses JSON-RPC 2.0 over HTTPS, always via HTTP POST. The read-only equivalent of a REST GET is a show command, which is idempotent and does not change state. We teach the protocol honestly so you understand what's happening on the wire. (Arista's true REST surface lives in CloudVision; that's a separate guide.)

License

MIT — see LICENSE.

About

Companion code for the NextGen Network Academy NetOps guide on Python + Arista eAPI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages