Wired Intelligent Edge (Campus Switching and Routing)

 View Only
last person joined: one year ago 

Bring performance and reliability to your network with the HPE Aruba Networking Core, Aggregation, and Access layer switches. Discuss the latest features and functionality of HPE Aruba Networking switching devices, and find ways to improve security across your network.

How to initiate a REST API call to HPE Switches for a Firmware Upgrade 

Mar 28, 2020 02:56 AM

Requirement:

We might have a requirement to initiate a firmware upgrade on the HPE Switch through an API call. This article provides one way of doing that.



Solution:

We can make use of the REST API call with the file-transfer service which is available from OS version 16.03.xx onwards for initiating the Firmware upgrade.

 

 

 

 



Configuration:

The REST-Interface on the Switch which we need to interact with for doing the REST Api calls is enabled by default on the switch. You can confirm that by executing the below command

Aruba-2930F-24G-PoEP-4SFP(config)# show rest-interface

 REST Interface - Server Configuration

  REST Interface            : Enabled
  REST Operational Status   : Up
  REST Session Idle Timeout : 7200 seconds
  HTTP Access               : Enabled
  HTTPS Access              : Enabled
  SSL Port                  : 443
 

The HTTPS access would be disabled by default. To enable HTTPS access you need to install a server certificate. We strongly recommend that you install a HTTPS certificate so that you can make the API calls over HTTPS.

Once that is done we should first initiate a login API call that gives us a cookie which we could use to do subsequent API calls.

sh-4.1# curl -k -X POST https://<IP Address or hostname of Switch>/rest/v1/login-sessions -d '{"userName":"<login username>","password":"<loginpassword>"}'
{"uri":"/login-sessions","cookie":"sessionId=TjSM8eDOkxfJgNLN1qx8FWA7YeOy8dNUqFp1a86JK9xV68ZWhBOfgGg60ayjzKM"}

The cookie we have obtained should be used for subsequent API calls.

The file-transfer API call for the Firmware Upgrade can be initiated as shown below

curl --cookie "sessionId=TjSM8eDOkxfJgNLN1qx8FWA7YeOy8dNUqFp1a86JK9xV68ZWhBOfgGg60ayjzKM" -k -X POST https://<IP Address or hostname of Switch>/rest/v3/file-transfer -d '{ "file_type":"FTT_FIRMWARE", "url":"<URL of the webserver that hosts the image>", "action":"FTA_DOWNLOAD", "boot_image":"BI_PRIMARY_IMAGE"}'

The POST destination is the Switch. the file_type would be "FTT_FIRMWARE" for Firmware. and the boot_image can be "BI_SECONDARY_IMAGE" or "BI_PRIMARY_IMAGE".

The URL is the URL of the Webserver that hosts the Firmware image . The cookie is the sessionID that was obtained by the login API call shown above.

Once we initiate this API call we would see a message like this 

{"message":"File transfer initiated"}

 

Similarly the File-Transfer API call can also be used to upload/download any of the below items

        "FTT_CONFIG", 
        "FTT_FIRMWARE", 
        "FTT_EVENT_LOGS", 
        "FTT_CRASH_FILES", 
        "FTT_SYSTEM_INFO", 
        "FTT_SHOW_TECH", 
        "FTT_DEBUG_LOGS"

Also note that we could use any programming language like Python etc. to initiate this API call and it should work the same way.



Verification

Once we initiate the firmware upgrade and we see the message {"message":"File transfer initiated"} after the file-transfer API call, we could verify that the Firmware is uploaded by looking for the messages below in the log by executing a "show logging -r"

 

I 03/08/18 06:08:09 00159 update: FT file transfer complete.Device needs reboot

I 03/08/18 06:08:09 00150 update: Primary Image updated via network http(s) by

            Rest server.

I 03/08/18 06:08:05 00163 update: Firmware image contains valid signature.

I 03/08/18 06:08:04 04185 http: Download of

            http://<IP of WebServer>/guest/public/WC_16_04_0011.swi to /ramfs/os.bin

            completed successfully.

 Once you see that message it means the Firmware image has been successfully downloaded by the switch.

After that if you execute the "show flash" command it should show the new image 

 

Aruba-2930F-24G-PoEP-4SFP# show flash
Image             Size (bytes) Date     Version
----------------- ------------ -------- --------------
Primary Image    :    28320962 12/22/17 WC.16.04.0011
Secondary Image  :    28793152 12/22/17 WC.16.05.0004

Boot ROM Version
----------------
Primary Boot ROM Version   : WC.16.01.0004
Secondary Boot ROM Version : WC.16.01.0004

Default Boot Image   : Primary
Default Boot ROM     : Primary
 

Once the Image shows up in the flash you can reboot the Switch in the corresponding partition and finish the Upgrade.

 

Statistics
0 Favorited
11 Views
0 Files
0 Shares
0 Downloads

Related Entries and Links

No Related Resource entered.