Pivotal Knowledge Base

Follow

How to download and upload Pivotal Cloud Foundry® products via API

Environment 

Product Version
Pivotal Cloud Foundry® (PCF) Ops Manager  1.6, 1.7, 1.8, 1.9

Purpose

This article illustrates how users can download and upload PCF products via API.

Instructions

  1. Log on to network.pivotal.io.
  2. Click on your name tab and select "Edit Profile" to get your "API TOKEN" keys. You'll need to use the keys to download any products using wget.
  3. Click on the "PRODUCTS" tab and look for the release you want to download. 
  4. Click on the letter "i" icon next to the product file name to get the "File Name" and "API Download" URL.

For example:

File Name: cf-1.6.17.pivotal
API URL: https://network.pivotal.io/api/v2/products/elastic-runtime/releases/1530/product_files/3974/download

Notes:

Before you're authorized to download a product release from Pivotal Network, you must first accept a product release EULA.  You only need to accept the EULA one time, the first you download a product release.

To accept the EULA, you can click on a product release download link, and click "Agree" on a product release's EULA popup page or you can accept a product release's EULA via POST /api/v2/products/:product_slug/releases/:release_id/eula_acceptance.

For example: 

$ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Token <TOKEN_KEYS_FROM_STEP2>" -X POST https://network.pivotal.io/api/v2/products/:product_slug/releases/:release_id/eula_acceptance

For complete reference on Accept EULA, see Pivotal Network Download API https://network.pivotal.io/docs/file_download_api

     5.  SSH into Ops Manager and download a PCF file using REST API with wget.

$ wget --post-data="" --header="Authorization: Token <TOKEN_KEYS_FROM_STEP2>" https://network.pivotal.io/api/v2/products/elastic-runtime/releases/1530/product_files/3974/download -O "cf-1.6.17.pivotal"

On Ops Manager 1.6.x

Upload (Import) cf-1.6.17.pivotal file to Ops Manager 1.6 using REST API with curl command:

$ curl -v -k "https://localhost/api/products" -F 'product[file]=@/path/to/cf-1.6.17.pivotal' -X POST -u ops-manager-admin:password 

Notes:

    • The @ sign is required when specifying the path to the product file.  
    • The -k option is only required if you need to skip SSL certification validation when the server is using a signed certificate.
    • Once the upload is completed, it will be available on the Ops Manager Web UI to be added.
    • Change the URL from localhost to Ops Manager DNS name, if you are not running the curl command from the Ops Manager VM.

On Ops Manager 1.7.x and greater

Ops Manager 1.7 authentication is now done via UAA.  The API with curl command is different from Ops Manager 1.6 that's using the Basic Auth, an additional step is required to upload the product tile.

First, you need to obtain the UAA <access_token> string with the following curl command:

$ curl -s -k -H 'Accept: application/json;charset=utf-8' -d 'grant_type=password' -d 'username=<web-ui-username>' -d 'password=<web-ui-pass>' -u 'opsman:' https://localhost/uaa/oauth/token

{"access_token":"eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI2NjAzNjlmYy0yYTc5LTQwYmUtYmMzZi1lOTFkMzY1MjUwNDUiLCJzdWIiOiI5MWJlMmQ5NS01YTQ5LTRjMTktYTNmZS0yMTc1NzRhNDQzM2YiLCJzY29wZSI6WyJjbGllbnRzLnJlYWQiLCJvcHNtYW4udXNlciIsInVhYS5hZG1pbiIsInNjaW0ucmVhZCIsIm9wc21hbi5hZG1pbiIsImNsaWVudHMud3JpdGUiLCJzY2ltLndyaXRlIl0sImNsaWVudF9pZCI6Im9wc21hbiIsImNpZCI6Im9wc21hbiIsImDpmbeVAwjz4bp0ieMo1KA-Xmk37RFKfK4R2d6f0RB-1ua9JpXkmFLZk5lKWQJsoeC_EBKSbxovU5fl0jjiGLWcLPAUIsGuVrcAhUFpoUnhu4hzgHzUUnTzV-1ngx1pzlel3kVKOyChyUxpFMvb3GS_q5Thi8k0tnwfEX4NWZJHIqr-86xQ0bmK4SANRvLPE1NwtcBTmJj4AUajqArJ6ChNgRk3RrHQrLc9Dmc3cHu2z0i5L2f-49ecoKf48RLIpobN84Xk9PKg","token_type":”bearer”...

Once you have the access token string, you can upload (Import) the product tile to Ops Manager using the following API with curl command:

$ curl -vv -H 'Authorization: bearer <access_token>' -k -X POST https://localhost/api/v0/available_products -F 'product[file]=@<path-to-product-tile>

Notes:

    • Replace <path-to-tile> with the full path to your PCF tile file.
    • Replace <web-ui-username> and <web-ui-pass> with your Ops Manager Web UI login username and password.
    • Replace <access_token> with a single long string of access_token obtained from the curl command in the red text for example.
    • Change the URL from localhost to Ops Manager DNS name, if you are not running the curl command from the Ops Manager VM.

 

Additional Information

For complete API documentation, check your Ops Manager installation docs https://<om-dns-name>/docs

For 3rd party python tool to download files from Pivotal Network and upload them to Ops Manager 1.6, check out https://github.com/mreider/gng.  The tool does not support Ops Manger 1.7 or greater.

Note that the API with curl command for uploading stemcell and release files for Ops Manager 1.6 are as follows:

  •  Stemcell:  curl -k "https://<om-dns-name>/api/stemcells" -F "stemcell[file]=@<path-to-stemcell-file>" -X POST -u <ops-manager-admin>:<password>
    • When uploading stemcells, you need to do this first before you select a tile to install with Ops Manager.
  • Release:  curl -k "https://<om-dns-name>/api/releases" -F "release[file]=@<path-to-release-file>" -X POST -u <ops-manager-admin>:<password>

Comments

Powered by Zendesk