3.11. Example: Create Virtual Machine The following example creates a virtual machine called vm1 on the Default cluster using the virtualization environment's Blank template as a basis. The request also defines the virtual machine's memory as 512 MB and sets the boot device to a virtual hard disk. Example 3.13. Create a virtual machine Request: cURL command: Result:

Commands:
POST /ovirt-engine/api/vms HTTP/1.1 Accept: application/xml Content-type: application/xml <vm> <name>vm1</name> <cluster> <name>default</name> </cluster> <template> <name>Blank</name> </template> <memory>536870912</memory> <os> <boot dev="hd"/> </os> <cpu_profile id="0000001a-001a-001a-001a-00000000035e"/> </vm>
curl -X POST -H "Accept: application/xml" -H "Content-Type: application/xml" -u [USER:PASS] --cacert [CERT] -d "<vm><name>vm1</name><cluster><name>default</name></cluster><template><name>Blank</name></template><memory>536870912</memory><os><boot dev='hd'/></os><cpu_profile id='0000001a-001a-001a-001a-00000000035e'/></vm>" https:// [RHEVM Host] :443/ovirt-engine/api/vms
HTTP/1.1 200 OK Accept: application/xml <vm id="6efc0cfa-8495-4a96-93e5-ee490328cf48" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48"> <name>vm1</name> <actions> <link rel="shutdown" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/shutdown"/> <link rel="start" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/start"/> <link rel="stop" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/stop"/> <link rel="reboot" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/reboot"/> <link rel="suspend" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/suspend"/> <link rel="detach" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/detach"/> <link rel="export" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/export"/> <link rel="move" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/move"/> <link rel="ticket" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/ticket"/> <link rel="migrate" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/migrate"/> <link rel="undo_snapshot" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/undo_snapshot"/> <link rel="commit_snapshot" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/commit_snapshot"/> <link rel="preview_snapshot" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/preview_snapshot"/> <link rel="logon" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/logon"/> <link rel="cancelmigration" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/cancelmigration"/> <link rel="maintenance" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/maintenance"/> <link rel="clone" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/clone"/> </actions> <link rel="applications" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/applications"/> <link rel="disks" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/disks"/> <link rel="nics" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/nics"/> <link rel="cdroms" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/cdroms"/> <link rel="snapshots" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/snapshots"/> <link rel="tags" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/tags"/> <link rel="permissions" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/permissions"/> <link rel="statistics" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/statistics"/> <link rel="reporteddevices" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/reporteddevices"/> <link rel="watchdogs" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/watchdogs"/> <link rel="sessions" href="/ovirt-engine/api/vms/6efc0cfa-8495-4a96-93e5-ee490328cf48/sessions"/> <type>desktop</type> <status> <state>down</state> </status> <memory>536870912</memory> <cpu> <topology cores="1" sockets="1"/> </cpu> <os type="Unassigned"> <boot dev="cdrom"/> </os> <high_availability> <enabled>false</enabled> <priority>0</priority> </high_availability> <display> <type>spice</type> <monitors>1</monitors> <single_qxl_pci>false</single_qxl_pci> <allow_override>false</allow_override> <smartcard_enabled>false</smartcard_enabled> <file_transfer_enabled>true</file_transfer_enabled> <copy_paste_enabled>true</copy_paste_enabled> </display> <cluster id="99408929-82cf-4dc7-a532-9d998063fa95" href="/ovirt-engine/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95"/> <template id="00000000-0000-0000-0000-000000000000" href="/ovirt-engine/api/templates/00000000-0000-0000-0000-000000000000"/> <stop_time>2011-06-15T04:48:02.167Z</stop_time> <creation_time>2011-06-15T14:48:02.078+10:00</creation_time> <origin>rhev</origin> <stateless>false</stateless> <delete_protected>false</delete_protected> <sso> <methods> <method id="GUEST_AGENT"/> </methods> </sso> <console enabled="false"/> <timezone>Etc/GMT</timezone> <initialization> <configuration> <type>ovf</type> <data>...</data> </configuration> </initialization> <placement_policy> <affinity>migratable</affinity> </placement_policy> <memory_policy> <guaranteed>536870912</guaranteed> <ballooning>true</ballooning> </memory_policy> <usb> <enabled>false</enabled> </usb> <soundcard_enabled>true</soundcard_enabled> <migration_downtime>-1</migration_downtime> <virtio_scsi enabled="true"/> <cpu_profile id="0000001a-001a-001a-001a-00000000035e"/> <next_run_configuration_exists>false</next_run_configuration_exists> <numa_tune_mode>interleave</numa_tune_mode> </vm>