Obtain a list of network devices by using Meraki, Cisco DNA Center, ACI, CiscoSD-WAN, or NSO

9. Construct code to perform a specific operation based on a set of requirements and given API reference documentation.

📘Cisco DevNet Associate (200-901 DEVASC)


In network automation and programmability, one of the most common tasks is retrieving information about devices on a network. Cisco provides multiple platforms that allow you to do this programmatically using APIs. Let’s go platform by platform.


1. Cisco Meraki

Meraki is Cisco’s cloud-managed networking solution. It provides an easy way to get device information via the Meraki Dashboard API.

  • API Endpoint: To get a list of devices in a network: GET /networks/{networkId}/devices
  • How it works:
    • You need an API key from your Meraki dashboard.
    • Send a GET request to the endpoint.
    • The API responds with a JSON list of devices, including:
      • Device model
      • Serial number
      • MAC address
      • IP address
      • Status (online/offline)
  • Example in Python: import requestsAPI_KEY = “your_meraki_api_key”
    NETWORK_ID = “N_123456789″url = f”https://api.meraki.com/api/v1/networks/{NETWORK_ID}/devices”
    headers = {“X-Cisco-Meraki-API-Key”: API_KEY}response = requests.get(url, headers=headers)
    devices = response.json()for device in devices:
    print(f”{device[‘model’]} – {device[‘serial’]} – {device[‘status’]}”)

Key Exam Points:

  • Know that Meraki is cloud-based.
  • Understand that devices are returned in JSON format.
  • You need API Key authentication.

2. Cisco DNA Center

Cisco DNA Center (DNAC) is used for network automation in enterprise environments.

  • API to list devices: GET /dna/intent/api/v1/network-device
  • Authentication:
    • Uses a token-based authentication.
    • First, you get a token using your username and password: POST /dna/system/api/v1/auth/token
    • Then, use that token in the header: X-Auth-Token: <token>
  • Returned info includes:
    • Device type (switch, router, wireless)
    • IP address
    • Software version
    • Serial number
  • Python Example: import requestsDNAC_URL = “https://dnac.example.com”
    USER = “username”
    PASS = “password”# Get Auth token
    auth_response = requests.post(f”{DNAC_URL}/dna/system/api/v1/auth/token”, auth=(USER, PASS))
    token = auth_response.json()[‘Token’]# Get devices
    headers = {“X-Auth-Token”: token}
    response = requests.get(f”{DNAC_URL}/dna/intent/api/v1/network-device”, headers=headers)
    devices = response.json()[‘response’]for device in devices:
    print(f”{device[‘hostname’]} – {device[‘managementIpAddress’]} – {device[‘type’]}”)

Key Exam Points:

  • Token-based authentication is used.
  • Devices returned with detailed attributes like hostname, type, IP, software version.
  • Often used in enterprise campus networks.

3. Cisco ACI (Application Centric Infrastructure)

Cisco ACI is for data center networks and uses the APIC (Application Policy Infrastructure Controller) API.

  • API Endpoint: GET /api/node/class/fabricNode.json
  • Authentication:
    • Uses session login (username/password) to get a token.
  • Returned info:
    • Node ID
    • Role (leaf, spine)
    • IP address
    • Status (up/down)
  • Python Example: import requestsAPIC_URL = “https://apic.example.com”
    USER = “admin”
    PASS = “password”# Login to get cookie
    login_payload = {“aaaUser”: {“attributes”: {“name”: USER, “pwd”: PASS}}}
    response = requests.post(f”{APIC_URL}/api/aaaLogin.json”, json=login_payload, verify=False)
    token = response.json()[‘imdata’][0][‘aaaLogin’][‘attributes’][‘token’]
    cookies = {‘APIC-cookie’: token}# Get nodes
    response = requests.get(f”{APIC_URL}/api/node/class/fabricNode.json”, cookies=cookies, verify=False)
    nodes = response.json()[‘imdata’]for node in nodes:
    attrs = node[‘fabricNode’][‘attributes’]
    print(f”Node {attrs[‘id’]} – Role {attrs[‘role’]} – IP {attrs[‘managementIp’]}”)

Key Exam Points:

  • ACI is data-center focused.
  • Nodes can be spine or leaf.
  • Uses APIC session authentication.

4. Cisco SD-WAN (vManage API)

Cisco SD-WAN uses vManage for controller-based management.

  • API Endpoint: GET /dataservice/device
  • Authentication:
    • Login with username/password to get a JSESSIONID cookie.
  • Returned info:
    • Device type (vEdge, cEdge)
    • System IP
    • Hostname
    • Status
  • Python Example: import requestsVMANAGE = “https://sdwan.example.com”
    USER = “admin”
    PASS = “password”# Login
    login_payload = {‘j_username’: USER, ‘j_password’: PASS}
    session = requests.session()
    session.post(f”{VMANAGE}/j_security_check”, data=login_payload, verify=False)# Get devices
    response = session.get(f”{VMANAGE}/dataservice/device”, verify=False)
    devices = response.json()[‘data’]for device in devices:
    print(f”{device[‘host-name’]} – {device[‘system-ip’]} – {device[‘device-type’]}”)

Key Exam Points:

  • SD-WAN devices are often branch or edge routers.
  • vManage API returns detailed device info.
  • Session-based login required.

5. Cisco NSO (Network Services Orchestrator)

NSO is used to automate and manage devices via a model-driven approach (YANG models).

  • API Types: RESTCONF or NETCONF
  • Endpoint Example for RESTCONF: GET /restconf/data/tailf-ncs:devices
  • Returned info:
    • Device name
    • Device type
    • Connection status
    • Management IP
  • Python Example using RESTCONF: import requests
    from requests.auth import HTTPBasicAuthNSO_URL = “https://nso.example.com:8443/restconf/data/tailf-ncs:devices”
    USER = “admin”
    PASS = “admin”response = requests.get(NSO_URL, auth=HTTPBasicAuth(USER, PASS), headers={“Accept”: “application/yang-data+json”}, verify=False)
    devices = response.json()[‘tailf-ncs:devices’][‘device’]for device in devices:
    print(f”{device[‘name’]} – {device[‘address’]} – {device[‘device-type’]}”)

Key Exam Points:

  • NSO uses YANG models to represent device data.
  • RESTCONF/NETCONF can retrieve device information.
  • Provides a single interface for multi-vendor devices.

Exam Tips for 9.a

  1. Understand the platform differences:
    • Meraki: Cloud-managed
    • DNAC: Campus/Enterprise network management
    • ACI: Data center fabric
    • SD-WAN: WAN/Edge routers
    • NSO: Multi-vendor orchestration
  2. Know the authentication method for each:
    • API Key → Meraki
    • Token → DNA Center
    • Session cookie → ACI, SD-WAN
    • Basic Auth / RESTCONF → NSO
  3. Understand JSON responses:
    • Almost all APIs return device info as JSON.
    • Key fields: hostname, IP, device type, status.
  4. Python is commonly used in examples.
    • Requests library: requests.get(), requests.post()
    • JSON parsing: response.json()
    • Loop through devices to display information.
  5. Real IT environment use:
    • Quickly check all devices online.
    • Validate software versions.
    • Inventory devices for upgrades or monitoring.

Summary:

For the exam, you should be able to identify which API to use for a given Cisco platform, understand authentication, and write code to retrieve device lists. Remember, these are all standard REST API calls returning JSON, and Python examples are typically enough to demonstrate knowledge.

Buy Me a Coffee