REST API Workflows
Leveraging automation, can save time and cost to implement workflows that are done manually.
API endpoints for some of the workflows mentioned in the Use Cases section are provided below.
Update AP settings / Rename an AP
Often there is a need to rename multiple APs managed by Aruba Central. This is the endpoint to rename one AP. In order to rename multiple APs, multiple calls to this API endpoint has to be made. This API can also be used to update other AP settings as shown in the payload.
API Endpoint Path: /configuration/v2/ap_settings/{serial_number}
where serial_number is the serial number of the IAP.
Request Method: POST
Request Headers: "Authorization": "Bearer <access_token>"
Request Payload:
{
"hostname": "<ap-name>",
"ip_address": "<ip-address>",
"zonename": "<zone-name>",
"achannel": "<achannel-num>",
"atxpower": "<atxpower-num>",
"gchannel": "<gchannel-num>",
"gtxpower": "<gtxpower-num>",
"dot11a_radio_disable": <true/false>,
"dot11g_radio_disable": <true/false>,
"usb_port_disable": <true/false>
}
Python Example
In this workflow, pycentral.workflows.config_apsettings_from_csv module from Python SDK pycentral
is used to rename APs.
- First step is to download the CSV file from Central.
Account Home -> Network Operations -> Choose an existing group from the Global menu -> Devices -> Access Points
and then click on the download icon in the Access Points Table.

- Update the required fields in the CSV file such as
DEVICE NAME
fields to change the name of the Access Points.
Some additional fields can be added to the CSV file as supported by the API endpoint. Complete list of supported fields are shown below.
SERIAL: Serial number of the AP for which the hostname will be modified
DEVICE NAME: Set new name for the AP
IP ADDRESS: Set valid IP to change the IP of the AP. If the AP has DHCP based IP, set "is_dhcp_ip" flag to true.
ZONE: if provided, will be configured
A CHANNEL: if provided, will be configured
A TX POWER: if provided, will be configured
G CHANNEL: if provided, will be configured
G TX POWER: if provided, will be configured
DOT11A RADIO DISABLE: if provided, will be configured
DOT11G RADIO DISABLE: if provided, will be configured
* USB PORT DISABLE: if provided, will be configured
Only these fields will be updated when provided. Other fields in the CSV file will be ignored.
At the end of script execution, a list of failed APs, that the script failed to update, will be listed for troubleshooting. A CSV file with failed APs will be created in the same directory of the provided CSV file.
# Create the following files by refering to the samples/documentation.
csv_filename = "csv_file.csv"
central_filename = "input_token_only.yaml"
# Get instance of ArubaCentralBase from the central_filename
from pycentral.workflows.workflows_utils import get_conn_from_file
central = get_conn_from_file(filename=central_filename)
# Rename AP using the workflow `workflows.config_apsettings_from_csv.py`
from pycentral.workflows.config_apsettings_from_csv import ApSettingsCsv
ap_workflow = ApSettingsCsv(is_dhcp_ip=True)
ap_workflow.ap_settings_csv(conn=central, csv_filename=csv_filename)
Note on API Usage Limit
Please note that the AP settings workflow uses (2 * N) number of API calls. Where N is the number of APs in the CSV file. For each AP, GET method is used to obtain existing AP settings and then a POST method is used to update the existing settings.
Site Deployment Workflow
In this workflow let's do the following
- Create a Group
- Move devices to the created Group
- Create a Site
- Assign devices to the created Site
Create a Site:
API Endpoint Path: /central/v2/sites
Request Method: POST
Request Headers: "Authorization": "Bearer <access_token>"
Request Payload:
{
"site_name": "site1",
"site_address": {
"address": "3970 Rivermark Plaza",
"city": "Santa Clara",
"state": "California",
"country": "United States",
"zipcode": "95053"
},
"geolocation": {
"latitude": "38.8951",
"longitude": "-77.0364"
}
}
HTTP Response: For successful request, site_id will be returned for created site
{
"site_id": 9,
"site_name": "site1"
}
Create a Group:
API Endpoint Path: /configuration/v2/groups
Request Method: POST
Request Headers: "Authorization": "Bearer <access_token>"
Request Payload: Setting true for Wired, Wireless keys will make the group a template group.
{
"group": "Central_Group",
"group_attributes": {
"group_password": "Aru2Ba@",
"template_info": {
"Wired": true,
"Wireless": true
}
}
}
HTTP Response: For successful request
"Created"
Assign device to a Site:
API Endpoint Path: /central/v2/sites/associate
Request Method: POST
Request Headers: "Authorization": "Bearer <access_token>"
Request Payload:
{
"device_id": "AD12412345",
"device_type": "IAP",
"site_id": 4
}
HTTP Response: No response message will be received for successful HTTP request.
Move devices to a Group:
This API endpoint moves a list of devices to a group. The devices are represented as serial numbers.
API Endpoint Path: /configuration/v1/devices/move
Request Method: POST
Request Headers: "Authorization": "Bearer <access_token>"
Request Payload:
{
"group": "Central_Group",
"serials": [
"string"
]
}
HTTP Response: For successful request
"Success"
Python Example
Python script developed using pycentral
Python SDK for site deployment workflow.
# Create the following files by refering to the samples.
csv_filename = "csv_file.csv"
central_filename = "input_token_only.yaml"
# Get instance of ArubaCentralBase from the central_filename
from pycentral.workflows.workflows_utils import get_conn_from_file
central = get_conn_from_file(filename=central_filename)
# Import Groups and Sites class
from pycentral.configuration import Groups, Devices
from pycentral.monitoring import Sites
g = Groups()
s = Sites()
d = Devices()
# Define Workflow Variables
group_name = "demo-grp"
group_pass = "pass@123"
site_name = "demo-site"
site_address = {
"address": "3000 Rivermark Plaza",
"city": "Santa Clara",
"state": "California",
"country": "United States",
"zipcode": "95053"
}
device_type = "IAP"
device_serials = ["CNXXXXXX01", "CNXXXXXX02", "CNXXXXXX03"]
# 1. Create a Template Group
print("1. Create a Group")
resp = g.create_group(central, group_name=group_name, group_password=group_pass,
wired_template=True, wireless_template=True)
print(resp)
# 2. Move devices to a Group
print("2. Move devices to a Group")
resp = d.move_devices(central, group_name=group_name,
device_serials=device_serials)
print(resp)
# 3. Create a Site
print("3. Creating Site")
resp = s.create_site(central, site_name=site_name, site_address=site_address)
print(resp)
# 4.1 Find site_id from site_name
site_id = s.find_site_id(central, site_name=site_name)
# 4.2 Assign Devices
print("4. Assign Devices to a Site")
resp = s.associate_devices(central, site_id=site_id,
device_type=device_type, device_id=device_serials)
print(resp)
Updated over 2 years ago