~/netref / Automation & APIs
##

Automation & APIs

Modern networks are programmed, not typed. The data formats, APIs and tools that make it happen.

// data formats
JSONLightweight key/value — most APIs
XMLVerbose tags — NETCONF
YAMLHuman-friendly — Ansible
// REST verbs (CRUD)
GETRead
POSTCreate
PUT / PATCHUpdate
DELETERemove

// network APIs & models

  • REST: HTTP CRUD over JSON, stateless
  • NETCONF: XML over SSH (port 830)
  • RESTCONF: REST-style over HTTP
  • YANG: data model for config & state
  • gNMI: streaming telemetry over gRPC
// tools
AnsibleAgentless, YAML playbooks, push
TerraformDeclarative IaC, state-based
Pythonnetmiko / NAPALM / requests
Puppet / ChefAgent-based, pull model

// SDN

  • Separates control plane from data plane
  • A central controller programs the devices
  • Northbound API (apps) / Southbound API (devices)
  • Intent-based networking automates policy
// management interfaces
NETCONFXML over SSH · 830Transactional config (candidate → commit)
RESTCONFJSON/XML over HTTPS · 443REST-style access to YANG data
gNMIprotobuf over gRPCStreaming telemetry & config
SNMPUDP 161Legacy polling (read-mostly)

// IaC principles

  • Idempotent — re-running yields the same state
  • Declarative (desired state) vs imperative (steps)
  • Store configs in Git — GitOps source of truth
  • CI/CD pipeline tests config before pushing
  • Render → deploy → verify, automatically
automate · python (netmiko)
# Python — push config with netmiko
from netmiko import ConnectHandler
dev = {"device_type":"cisco_ios","host":"10.0.0.1",
       "username":"admin","password":"***"}
with ConnectHandler(**dev) as c:
    c.send_config_set(["interface Gi0/1",
                       "description uplink","no shutdown"])
    print(c.send_command("show ip int brief"))
restconf · curl
# RESTCONF — read interfaces (JSON over HTTPS)
curl -sk -u admin:*** \
  -H "Accept: application/yang-data+json" \
  https://10.0.0.1/restconf/data/ietf-interfaces:interfaces