Calm Cookbook – Recipe #1 – Blueprint Import

Calm Cookbook - Recipe #1 - Blueprint Import

Written by Laura Jordana, Technical Marketing Engineer at Nutanix

While working on a recent project, I came across a need to automate certain operations in Calm. One of these operations was to automate the import/upload of a blueprint within Calm. Of course, we can easily do this in Prism by clicking on Blueprints > Upload Blueprint and selecting our file from within the Calm UI. But how can we automate this? Let’s take a look.

Before getting started, here’s a quick overview of the environment and tools used to prepare this recipe.

  • Calm 2.9.0
  • Prism Central 5.11
  • Postman 7.12
  • Python 3.7.5

Nutanix Calm REST API Documentation

Before diving too deep into the APIs themselves, please be aware of the Nutanix Calm REST API documentation. All currently available GA APIs are covered there, including examples of each. Please bookmark or save as it is where documentation updates for all Nutanix REST APIs will be published first.

Import a Blueprint

We’ll be using the blueprints API, more specifically, the “Upload blueprint” endpoint. This endpoint will allow us to pass the file in as an object. Note that there is also an “Import blueprint” endpoint. “Import blueprint” requires the raw JSON content to be passed.

Let’s take a look at the requirements.

First, we will need the Project UUID, as a blueprint needs to be associated with a specific project. 

We’ll also need the desired name of the blueprint.

Finally, the blueprint file should exist on the system the API call is being made from.

To summarize, the following inputs will be required:

  • Project UUID
  • Desired blueprint name
  • Path to blueprint file

Getting the Project UUID

So how do we get the Project UUID? You can get this directly from Prism as shown in the screenshot below, or you can issue an API call to the projects list endpoint with a payload of {“kind”: “project”, “filter”: “name=={{PROJECT_NAME}}” }. From there, you can filter out the UUID from the response.

Example using curl and jq:

curl -s -k -X POST https://$prism_central_ip_address:9440/api/nutanix/v3/projects/list -H 'Content-Type: application/json' --user admin:$password -d '{"kind": "project", "filter": "name==$project_name"}' | jq -r '.entities[].metadata.uuid'

Once we have the project UUID, we can now make our call to import the blueprint.

Import the Blueprint

To import the blueprint, we’ll be using the upload blueprint endpoint. 

 ------{boundary value}
 Content-Disposition: form-data; name="file"; filename="blob"
 Content-Type: application/json
 ------{boundary value}
 Content-Disposition: form-data; name="name"
 ------{boundary value}
 Content-Disposition: form-data; name="project_uuid"
 ------{boundary value} 

Now I know what you’re thinking, you just wanted a method to pass in a file object, so why would you want to mess with a complicated payload and boundary values?

There are a few ways to do this easily. Please note the use of variables in the below examples. If you are following this article in your own environment, please make sure you change these to values appropriate for you.


  • Create a new request and configure it as a POST request as shown here.
  • Set Authorization as “Basic Auth” and enter the Prism credentials.
  • Under Body, select the form-data radio button.
    • Under the Key column, type in file, and select the File type from the drop-down.
  • For the Value column on the same row, click Select Files and choose the location of your blueprint.
  • Enter in two more keys and their values as follows:
    • name: {{desired_blueprint_name}}
    • project_uuid: {{project_uuid}}
  • Click Send.

Note that we don’t actually have to define the header as Postman will do this for us.

A successful response will be quite large and will have the newly imported blueprint UUID shown at the bottom.

If we look at this blueprint in Prism, we can see it was successfully imported and is in Draft mode.


We can also do this in Python with the requests module. We’ll use the files parameter, along with the relevant details (blueprint_name and project_uuid):

file_to_upload = {'file': open(bp_file, 'rb')}
data = {'name': bp_name, 'project_uuid': project_uuid }
import_resp =, auth=AUTH_TYPE, files=file_to_upload, data=data, verify=False)

A full working script can be found here (be sure to replace the values in the script with the values that match your environment):


With curl we can use the -F parameter for passing form data.

A sample curl command:

curl -s -k -X POST $url -F file=@$path_to_file -F name=$bp_name -F project_uuid=$project_uuid --user admin:"$password"

Demo Video Using Postman

Stay tuned for our next post where we will configure the blueprint so it is ready to launch!