Deploy Your Blueprint

To request the deployment of a blueprint, you use the Blueprint APIs to make a POST request with the blueprint ID as input.

The prerequisites of this task call for verifying that you have the blueprint ID of the blueprint you want to deploy. In addition, this procedure includes an optional step to deploy a blueprint without a blueprint ID by providing contents inline instead.

Prerequisites

Procedure

  1. Assign the blueprint ID variable.
    blueprint_id='<your_blueprint_id>'
  2. To deploy a blueprint, assign variables for image mapping and flavor mapping.
    image_mapping='<your_image_mapping_name>'
    flavor_mapping='<your_flavor_mapping_name>'
    

    The image mapping specifies the OS image for a VM. The flavor mapping specifies the CPU count and RAM of a VM.

  3. Request a deployment of a blueprint.
    curl -X POST \
      $url/blueprint/api/blueprint-requests?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" \
      -H 'Content-Type: application/json' \
      -d '{
        "description": "requesting deployment from blueprint",
        "blueprintId": "'"$blueprint_id"'",
        "inputs": {
              "count": 2,
            "image":"'"$image_mapping"'",
            "flavor":"'"$flavor_mapping"'"
        }
    }' | jq "."
    
  4. Examine the response to get the blueprint request ID and the deployment ID.
  5. Assign the blueprint request ID and the deployment ID.
    blueprint_request_id='<your_blueprint_request_id>'
    deployment_id='<your_deployment_id>'
  6. (Optional) If you do not have a blueprint ID, you can also request a blueprint deployment with contents inline.
    1. Validate the blueprint before creating it.
      curl -X POST \
        $url/blueprint/api/blueprint-validation?apiVersion=$api_version \
        -H 'Content-Type: application/json' \
        -H "Authorization: Bearer $access_token"  \
        -d '{
          "name" : "'"$blueprint_id"'",
          "description" : "Basic Cloud Machine blueprint",
          "content" : "formatVersion: 1\ninputs:\n  flavor:\n    type: string\n    title: Flavor\n    description: Flavor Mapping Name\n  image:\n    type: string\n    title: Image\n    description: Image Mapping Name\n  count:\n    type: integer\n    minimum: 1\n    default: 1\n    maximum: 2\n    title: Number of Instances\nresources:\n  BasicCloudMachine:\n    type: Cloud.Machine\n    properties:\n      name: BasicCloudMachine\n      flavor: '\''${input.flavor}'\''      \n      image: '\''${input.image}'\''\n      count: '\''${input.count}'\''",
          "projectId" : "'"$project_id"'",
          "requestScopeOrg": false
      }' | jq "."
    2. Examine the response to confirm that you see "valid":true.
    3. Request the blueprint deployment.
      curl -X POST \
        $url/blueprint/api/blueprint-requests \
        -H "Authorization: Bearer $access_token" \
        -H 'Content-Type: application/json' \
        -d '{
          "description": "requesting deployment from inline blueprint",
          "projectId": "'"$project_id"'",
          "inputs": {
                "count": "2",
              "image":"'"$image_mapping"'",
              "flavor":"'"$flavor_mapping"'"
          },
          "content" : "formatVersion: 1\ninputs:\n  flavor:\n    type: string\n    title: Flavor\n    description: Flavor Mapping Name\n  image:\n    type: string\n    title: Image\n    description: Image Mapping Name\n  count:\n    type: integer\n    minimum: 1\n    default: 1\n    maximum: 2\n    title: Number of Instances\nresources:\n  BasicCloudMachine:\n    type: Cloud.Machine\n    properties:\n      name: BasicCloudMachine\n      flavor: '\''${input.flavor}'\''      \n      image: '\''${input.image}'\''\n      count: '\''${input.count}'\''"
      }' | jq "."
  7. Look up the status of the blueprint deployment.
    curl -X GET \
      $url/api/blueprint-requests/$blueprint_request_id?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" | jq "."

Example: Deploy a Blueprint

For a blueprint with ID 1f170637-81a3-4257-b1cd-b2219ee8034c, request the deployment with image mapping set to ubuntu and flavor mapping set to small.

Assign variables.

$ url='https://appliance.domain.com'
$ api_version='2019-09-12'
$ blueprint_id='1f170637-81a3-4257-b1cd-b2219ee8034c'
$ image_mapping='ubuntu'
$ flavor_mapping='small'

Request the deployment of a blueprint.

$ curl -X POST \
  $url/blueprint/api/blueprint-requests?apiVersion=$api_version \
  -H "Authorization: Bearer $access_token" \
  -H 'Content-Type: application/json' \
  -d '{
    "description": "requesting deployment from blueprint",
    "blueprintId": "'"$blueprint_id"'",
    "inputs": {
          "count": 2,
        "image":"'"$image_mapping"'",
        "flavor":"'"$flavor_mapping"'"
    }
}' | jq "."

A snippet of the response shows the blueprint request ID, the deployment ID, and the blueprint ID.

{  
  "id": "889f95a8-79a3-4b2f-b19e-32d1536dd69a",
  "createdAt": "2019-10-11T00:11:55.544Z",
...
  "projectName": "Example-project",  
  "deploymentId": "15454178-63fc-42ea-b4ad-7ed8a5cdb128",
  "requestTrackerId": "889f95a8-79a3-4b2f-b19e-32d1536dd69a",
...
  "blueprintId": "1f170637-81a3-4257-b1cd-b2219ee8034c",
...

Assign the blueprint request ID variable.

$ blueprint_request_id='889f95a8-79a3-4b2f-b19e-32d1536dd69a'

Request the status of the deployment.

$ curl -X GET \
  $url/blueprint/api/blueprint-requests/$blueprint_request_id?apiVersion=$api_version \
  -H "Authorization: Bearer $access_token" | jq "."

A snippet of the response shows the blueprint request ID and the blueprint ID with the status of the deployment request. If the deployment fails, the failure message indicates the reason for the failure.

{
  "id": "889f95a8-79a3-4b2f-b19e-32d1536dd69a"
  ...  
  "blueprintId": "1f170637-81a3-4257-b1cd-b2219ee8034c",
  "inputs": {
    "count": 2,
    "image": "ubuntu",
    "flavor": "small"
  },
  "status": "FINISHED",
...

What to do next

Use the deployment ID to look up resource information for your deployment.