PowerAruba / PowerArubaSW

PowerShell module to manage ArubaOS switches
Apache License 2.0
42 stars 9 forks source link

Feature request: add support for firmware uploads #138

Open LRSFC-DanJ opened 7 months ago

LRSFC-DanJ commented 7 months ago

PowerArubaSW currently doesn't provide a command that can do firmware uploads to HP/Aruba AOS-S switches.

The process for doing this using the REST API is described on the HPE website here: https://support.hpe.com/hpesc/public/docDisplay?docId=sf000095706en_us&docLocale=en_US

It would be great if this could be added as this would be a step towards being able to script/schedule switch updates in bulk.

alagoutte commented 7 months ago

Hi @LRSFC-DanJ,

Yes... You can try this : (work me)

$body = @{
    "url"        = "http://192.168.244.48/YA_16_11_0016.swi"
    "file_type"  = "FTT_FIRMWARE"
    "action"     = "FTA_DOWNLOAD"
    "boot_image" = "BI_PRIMARY_IMAGE"
}
Invoke-ArubaSWWebRequest -method POST -body $body -uri "file-transfer"

and for Check status

(Invoke-ArubaSWWebRequest -method GET -uri "file-transfer/status").content

For example :

$body = @{
    "url"        = "http://192.168.244.48/YA_16_11_0016.swi"
    "file_type"  = "FTT_FIRMWARE"
    "action"     = "FTA_DOWNLOAD"
    "boot_image" = "BI_PRIMARY_IMAGE"
}
Invoke-ArubaSWWebRequest -method POST -body $body -uri "file-transfer"

StatusCode        : 202
StatusDescription : Accepted
Content           : {"message":"File transfer initiated"}
RawContent        : HTTP/1.1 202 Accepted
                    Server: eHTTP
                    Server: v2.0
                    Connection: close
                    Transfer-Encoding: chunked
                    RequestId: 
                    Content-Type: application/json

                    {"message":"File transfer initiated"}
Headers           : {[Server, System.String[]], [Connection, System.String[]], [Transfer-Encoding, System.String[]], [RequestId, System.String[]]…}
Images            : {}
InputFields       : {}
Links             : {}
RawContentLength  : 37
RelationLink      : {}

(Invoke-ArubaSWWebRequest -method GET -uri "file-transfer/status").content
{"uri":"/file-transfer/status","status":"FTS_IN_PROGRESS","result":"File transfer still in progress"}   

#retry after some seconds/minutes...
(Invoke-ArubaSWWebRequest -method GET -uri "file-transfer/status").content
{"uri":"/file-transfer/status","status":"FTS_COMPLETED"}

I accept with pleasure patch for adding cmdlet for this :)

LRSFC-DanJ commented 7 months ago

Thank you, this is actually really helpful as I didn't know there was an API function to check the file transfer status (finding documentation about this API seems really difficult for some reason).

LRSFC-DanJ commented 7 months ago

Do you happen to know what software version is required for the file-transfer/status API endpoint to be available? As it doesn't seem to be present on the software version installed on our switches at the moment, sadly.

alagoutte commented 7 months ago

Do you happen to know what software version is required for the file-transfer/status API endpoint to be available? As it doesn't seem to be present on the software version installed on our switches at the moment, sadly.

What your switch model and firmware ? (and max supported api version when you connect ?)

You can look this for doc about API : https://networkingsupport.hpe.com/downloads/software/RmlsZTo3OTI3NTc5Mi00YzQ5LTExZWQtOTUxMy04Yjg1M2I4ZWYxMDk%3D