How to create and configure a VMware Marketplace Resource using the Cloud Director OpenAPI
search cancel

How to create and configure a VMware Marketplace Resource using the Cloud Director OpenAPI

book

Article ID: 441236

calendar_today

Updated On:

Products

VMware Cloud Director

Issue/Introduction

  • If you want tenants to import applications from VMware Marketplace into VMware Cloud Director catalogs, you must create a VMware Marketplace resource and share it with one or more tenant organizations.
  • After creating the VMware Marketplace resource, you can share the configured
    VMware Marketplace
    resources with tenant organizations.

Environment

VMware Cloud Director 10.6.1.x

Resolution

The VMware Cloud Director OpenAPI Create Catalog Content Source request can be used to create a VMware Marketplace resource.

The VMware Cloud Director OpenAPI Update Access Control Grants request can be used to share the configured VMware Marketplace resources with tenant organizations after it has been created.

Example steps would be as follows:

  1. Before proceeding ensure you have a valid VMware Marketplace API token. You can generate the API token in the Broadcom Cloud Services Console. This API token will be used as the <marketplace_api_token> value in the API calls below.
  2. Log into the Cloud Director API as a System Administrator and retain the X-VMWARE-VCLOUD-ACCESS-TOKEN authentication token value for use in the subsequent API calls.
    Example login with Curl:

    curl -ksSL -D - -X POST https://<vcd_address>/cloudapi/1.0.0/sessions/provider -H "Accept: application/json;version=39.1" -u "administrator@system"

    Example X-VMWARE-VCLOUD-ACCESS-TOKEN response:

    X-VMWARE-VCLOUD-ACCESS-TOKEN: <vcd_token>

  3. Construct the JSON request body required to add the VMware Marketplace Content Source.
    NOTE: When adding the Content Source at the System level, the default Organization ID for System and the default User ID for the system user can be used.
    The default values of urn:vcloud:org:a93c9db9-7471-3192-8d09-a8f7eeda85f9 and urn:vcloud:user:07e746aa-1835-39f8-962a-717e352f5c6a are present in all Cloud Director installs and are not unique to a specific instance.
    The URL of VMware Marketplace is also currently https://eapi.broadcom.com/vcf/vsc/gtw/api/v1.
    Only the description, name, and apiToken need to be customised.

    {
        "url": "https://eapi.broadcom.com/vcf/vsc/gtw/api/v1",
        "description": "<description>",
        "sourceType": "VmwareMarketplace",
        "orgId": "urn:vcloud:org:a93c9db9-7471-3192-8d09-a8f7eeda85f9",
        "owner": {
            "name": "system",
            "id": "urn:vcloud:user:07e746aa-1835-39f8-962a-717e352f5c6a"
        },
        "name": "<name>",
        "apiToken": "<marketplace_api_token>"
    }

  4. Save the JSON for later use with the API, for example contentsource.json.
  5. Create Catalog Content Source by sending the constructed JSON.
    Example creation with curl:

    curl -kv -X POST https://<vcd_address>/cloudapi/1.0.0/catalogContentSources -H 'Accept: application/json;version=40.0.0-alpha' -H 'Content-Type: application/json' -H 'Authorization: Bearer <vcd_token>' -d @contentsource.json

    Successful response:
    201 Created

  6. Query Catalog Content Sources to confirm the Content Source has been created.
    Example get with curl:

    curl -k -X GET https://<vcd_address>/cloudapi/1.0.0/catalogContentSources -H 'Accept: application/json;version=40.0.0-alpha' -H 'Content-Type: application/json' -H 'Authorization: Bearer <vcd_token>'

  7. From the JSON response note the ID of the newly created Content Source.
    Example ID:

    urn:vcloud:catalogContentSource:########-####-####-####-############

  8. To use the VMware Marketplace Content Source in Tenant Organizations it will need to be shared with the desired Organizations by editing its access control list. Start by getting the current access control list for the Content Source using its ID.
    NOTE: For a newly created Content Source the list should be empty.
    Example get with curl:

    curl -k -X GET https://<vcd_address>/cloudapi/1.0.0/catalogContentSources/urn:vcloud:catalogContentSource:########-####-####-####-############/accessControls -H 'Accept: application/json;version=40.0.0-alpha' -H 'Content-Type: application/json' -H 'Authorization: Bearer <vcd_token>'

  9. Construct the JSON request body with the list of all Organizations by ID that should have access to the Content Source and the ID of the newly created Content Source.
    NOTE: The ID of a an Organization can be seen in the browser URL by opening it in the Cloud Director Provider portal, Resources > Cloud Resources > Organizations > click Organization name.
    Query Orgs can also be used as a System Administrator to get a list of all Organizations.
    Example JSON to allow read only access to two Organizations:

    {
        "values": [
            {
                "tenant": {
                    "id": "urn:vcloud:org:1234####-####-####-####-############"
                },
                "grantType": "MembershipAccessControlGrant",
                "objectId": "urn:vcloud:catalogContentSource:########-####-####-####-############",
                "accessLevelId": "urn:vcloud:accessLevel:ReadOnly",
                "memberId": "urn:vcloud:org:1234####-####-####-####-############"
            },
            {
                "tenant": {
                    "id": "urn:vcloud:org:5678####-####-####-####-############"
                },
                "grantType": "MembershipAccessControlGrant",
                "objectId": "urn:vcloud:catalogContentSource:########-####-####-####-############",
                "accessLevelId": "urn:vcloud:accessLevel:ReadOnly",
                "memberId": "urn:vcloud:org:5678####-####-####-####-############"
            }
        ]
    }

  10. Save the JSON for later use with the API, for example contentsourceaccess.json.
  11. Update Access Control Grants by sending the constructed JSON.
    Example update with curl:

    curl -kv -X PUT https://<vcd_address>/cloudapi/1.0.0/catalogContentSources/urn:vcloud:catalogContentSource:########-####-####-####-############/accessControls -H 'Accept: application/json;version=40.0.0-alpha' -H 'Content-Type: application/json' -H 'Authorization: Bearer <vcd_token>' -d @contentsourceaccess.json

    Successful response:
    200 OK

  12. The VMware Marketplace Content Source should now be available in the Organizations which have been provided access.