Skip to main content

Provisioning Profiles

The Provisioning Profiles feature provides a practical solution for saving your virtual machine configurations for future use. It enables you to save configuration settings, such as flavors, environments, user data, and other customization options. This stored information can be easily reused when creating future VMs, streamlining the process and reducing the likelihood of errors. This feature is designed to enhance efficiency in VM deployment and eliminate the need to recreate VMs from scratch for consistent setups.


Profile operations

OperationsEndpoints
Create a profilePOST /core/profiles
Retrieve the list of profilesGET /core/profiles
Retrieve details about a profileGET /core/profiles/{id}
Delete a profileDELETE /core/profiles/{id}

Creating a Profile

To save a virtual machine configuration for future use, call the POST /core/profiles endpoint to create a provisioning profile. To create a profile simply provide a name, description, and the configuration of the virtual machine you wish to create a profile for, in the data object as seen below.

Select the virtual machine configuration features that meet your needs by following the instructions here.


Request body parameters

The following parameters must be sent in the body of the request:


name REQUIRED string

Name of the profile being created.
A string with a maximum length of 50 characters.


data REQUIRED string

The data object which contains the configuration of the virtual machine profile being created.

Show child parameters
environment_name REQUIRED string

Name of the environment for the virtual machine.


image_name REQUIRED string

Name of the image that you chose from the response of the GET /core/images endpoint.


flavor_name REQUIRED string

Name of the flavor (hardware configuration) for the virtual machine being saved in the profile.


key_name REQUIRED string

Name of the SSH key pair that was used to import an SSH key.


assign_floating_ip REQUIRED boolean

Designates whether or not to assign a public IP to the virtual machine. In this example assign_floating_ip is set to true, making the virtual machine publicly accessible using the SSH key pair. If you don't want your virtual machine to be publicly accessible, set the assign_floating_ip to false.


count REQUIRED integer

Number of virtual machines to be deployed.


create_bootable_volume optional boolean

Indicates whether or not to create a bootable volume for the virtual machine. Valid values are: true which creates a bootable volume, and false which does not create a bootable volume for the virtual machine. In this case no bootable volume is required so a value of false is used.


user_data optional string

Custom data or scripts to be executed during virtual machine deployment. A value of "" is used indicating that no custom data is required.

Learn more about user_data.


description optional string

The optional description for the profile being created.
A string with a maximum length of 150 characters.


Returns


The Profile object is returned which contains the ID, profile name, description if provided, and the data object which contains the virtual machine configuration saved as a profile.

This response indicates that a new provisioning profile named "profile-1" with an ID of "4" has been successfully created. This profile can be used in the future to create a virtual machine with the same configuration.


Request
curl -X POST "http://infrahub-api.nexgencloud.com/v1/core/profiles" \
-H "accept: application/json"\
-H "api_key: YOUR API KEY"\
-H "content-type: application/json" \
-d '{
"name": "profile-1",
"description": "This is an example profile.",
"data": {
"environment_name": "Test-env",
"image_name": "CentOS 9",
"volume_name": "",
"create_bootable_volume": "false",
"flavor_name": "n1-cpu-medium",
"key_name": "key pair -1",
"user_data": "",
"callback_url": "",
"assign_floating_ip": "false",
"count": "1"
}
}'
Response
{
"status": true,
"message": "Profile created successfully",
"profile": {
"description": "This is an example profile.",
"id": 4,
"name": "profile-1",
"data": {
"environment_name": "Test-env",
"image_name": "CentOS 9",
"volume_name": "",
"create_bootable_volume": false,
"flavor_name": "n1-cpu-medium",
"key_name": "key pair -1",
"user_data": "",
"callback_url": "",
"assign_floating_ip": false,
"count": 1
}
"created_at": "2023-05-19T08:45:58"
}
}


Using a provisioning profile to create a virtual machine

Retrieve a list of profiles

In order to use a provisioning profile to create a virtual machine with a saved configuration, call the GET /core/profiles endpoint to retrieve a list of existing profiles.


Parameters


No parameters.


Returns


Returns an array of virtual machine configuration profiles.


Request
curl -X GET "https://infrahub-api.nexgencloud.com/v1/core/profiles" \
-H "accept: application/json"\
-H "api_key: YOUR API KEY"
Response
{
"status": true,
"message": "Getting profiles success.",
"regions": [
{
"id": 4,
"name": "profile-1",
"data": {
"environment_name": "Test-env",
"image_name": "CentOS 9",
"volume_name": "",
"create_bootable_volume": false,
"flavor_name": "n1-cpu-medium",
"key_name": "key pair -1",
"user_data": "",
"callback_url": "",
"assign_floating_ip": false,
"count": 1
},
"description": "This is an example profile.",
"created_at": "2023-08-15T17:24:08"
}
{...}

Using a profile to create a VM

  1. Once you have accessed the list of virtual machine profiles, copy the name of the profile corresponding to the data object that contains your desired virtual machine configuration.

  2. The name of the profile you select will be used as the value within the profile_name field, in the body of the POST /core/virtual-machines request as shown in this example.


Profile object: POST /core/virtual-machines
{
...
"profile": {
"name": "profile-1"
"description": "Example description."
}
...
}

See instructions on how to create a new virtual machine using the POST /core/virtual-machines endpoint.


This process saves the user time and reduces the likelihood of error, by automatically applying previously saved settings to the VM, ensuring that it is configured exactly as desired.


See more information about the features of Infrahub virtual machines.


Back to top