Hi Stuart,
I assume you are not using Aruba Central? If you are you could do this a number of ways including using the Aruba Central API.
If these are non cloud managed APs then you could utilise the REST API -
https://www.arubanetworks.com/techdocs/Aruba-Instant-8.x-Books/811/Aruba-Instant-8.11.0.0-REST-API-Guide.pdf
Here is some shonky python I've jumbled together... You would need to run allow-rest-api, commit apply on the IAP to enable the REST API. I can't guarantee the code will work for you perfectly.
import csv
import requests
# specify the Aruba Master IAP IP Address
iap_ip = "ip_addr_of_VC"
#specify the Aruba AP Login details
admin = "admin"
password = "passsssword"
# specify URLs for logging in and out of the Aruba Instant API
loginurl = "https://"+iap_ip+":4343/rest/login"
print(f"Logging in at: ", loginurl)
logouturl = "https://"+iap_ip+":4343/rest/logout"
# specify the headers
headers = {'Content-Type': 'application/json'}
# specify auth payload
auth_payload = {"user": admin, "passwd": password}
# login to the AP to retrieve the SID, include verify=False for certificate errors
login = requests.post(loginurl, headers=headers, json=auth_payload)
print(login)
if login.status_code == 503:
print(f"Please enable the REST API")
raise SystemExit('API disallowed')
else:
back = login.json()
print(back)
if str(back['Status']) == "Success":
print(f"Successfully logged into the AP")
sid = back['sid']
else:
print(f"Failed to log into the AP. Status-code: ",back['Status-code'],", Message :", back['message'])
raise SystemExit('Login failed')
# specify the URL for the AP API
apiurl = "https://"+ iap_ip+":4343/rest/hostname?sid="+sid
print(f"API URL: ", apiurl)
# read the CSV file containing the AP names
with open('ap_names.csv', 'r') as file:
reader = csv.reader(file)
next(reader) # skip the header row
for row in reader:
ap_ip, new_name = row[0], row[1]
# construct the payload for the API request
payload = {"iap_ip_addr": ap_ip,
"hostname_info":
{"hostname": new_name
}
}
print(payload)
# send the API request to update the AP name, include verify=False for certificate errors
response = requests.post(apiurl, json=payload, headers=headers)
check = response.json()
# check the response status code to ensure the request was successful
if response.status_code == 200:
if check['Status-code'] == 0:
print(f"Successfully renamed AP {ap_ip} to {new_name}")
else:
print(check)
else:
print(f"Failed to rename AP {ap_ip}. Status Code: {response.status_code} Error: {response.text}")
# logout afterwards to close the door, include verify=False for certificate errors
lo_payload = {"sid": sid}
logout = requests.post(logouturl, json=lo_payload, headers=headers)
print(f"Logging out at: ", logouturl)
l_out = logout.json()
# check the response status code to ensure the request was successful
if logout.status_code == 200:
print(l_out['message'])
else:
print(f"Uh oh! Logout failed. Message: ",l_out['message'])
You can setup a csv file like this...

Not sure I can help with pre-populating this csv in response to the first part of your query. The show aps API doesn't respond with JSON so it would require some clever parsing. I've kept the CSV simple however. So hopefully you could easily populate it.