[Aruba DevNet Lecture 2] Escape Excel Hell! Organize Your Equipment Assets in 3 Seconds with Python

past Lecture 1In , we succeeded in obtaining an 'Access Token' that opens the door to the Aruba Central API.
If you haven't seen it yet, I recommend watching Lecture 1 first!

Today we will use that token for real ‘'Money and time'’ Let's get to work.
This is the eternal homework of network administrators: asset management (Inventory).

“Team Leader: Please compile an Excel spreadsheet with a list of all APs currently in operation, including serial numbers and license expiration dates. Within 30 minutes.”

Are you going to check and copy and paste everything one by one in the Aruba Central dashboard?
If you have the Python script I'm going to show you today, just press Enter once. Before even taking a sip of coffee An Excel file is created in no time.


1. Today's goal

  • target: Get information on all devices (APs, switches, gateways) registered in Aruba Central
  • process: After selecting only the information I need (name, model name, serial, IP, status)
  • result: Neat .xlsx Save as an Excel file.

In this process we PandasWe will be using a very powerful Python library called .
It's a tool used by data analysts who work with Excel, but it's also very useful for network engineers like us.

2. Warm-up: Finding APIs in the Developer Hub

Before coding Aruba Developer HubI guess I'll have to figure out which API to use?

The API we will use is Network Monitoring In the category List Devicesno see.

  • API Endpoint: /network-monitoring/v1alpha1/devices

“Why v1alpha1?”

As Aruba Central evolved into New Central, its APIs also began to take on a more standardized structure.
v1alpha1is the endpoint that most quickly reflects the latest network monitoring capabilities.

existing v2 It is faster than API and fully integrated with future microservices architecture based on AOS 10.

  • Method: GET
  • function: Returns a list of registered devices with their status and details.

3. [Practice] Saving New Central Data to Excel with Python

In this exercise, we will learn about the standard Excel analysis Pandas Use the library.

[Preparation]

Bash
pip install requests pandas openpyxl

[New Central-specific Python script]

Python
import requests
import pandas as PD
from datetime import datetime

# 1. New Central Access Information
Enter the token issued in # Lesson 1 and your region address.
ACCESS_TOKEN = ""YOUR_ACCESS_TOKEN""
BASE_URL = ""https://de1.api.central.arubanetworks.com""
API_PATH = ""/network-monitoring/v1alpha1/devices""

print(f""🚀 Start calling the New Central API: {BASE_URL}""")

try:
    # 2. Data Request
    response = requests.get(f"""{BASE_URL}{API_PATH}""", headers=headers)
    
    if response.status_code == 200:
        raw_data = response.json()
        # New Central v1alpha1 usually contains a list of equipment in the 'items' key.
        devices = raw_data.get(''items'', [])
        print(f""✅ Total {len(devices)}"We have received your equipment data."")
        
        # 3. Data processing (desired column mapping)
        device_list = []
        for dev in devices:
            device_list.append({
                ""Equipment Name"": dev.get(""deviceName""),
                ""cereals"": dev.get(""serialNumber""),
                ""model"": dev.get(""model""),
                ""IP address"": dev.get(""ipv4""),
                ""situation"": dev.get(""status""),
                ""site"": dev.get(""siteName""),
                ""MAC address"": dev.get(""macAddress"")
            })
            
        # 4. Saving Excel files using Pandas
        df = pd.DataFrame(device_list)
        filename = f""NewCentral_Inventory_{datetime.now().strftime(''%Y%m%d')}.xlsx""
        df.to_excel(filename, index=False)
        print(f""🎉 File saving complete: {filename}""")
        
    else:
        print(f""❌ Failure (code {response.status_code}): {response.text}""")

except Exception as e:
    print(f""❌ An error occurred: {e}""")

If the script runs successfully, an Excel file will be extracted with the following message.

4. In conclusion

Today we're extracting data from a modern environment called New Central.
Now, instead of manually organized Excel spreadsheets on your desk, A complete list of assets generated by the codeThere will be a place for it.

next 3rd lectureBased on the data collected in this way, AnsibleLet's dive into the world of 'real automation' by pushing settings to actual equipment (CX switches) using !