Load content packs via CLI/API/REST

Hi all, 

I'm currently looking for documentation that would allow me to programically deploy a content pack via a Remote Powershell, API or authenticated RESTful interface to OO 10.51

I have found the OO Shell Wizard but this has a gui that appears to replay commands on your behalf.

If anyone could point me in the right direction of some method/doco it would be appreciated.

Thanks, 

Andrew

  • You can check the "How can I deploy content packs with progress" section the API guide.

  • Hi,

    We would like to understand your use cases. For eg are you also creating the CP from CLI?

    To deploy a CP from CLI you can also use OO Shell (OOSH) CLI tool that is available with HPE OO.

    HTH,

    Lucian

  • Hi,

    We would like to understand your use cases. For eg are you also creating the CP from CLI?

    To deploy a CP from CLI you can also use OO Shell (OOSH) CLI tool that is available with HPE OO.

    HTH,

    Lucian

  • Hi Guy, 

    I am working throught he following documentation now in regards to creating a deployment or deploying a content pack via OO REST API.

    https://lnast01pcache.saas.hpe.com/asset/resources/pd/oo/gcq1459954671/OO10.51_API_Guide.pdf 

    This guide is useful however it doesnt provide any details on the post REQUESTS that need to be made, it just lists the responses. 

    this makes it difficult to understand what the API expects in regards to data to facilitate an upload.

    I'm currently trying to find information on how to format my request in JSOn. This appears to be consistent for a lot of the calls in the above doco.

    Eg: Deploy Content Packs
    Request: PUT /content-packs/{cpFileName}

    Say I want to upload content pack "cp-xyz.jar" 

    Sure I can PUT https://<oocentral>:8443/oo/rest/v2/content-packs/cp-xyz

    but how do i specify the source file to PUT? The API guide lacks documentation on what to specify.

  • Hi Lucian, 

    My use case is I have pre-built Content packs available on a file share. 

    I wish to upload these to OO Central via REST, more specifically, from a centos host via CURL or some other utility and ensure the success via a response or return code.

    Managing dependancies are not such a big deal at this stage.

    I also understand the CSRF-TOKEN requirements in order to PUT/POST to OO.

    Thanks, 

    Andrew

     

  •  

    As you can see from the above screenshot, there are no details on how to define the body of your request to go along with the PUT request. 

    Any pointers are appreciated.

    Thanks.

  • Hi,

    The body is not JSON, but rather the CP file itself.

    Exactly how the file should be formatted, depends on which deployment API you use:

    • In the simpler API, which you referenced, the file should be transfered as a raw stream of bytes. This can be done programmatically.

    • There is also the more advanced "deplyoment with progress" API. In that API, you first create a new deployment process, then add one or more CP files to it, then start the deployment, and finally query it to check its progress.

      In this API, CP files should be added to the body according to the "multipart/form-data" standard (RFC 2388), which is the standard used for uploading files in webpages. This can be done programmatically or through a REST client that supports file upload.


    HTH,
    Rotem

  • As an example to what Rotem mentioned

    In the Rest Client with upload support your PUT call could look like this

     

    PUT /content-packs/{cpFileName}Hope it helps,

    Andrei

     

  • Yea the documentation wasn't that helpful with content pack deployment. I did get it working with python and requests. Something like this:

    import requests
    
    url='https://<OO server>:8443/oo/rest/v2/content-packs/<ContentPackName>'
    myheaders={"Content-Type": "application/json"}
    files = open('c:\\Content Packs\\<ContentPackName>.jar', 'rb')
    r= requests.put(url,data=files,verify=False,auth=('admin','password'),headers=myheaders)

     edit: you don't need to import json

  • Rotem, Andrei and Peter, 

    Thank you all for highlighting this process to me. I've done some work with API's and restful interfaces but not a great deal. This helps me considerably and will attempt to code this part of my script today. I'm using Postman to help interact with the REST interface and it wasn't immediately obvious how to add a file as part of a put command. Knowing now how it operates I'll look for this functionality specifically.

    Thanks again.

    Andrew