Create VM from custom images, API only
1. Create a standalone block storage disk from URL
curl https://<api-hostname>/v1/storage/disk-from-image \
-H 'apikey: [apikey]' \
-X POST \
-d "size_gb=[image size or bigger]" \
-d "image_url=[image url]" \
-d "billing_account_id=[billing_account_id]"
uuid
from the response is needed to check if the created custom image disk status
has changed from Reserved
to Active.
Image URL must point to a downloadable disk image. Image is expected to be in a format that qemu-img
automatically detects, e.g. raw or qcow2.
2. Check newly created VM disk status
curl https://<api-hostname>/v1/storage/disk/<uuid> \
-H 'apikey: [apikey]' \
-X GET
status | description |
---|---|
| Initial status. Disk is not usable yet. |
| Disk has been created as requested. It can now be used. |
| Disk is deleted after creating it from external image fails for some reason. This disk is not usable anymore. |
3. Create VM from available custom Image
curl --request POST 'https://<api-hostname>/v1/user-resource/vm' \
--header 'apikey: [apikey]' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'name=[Name for the VM]' \
--data-urlencode 'ram=[512]' \
--data-urlencode 'vcpu=[1]' \
--data-urlencode 'password=[password]' \
--data-urlencode 'username=[username]' \
--data-urlencode 'billing_account_id=[billing_account_id]' \
--data-urlencode 'boot=false' \
--data-urlencode 'disk_uuid=[uuid from Get Disk]'
Setting boot=false
is useful to debug VM's first boot. With this setting, VM is created without booting it, then in UI Virtual Console can be opened before pressing Start to monitor the first boot and resolve any possible errors.
Otherwise if VM boot fails during VM create, the VM and its disk will be deleted and there would be no way of knowing why it failed. Also, because the disk is deleted, it cannot be used to create a new VM, the image would have to be imported again.
Steps in UI
Refresh the Compute list
Start VM created from custom image
Check the boot process in the Virtual Console tab
Issues with the current pipeline
qemu-guest-agent has to be installed for the setup
If guest agent does not answer in 10 minutes, then boot fails and VM is stopped
In Create VM stage, the size of the disk cannot be changed/altered any more
Importing images that are bigger than ~35 GB will probably fail