Automating ArubaOS-CX Switches with the REST API and Postman - 夜莺博客

Automating ArubaOS-CX Switches with the REST API and Postman

ArubaOS-CX switches expose a full RESTful API that lets you treat switch configuration like any other software-defined resource — read state, push config, and automate workflows without ever opening an SSH session. This tutorial walks through a proven Postman collection of 13 requests that covers the whole lifecycle: logging in, reading interface state, uploading a complete configuration, and building a VLAN workflow step by step. It is the fastest way to get comfortable with AOS-CX programmability before you move on to Ansible or scripting.

Prerequisites and Initial Switch Setup

You need Postman (v7.2.2 or later) and an AOS-CX capable switch — a virtual AOS-CX switch works perfectly for testing. On the switch, enable the REST server and create an API user:

switch(config)# rest access-mode read-write enabled
switch(config)# username apiadmin password Aruba123
switch(config)# vlan 7
switch(config)# interface 1/1/4

Set a Postman environment variable named host to the switch management IP (e.g. 192.168.121.2) so every request resolves against the right device.

Importing the Collection

In Postman, click Import → Import from Link and paste the collection URL from the Aruba Community post. You get 13 requests labelled Aruba Andy's AOS-CX Collection covering login, logout, and read/write operations.

The Key Requests

Login and Logout

The login request is a POST that authenticates the API user and returns a session cookie. Always send a logout when you finish — sessions left open until idle timeout are a small but avoidable hygiene issue.

Show Running-Config and Upload Full-Config

The most instructive pair: run show running-config on the switch, then GET the running config via the API and compare the JSON formatting with the CLI output. You can paste the API response body into the Upload Full-Config PUT request to overwrite the switch config programmatically — exactly how you would seed a new device.

VLAN and Interface Workflow

  • Create vlan7 — POST to create the VLAN.
  • Map 1/1/4 to vlan7 — the tricky one: this only works if the interface has never been defined on the switch. If the port already exists in config, the request fails — a known quirk of how AOS-CX maps physical interfaces to logical ports (see the AOS-CX REST API Guide, section on ports and interfaces).
  • Review 1/1/4 — GET to inspect the interface state.
  • Bring 1/1/4 up — PUT to edit the interface admin state.
  • Delete vlan7 — DELETE, with a worthwhile experiment: delete a VLAN that is still referenced by an interface and observe the behavior.

Diagnostics Over the API

Ping and traceroute are also exposed as API requests — identical to the Diagnostics tools in the switch GUI, which makes them easy to embed in health-check scripts.

For onboarding and management context, see HPE Aruba AOS-CX Central 上线指南 and Arista CloudVision 与 AVD 实验 for adjacent automation workflows on Arista and Dell platforms.

原文链接:https://community.arubanetworks.com/discussion/tutorial-aos-cx-restful-api-and-postman