cancel
Showing results for 
Search instead for 
Did you mean: 

Uploading SPP

 
SOLVED
Go to solution
BradV
Trusted Contributor

Uploading SPP

Trying to upload the latest SPP to OneView using the REST API: 

ISO=spp-2019.03.0-SPP2019030.2019_0206.85.iso
curl --insecure \
     --max-time 1200 \
     --header "accept: application/json" \
     --header "X-API-Version: ${currentVersion}" \
     --header "auth: ${sessionID}" \
     --header "uploadfilename:${ISO}" \
     --form "file=\"@/var/tmp/${ISO}\"" \
     --request POST ${OneView}/rest/firmware-bundles | jq -r '.'

It is failing and I'm getting back: 

{
  "data": {},
  "nestedErrors": [],
  "erroSource": null,
  "recommendedActions": [],
  "details": null,
  "message": "Parsed multipart servlet request file is empty; nested exception is com.hp.ci.mgmt.fwdrivers.exceptions.FileUploadException: Emtpy file was found in the request.",
  "errorCode": null
}

Anyone have an idea what I am doing wrong?  I don't have any scopes defined.  So, did not include the scopeuri header.

10 REPLIES 10
ChrisLynchHPE
Neighborhood Moderator

Re: Uploading SPP

The form attribute name is called filename, not file.  


Accept or Kudo

BradV
Trusted Contributor

Re: Uploading SPP

Hi Chris,

Then the REST API reference needs updated.  At least my version shows: '-F file="@/var/tmp/.."  I did change to filename instead of file, but got back the same error.  I tried including the initialScopeUris header as just blank thinking maybe that was required, but still same error.  I do see the words, "a form with the Content-Type multipart/form-data and submit action as https://{app1}/rest/firmware-bundles."  So, I added: 

--header "content-type: multipart/form-data" \

to the call, but still did not work.  None of the examples show that option however. 

ChrisLynchHPE
Neighborhood Moderator

Re: Uploading SPP

This is straight from the REST API Documentation for POST /rest/firmware-bundles:

Upload SPP cURL examples from OV REST API Documentation.png

And sorry, the form attribute you have is correct.  I was looking at another part of my code for the PowerShell library, which does the exact same thing you are trying to do, and has not changed in a long time.


Accept or Kudo

BradV
Trusted Contributor

Re: Uploading SPP

Hi Chris,

Yes, that is exactly what I saw.  In the examples, they don't show an api version header, nor do they show anything about a content-type header.  In the last bullet above that section, it talks about a content-type multipart/form-data.  So, should that header also be included?  I used the long form of switches.  -m is the same as --max-time.  -k is the same as --insecure.  -X is the same as --request.  -H is the same as --header.  -F is the same as --form.  I also don't have any scopes defined.  Is the header intialscopeuris mandatory, or optional?  Are you sure the form parameter for the file name is "file?"  Just want to make sure it's not something like that.

BradV
Trusted Contributor

Re: Uploading SPP

Also, I don't see in the api reference firmware bundles section anything about retrieving a list of currently uploaded bundles nor deleting a currently uploaded bundle.  Are those functions available, but just not documented?

BradV
Trusted Contributor
Solution

Re: Uploading SPP

Finally got back to this and got it working.  I had to many quotes in the form line.  This code is working: 

# Upload SPP:
DIR=/var/tmp
ISO=spp-2019.03.0-SPP2019030.2019_0206.85.iso
curl --insecure \
     --max-time 1200 \
     --header "accept: application/json" \
     --header "auth: ${sessionID}" \
     --header "X-API-Version: ${currentVersion}" \
     --header "content-type: multipart/form-data" \
     --header "uploadfilename:${ISO}" \
     --form file="@${DIR}/${ISO}" \
     --request POST ${OneView}/rest/firmware-bundles | jq -r '.'

So, now just need to see if there is an API for getting the current list of uploaded bundles and how to delete an uploaded bundle.  I don't see those in the API reference.

ChrisLynchHPE
Neighborhood Moderator

Re: Uploading SPP

 


@BradV wrote:

Finally got back to this and got it working.  I had to many quotes in the form line.  This code is working: 

So, now just need to see if there is an API for getting the current list of uploaded bundles and how to delete an uploaded bundle.  I don't see those in the API reference.



GET /rest/firmware-drivers and DELETE /rest/firmware-drivers/{GUID} are the two API's that are documented to perform the operations you want to do.

 

 


Accept or Kudo

BradV
Trusted Contributor

Re: Uploading SPP

Hi Chris,

Thanks!  I see it was the next group in the API reference.    I got the status with: 

 

# To check existing firmware bundles, run:
curl --insecure \
     --header "auth: ${sessionID}" \
     --header "X-API-Version: ${currentVersion}" \
     --output firmware \
     --request GET ${OneView}/rest/firmware-drivers
#
# Then to see a summary of the information, run:
cat firmware | jq '.members[] | {baselineShortName,bundleType,hpsumVersion,isoFileName,releaseDate,resourceState,status,type,uri,uuid,version}'

 

To delete, I should use the value returned with 'uri,' correct?  For example, 

 

URI=/rest/firmware-drivers/SPP_Gen9_10_11
curl --insecure \
     --header "auth: ${sessionID}" \
     --header "X-API-Version: ${currentVersion}" \
     --header "content-type: application/json" \
     --include \
     --request DELETE ${OneView}${URI}

 

Does that look correct?

ChrisLynchHPE
Neighborhood Moderator

Re: Uploading SPP

Correct.


Accept or Kudo

BradV
Trusted Contributor

Re: Uploading SPP

Thanks.  Yes, that worked.