Create vApp with Guest Customization and Recipes

To create a vApp, use the following request:

1
2
POST /vapps.xml
POST /vapps.json

XML Request Example

1
curl -i -X POST -u user:userpass http://onapp.test/vapps.xml -H 'Accept: application/xml' -H 'Content-Type: application/xml' -d '<vapp><name>ExampleVApp</name><vdc_id>2</vdc_id><vapp_template_id>5</vapp_template_id><virtual_machines><virtual_machine_0><id>4632-88dd-03fbfa33f0c0</id><name>VM1</name><cpus>2</cpus><cores_per_socket>1</cores_per_socket><memory>512</memory><hard_disks><hard_disk_1><disk_space>6</disk_space><storage_policy>3</storage_policy></hard_disk_1><hard_disk_2><disk_space>1</disk_space><storage_policy>3</storage_policy></hard_disk_2></hard_disks><nics><nic_0><network_id></network_id></nic_0></nics><vcloud_guest_customization><computer_name>vm-1</computer_name><enabled>true</enabled><admin_password_enabled>true</admin_password_enabled><admin_password>23</admin_password></vcloud_guest_customization><recipe_ids type="array"><recipe_id>3</recipe_id></recipe_ids><custom_recipe_variables><variable_0><name>x</name><value>1</value><enabled>true</enabled></variable_0><variable_1><name>y</name><value>2</value><enabled>false</enabled></variable_1></custom_recipe_variables><disable_guest_customization_after_run>false</disable_guest_customization_after_run><boot_vm>true</boot_vm></virtual_machine_0><virtual_machine_1><id>4bb5-b124-15700d40073b</id><name>VM2</name><cpus>4</cpus><cores_per_socket>2</cores_per_socket><memory>1024</memory><hard_disks><hard_disk_1><disk_space>31</disk_space><storage_policy>3</storage_policy></hard_disk_1></hard_disks><nics><nic_0><network_id>4</network_id></nic_0></nics><vcloud_guest_customization><computer_name>vm-2</computer_name><enabled>true</enabled><admin_password_enabled>true</admin_password_enabled><admin_password_auto>true</admin_password_auto></vcloud_guest_customization><recipe_ids type="array"><recipe_id>1</recipe_id><recipe_id>2</recipe_id></recipe_ids><disable_guest_customization_after_run>true</disable_guest_customization_after_run><boot_vm>false</boot_vm></virtual_machine_1></virtual_machines></vapp>'

JSON Request Example

1
curl -i -X POST -u user:userpass http://onapp.test/vapps.json -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"vapp": {"name": "ExampleVApp", "vdc_id": 2, "vapp_template_id": 5, "virtual_machines": {"virtual_machine_0": {"id": "vm-88dd-03fbfa33f0c0", "name": "VM1", "cpus": 2, "cores_per_socket": 1, "memory": 512, "hard_disks": {"hard_disk_1": {"disk_space": 6, "storage_policy": 3}, "hard_disk_2": {"disk_space": 1, "storage_policy": 3}}, "nics": {"nic_0": {"network_id": ""}}, "vcloud_guest_customization": {"computer_name": "vm-1", "enabled": "true", "admin_password_enabled": "true", "admin_password": "23"}, "recipe_ids": [3], "custom_recipe_variables": {"variable_0": {"name": "x", "value": 1, "enabled": "true"}, "variable_1": {"name": "y", "value": 2, "enabled": "false"}}, "disable_guest_customization_after_run": "false", "boot_vm": "true"}, "virtual_machine_1": {"id": "b124-15700d40073b", "name": "VM2", "cpus":4, "cores_per_socket": 2, "memory": 1024, "hard_disks": {"hard_disk_1": {"disk_space": 31, "storage_policy": 3}}, "nics": {"nic_0": {"network_id": 4}}, "vcloud_guest_customization": {"computer_name": "vm-2", "enabled": "true", "admin_password_enabled": "true", "admin_password_auto": "true"}, "recipe_ids": [1, 2], "disable_guest_customization_after_run": "true", "boot_vm": false}}}}'

Where:

  • name - name of the vApp
  • vdc_id - ID of the datacenter on which the vApp will be created
  • vapp_template_id - ID of the template on which the vApp will be built
  • virtual_machines - array of parameters associated with the VSs
    • id - ID of the VS
    • name -choose a name for the VS
    • cpus - set the number of cores
    • cores_per_socket - set the number of cores per socket
    • memory - the amount of RAM allocated to this VS in Mb
    • storage_policy - the virtual server’s storage policy
    • hard_disks - array of parameters associated with the VS disks
      • disk_space - set the disk’s size
      • storage_policy - the disks’s storage police
    • nics - array of parameters associated with the NICs
      • network_id - the ID of the network to which the NIC will be connected
    • vcloud_guest_customization - array of parameters associated with guest customization
      • computer_name - VS’s computer name
      • enabled - set true if guest customization should be enabled for the VS, otherwise, set false
      • admin_password_enabled - set true if the local admin password should be allowed, otherwise; set false
      • admin_password - enter the password of the administrator
      • admin_password_auto - set true if the admin password should be generated automatically; otherwise, set false
        If you set the admin_password_auto parameter to true, Resync vCloud VS after creating the vApp with guest customization to be able to view the password.
    • recipe_ids - the IDs of the recipes that are to be applied to the VS
    • custom_recipe_variables - array of parameters associated with custom variables
      • name - the name of the custom variable
      • value - the value of the custom variable
      • enabled - set to true if the custom variable should be enabled; otherwise, set false
    • disable_guest_customization_after_run - set true if guest customization for this VS should be disabled after vApp deployment; otherwise, set false
    • boot_vm - set true if the VS should be switched on after vApp deployment; otherwise, set false