15.5. Methods
15.5.1. Creating a Virtual Machine
name, template, and cluster elements. Identify the template and cluster elements with the id attribute or name element. Identify the CPU profile ID with the cpuprofiles attribute.
Example 15.4. Creating a virtual machine with 512 MB that boots from CD-ROM
POST /api/vms HTTP/1.1
Accept: application/xml
Content-type: application/xml
<vm>
<name>vm2</name>
<description>Virtual Machine 2</description>
<type>desktop</type>
<memory>536870912</memory>
<cluster>
<name>default</name>
</cluster>
<template>
<name>Blank</name>
</template>
<os>
<boot dev="cdrom"/>
</os>
<cdroms>
<cdrom>
<file id="example_windows_7_x64_dvd_u_677543.iso"/>
</cdrom>
</cdroms>
<cpu_profile id="0000001a-001a-001a-001a-00000000035e"/>
</vm>
Example 15.5. Creating a virtual machine with 512 MB that boots from a virtual hard disk
POST /api/vms HTTP/1.1
Accept: application/xml
Content-type: application/xml
<vm>
<name>vm2</name>
<description>Virtual Machine 2</description>
<type>desktop</type>
<memory>536870912</memory>
<cluster>
<name>default</name>
</cluster>
<template>
<name>Blank</name>
</template>
<os>
<boot dev="hd"/>
</os>
<cpu_profile id="0000001a-001a-001a-001a-00000000035e"/>
</vm>
Note
15.5.2. Updating a Virtual Machine
name, description, cluster, type, memory, cpu, os, high_availability, display, timezone, domain, stateless, placement_policy, memory_policy, usb, payloads, origin and custom_properties elements are updatable post-creation.
Example 15.6. Updating a virtual machine to contain 1 GB of memory
PUT /api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Accept: application/xml
Content-type: application/xml
<vm>
<memory>1073741824</memory>
</vm>
Note
Note
Example 15.7. Hot plugging vCPUs
PUT /api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Accept: application/xml
Content-type: application/xml
<vm>
<cpu>
<topology>
<sockets>4</sockets>
<cores>2</cores>
<threads>2</threads>
</topology>
</cpu>
</vm>Note
Example 15.8. Pinning a virtual machine to multiple hosts
PUT /api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Accept: application/xml
Content-type: application/xml
<vm>
<high_availability>
<enabled>true</enabled>
<priority>1</priority>
</high_availability>
<placement_policy>
<hosts>
<host><name>Host1</name></host>
<host><name>Host2</name></host>
</hosts>
<affinity>pinned</affinity>
</placement_policy>
</vm>15.5.3. Removing a Virtual Machine
DELETE request.
Example 15.9. Removing a virtual machine
DELETE /api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1 HTTP/1.1 204 No Content
15.5.4. Removing a Virtual Machine but not the Virtual Disk
DELETE request.
Example 15.10. Removing a virtual machine
DELETE /api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Accept: application/xml
Content-type: application/xml
<action>
<vm>
<disks>
<detach_only>true</detach_only>
</disks>
</vm>
</action>

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.