Example: Firmware upgrade using REST APIs

Uploading a file as the secondary firmware image

In the following example, a curl command is used to upload the firmware image file from the local workstation to the switch, as the secondary firmware image. The-Foption specifies that the POST method is used to upload the file.

Example method and URI:

POST "https://192.0.2.5/rest/v1/firmware?image=secondary"

请求主体包含开关固件图像放大e file in binary format.

Example curl command:

$curl --noproxy -k -b /tmp/auth_cookie \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -F "fileupload=@/myfirmwarefiles/myswitchfirmware_2020020905.swi" \ https://192.0.2.5/rest/v1/firmware?image=secondary
In the curl command, the POST request is handled as part of the-Foption.

Booting the system using the secondary firmware image

Example method and URI:

POST "https://192.0.2.5/rest/v1/boot?image=secondary"

Example curl command:

$curl --noproxy -k -X POST -b /tmp/auth_cookie \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ "https://192.0.2.5/rest/v1/boot?image=secondary"