Wired Intelligent Edge (Campus Switching and Routing)

Reply
Highlighted
Occasional Contributor II

REST Post firmware images

Hi all,

 

I want to post firmware images on 6300 switches using a REST call in python. 

The example from the API guide doesn't seem to work (I think the example is still using an old API?):

https://support.hpe.com/hpesc/public/docDisplay?docLocale=en_US&docId=emr_na-a00091710en_us

 

The API help on the switch ( https://{switch_ip}/api/v10.04 ) doesn't really help either.

 

So I have some basic questions. Do I upload the firmware in the post request in binary form or do I post a link to the file, where the switch needs to download it? If it's the latter, which protocol is used for the download?

 

I got the idea because of the documentation:

{
  "file": [
    "string"
  ]
}

It says string instead of binary file.

Did someone already upgrade their switch via API?

 

I tinkered a lot with the code, most of the times I get the error response 500 "Error processing the form.\n".

 

Here is the current code, if you are interested.

 

 

 

 

        firmware = os.path.abspath(firmware)

        params = (
            ('image', 'secondary'),
        )

        files = {'file': open(firmware, 'rb')}

        headers = {
            'accept': '*/*',
            'Content-Type': 'multipart/form-data',
        }

        r = session_dict['s'].post(target_url, files=files, headers=headers, params=params, verify=False)

 

 

 

 

Thanks,

Bjarne

Search Airheads
cancel
Showing results for 
Search instead for 
Did you mean: