Cloud Managed Networks

 View Only
  • 1.  Aruba Central script to bulk change AP names

    Posted Jun 07, 2022 02:53 PM
    Hi Airheads,

    I come up a situation i have to change the AP name for around 700 access points in Aruba Central. It seems like there is no easy xml import button to do this. Off course there maybe some other options but i come up the idea to create an python script what talks to the Aruba Central API interface.

    The script read from a common seperate file "import.txt" what contains the AP serial numbers and the desired AP names like the follow format:
    DZ0123456,HomeLAB-AP01
    DZ0123457,HomeLAB-AP02
    DZ0123458,HomeLAB-AP03
    DZ0123459,HomeLAB-AP04​


    Before the script runs there are some attributes to customize yourself:
    1. Fill in the API access+token you can generate in your Aruba Central account.
    2. Prepare the "import.txt" file like above.
    3. The URL must be match your Aruba Central datacenter location (EU-1, EU-3 for example has different URLs which can be find in Aruba Central.

    To generate a Aruba Central token go to: Network Operations > Organization > Platform Integration > API Gateway > REST API
    Here you will also find the URL of your Aruba Central , for example EU-1 is "https://eu-apigw.central.arubanetworks.com/".

    Note: API access token will expire after 2 hours.

    Hope you will find my script useful and inspire you to create your own API scripts.

    import requests
    import json
    
    
    token = "api token here"
    
    header = {'Authorization': 'Bearer ' + token}
    
    with open('import.txt') as importfile:
       for line in importfile:
          serial, apname = line.split(',')
          print(serial.strip(), apname.strip())
    
    
          url = "https://eu-apigw.central.arubanetworks.com/configuration/v2/ap_settings/"+serial
    
          payload = {"hostname": apname,
                     "ip_address": "",
                     "zonename": "",
                     "achannel": "",
                     "atxpower": "",
                     "gchannel": "",
                     "gtxpower": "",
                     "dot11a_radio_disable": False,
                     "dot11g_radio_disable": False,
                     "usb_port_disable": False}
    
          r = requests.post(url, json=payload, headers=header)
    
          response = r.text
          print (response)​




     


    ------------------------------
    Marcel Koedijk | MVP Expert 2022 | ACEP | ACMP | ACCP | ACDP | Ekahau ECSE | Not an HPE Employee | Opinions are my own
    ------------------------------


  • 2.  RE: Aruba Central script to bulk change AP names

    Posted Jun 07, 2022 07:08 PM
    This is great.

    Also I wanted to ensure that everyone is aware of this Aruba Central API automation site that was developed by one of our senior engineers and is fully operational. This  show cases the true power of automation.
    https://central.wifidownunder.com/settings.html

    Here is the full doco on it.
    https://central.wifidownunder.com/documentation.html



    ------------------------------
    Any opinions expressed here are solely my own and not necessarily that of Hewlett Packard Enterprise or Aruba.
    ------------------------------



  • 3.  RE: Aruba Central script to bulk change AP names

    Posted Jun 08, 2022 12:43 AM
    Thanks for sharing!

    Outlook voor iOS downloaden





  • 4.  RE: Aruba Central script to bulk change AP names

    Posted 7 days ago

    Hi Marcel,

    I tried to run this but it seems Aruba API doesn't support this when running the script externally. First I tried using the built in Aruba API and through that I can only change the AP name for individual AP. I tried to run the script externally, but it gives error like "The method is not allowed for the requested URL." Status code : 405.

    Where you ran the script exactly?




  • 5.  RE: Aruba Central script to bulk change AP names

    Posted 7 days ago

    Do you use Classic Central or the New Central?

    The script was developed for Classic Central, where the API is configured in the Classic Central interface. It runs externally and does not need to be executed from within Central.


    Met vriendelijke groet / Kind regards,

    Marcel

    KOEDIJK

    Consultant

    Tel:

     

    +31 251 261 300

    - Mobiel: 

     

    +31 6 51611374

     

    marcel.koedijk@axians.com

     


    C2-Vertrouwelijk






  • 6.  RE: Aruba Central script to bulk change AP names

    Posted 6 days ago

    New CAS is also available for New Central check it out.



    ------------------------------
    If my post was useful accept solution and/or give kudos.
    Any opinions expressed here are solely my own and not necessarily that of HPE or Aruba.
    ------------------------------



  • 7.  RE: Aruba Central script to bulk change AP names

    Posted 6 days ago

    I use Classic Central




  • 8.  RE: Aruba Central script to bulk change AP names

    Posted 13 hours ago

    A 405 means the path matched something but the verb didn't, so it's worth checking two things before blaming the API.

    First, your base URL has to be your own region. The script hardcodes eu-apigw, and if that isn't your cluster you're hitting a gateway that doesn't serve your tenant. Grab the right one from API Gateway in Central.

    Second, look at the indentation in the script as posted. The url, payload and requests.post lines sit outside the for loop, so it only ever fires once, using whatever serial was left over from the last line, and apname still has a newline on it. Pull those inside the loop and strip both values.

    If it still 405s after that, post your exact request line and the full response body, since the status alone doesn't say whether it's the verb or the path.



    ------------------------------
    Dustin Burns

    @Worldcom Exchange, Inc.


    If my post was useful accept solution and/or give kudos
    ------------------------------



  • 9.  RE: Aruba Central script to bulk change AP names

    Posted 6 days ago
    Edited by GK-c34688 6 days ago

    Hi Marcel.

    Neat little script. Very useful even for smaller deployments. Can save quite a few mouse clicks.

    I usually use Central Automation Studio docker on my laptop for mass changes. Your script offer additional flexibility and no overhead.

    And just to remind everyone, there is a pycentral github here https://github.com/aruba/pycentral v2 supports classic and new Central.

    Best, Gorazd

     



    ------------------------------
    Gorazd Kikelj
    MVP Guru 2025
    ------------------------------