Developer

 View Only
last person joined: 5 hours ago 

Expand all | Collapse all

Set boot partition using AOS Rest API

This thread has been viewed 12 times
  • 1.  Set boot partition using AOS Rest API

    Posted Dec 21, 2023 05:27 AM

    Hello,

    I'd like to set the boot partition on our controllers using the API (we have quite a lot of controllers so it's easiier than doing it by hand, and I'd prefer to use the API than script SSH CLI commands), but I'm not sure I can see a way of doing it. There's /object/config_boot_partition but the wording sounds a bit odd:

    "Create a new instance or update existing instance or delete parts of the instance or full object of type config_boot_partition"

    Will this do what I want? I tried it out and nothing happened but it's more than possible I'm doing something wrong (my Python scripting skills are pretty basic)?:

    def set_ctlr_boot_partition(host,uid,part):

        hostname = host
        uidaruba = uid
        part_num = str("partition"+part)

        url = f"https://{hostname}:4343/v1/object/config_boot_partition"
        payload = {
               "verbose": True,
               "test_type": "fast",
               "partition_num": part_num
               }

        headers = {"Content-Type": "application/json",
                   "Accept" : "application/json",
                   "Cookie" : f"SESSION={uid}",
                   }

        response = requests.request("POST", url, json=payload, headers=headers, verify=False)
        print(response.raise_for_status())
        return response

    The API reference on the developer site doesn't seem to include this particular call so I can't verify my function is correct. response.raise_for_status() returns 'None'.

    I'd also like to be able to reload controllers via the API, there's an /object/reload call but again the language is a bit ambiguous:

    "Create a new instance or update existing instance or delete parts of the instance or full object of type reload"

    Any advice appreciated.

    Guy



  • 2.  RE: Set boot partition using AOS Rest API

    MVP GURU
    Posted Dec 22, 2023 04:11 AM

    Hi Guy,

    if you display response and not raise_for_status ?

    I write this small code using PowerShell (and PowerArubaMC) and work for me :

    $body = @{
        "partition_num" = "partition0"
    }
    
    Invoke-ArubaMCRestMethod -method POST -uri v1/configuration/object/config_boot_partition -body $body

    i get the following output 

    config_boot_partition                               _global_result
    ---------------------                               --------------
    @{partition_num=partition0; _result=}               @{status=0; status_str=Success; _pending=False}

    and after launch reboot/reload without body

    Invoke-ArubaMCRestMethod -method POST -uri v1/configuration/object/reload

    there is no output... only need to wait 2/3 minutes and the controller is reload 



    ------------------------------
    PowerArubaSW : Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP...

    PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...)

    PowerArubaCL: Powershell Module to use Aruba Central

    PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)..

    ACEP / ACMX #107 / ACDX #1281
    ------------------------------



  • 3.  RE: Set boot partition using AOS Rest API

    Posted Dec 22, 2023 09:21 AM

    Hi,

    Bah ok it was me being an idiot. missed out "configuration" in the URL, _and_ missed out the line that includes the config_path and ARUBAUID

    querystring = {"config_path":"/mm","UIDARUBA":"<uidaruba obtained previously>"}

    I had/have a session cookie in there already ("Cookie" : f"SESSION={uid}",) which I thought was the arubauid. I'm not really sure what that cookie actually does and whether I need it at all. But anyway it is working now. Thank you