Add Instance Package VS

To add a preconfigured VS, use the following request:

POST /virtual_machines.xml
POST /virtual_machines.json

This section describes the API request that adds a VS using instance packages. For information on the API request that adds a VS and sets its resources, refer to Add VS.

XML Request Example

curl -i -X POST -H 'Accept: application/xml' -H 'Content-type: application/xml' -u user:userpass -d '<virtual_machine><template_id>8</template_id><label>zaza</label><hostname>zaza</hostname><initial_root_password>ehgebhewvtwh</initial_root_password><instance_package_id>3</instance_package_id><location_group_id>12</location_group_id><licensing_server_id>38</licensing_server_id><licensing_type>kms</licensing_type><licensing_key>keyexample</licensing_key><required_ip_address_assignment>1</required_ip_address_assignment><required_automatic_backup>0</required_automatic_backup><required_virtual_machine_build>1</required_virtual_machine_build><required_virtual_machine_startup>1</required_virtual_machine_startup><time_zone>Atlantic Time (Canada)</time_zone><enable_autoscale>0</enable_autoscale><custom_recipe_variables><custom_recipe_variable><name>varname</name><value>value</value><enabled>1</enabled><recipe_ids type='array'><recipe_id>11</recipe_id></recipe_ids></custom_recipe_variable></custom_recipe_variables></virtual_machine>' --url http://onapp.test/virtual_machines.xml

JSON Request Example

curl -i -X POST -H 'Accept: application/json' -H 'Content-type: application/json' -u user:userpass -d '{"virtual_machine":{"template_id":"8", "label":"zaza", "hostname":"zaza","licensing_server_id":"38","licensing_type":"kms","licensing_key":"keyexample", "initial_root_password":"tyrhsghj657th", "instance_package_id":"3", "location_group_id":"12", "required_ip_address_assignment":"1", "required_automatic_backup":"0", "required_virtual_machine_build":"1", "required_virtual_machine_startup":"1", "time_zone": "Atlantic Time (Canada)", "enable_autoscale":"0","recipe_ids":["11"],"custom_recipe_variables":{"custom_recipe_variable":{"name":"varname","value":"var_value","enabled":"1"}}}}' --url http://onapp.test/virtual_machines.json


hostname* - set the host name for this VS

instance_package_id - ID of the instance package that will be used to build the VS

label* - user-friendly VS description

location_group_id - set the ID of the location group where the VS should be created

type_of_format - type of filesystem - ext4. For Linux templates, you can choose ext4 file system instead of the ext3 default one

required_automatic_backup - set 1 if you need automatic backups

required_virtual_machine_build * - set 1 to build VS automatically

required_virtual_machine_startup - set 1 to start up the VS automatically, otherwise set 0 (default state is "1")

time_zone - the time zone set for the VS. This parameter is applicable only to Windows virtual servers.

Currently, the time zone is set at the Compute resource side only. Therefore, users need to set the target time zone inside a Windows VS manually. Setting correct time zone at the Compute resource side helps to keep correct time inside a VS after starting it if time synchronization is not completed for some reason.

required_ip_address_assignment* - set "1" if you want VS to be created with already assigned IP address, otherwise set "0"; IP address can be assigned after VS creation using this API request 

admin_note - enter a brief comment for the VS. Optional parameter

note - a brief comment a user can add to a VS

template_id * - the ID of a template from which a VS should be built

licensing_server_id * - the ID of a template group where the KMS server details are indicated and to which the template belongs (either directly or through the child group). This parameter is for Windows virtual machines with KMS licensing type only

licensing_type * - the type of a license: makkms or user own license. This parameter is required for Windows virtual machines only

licensing_key * - the key of a license, required if you have selected own licensing type, and not required for MAK and KMS licensing types

initial_root_password - the root password for a VS. Optional, if none specified, the system will provide a random password. It can consist of 6-32 characters, letters [A-Za-z], digits [0-9], dash [ - ] and lower dash [ _ ], and the following special characters: ~ ! @ # $ * _ - + = ` \\ { } [ ] : ; ' , . ? /. You can use both lower- and uppercase letters.

The following characters are not allowed for Windows-based virtual servers:

  • percent sign [%]
  • double quotation marks [“]
  • brackets [<,>]
  • vertical bar [|]
  • caret [^]
  • ampersand [&]
  • parentheses [(,)]

initial_root_password_encryption_key - specify the password encryption passphrase

recipe_ids - an array of recipe ID you want to run on the virtual server provisioning

custom_variables - an array of custom variables with the following details:

  • enabled - true, if the variable is enabled, otherwise false
  • id - variable ID
  • name - variable name
  • value - variable value script