1. Operations
2. vcenter
3. vm
4. hardware
5. cdrom

## vcenter vm hardware cdrom: create

Adds a virtual CD-ROM device to the virtual machine.

### Request:

#### HTTP request

POST https://{server}/rest/vcenter/vm/{vm}/hardware/cdrom

#### Path Parameters

Name | Type | Description
--- | --- | ---
Required
vm | string | Virtual machine identifier.

#### Request Body Structure:

- JSON
- XML

{
"spec": {
"allow_guest_control": true,
"backing": {
"device_access_type": "EMULATION",
"host_device": "string",
"iso_file": "string",
"type": "ISO_FILE"
},
"ide": {
"master": true,
"primary": true
},
"sata": {
"bus": 1,
"unit": 1
},
"start_connected": true,
"type": "IDE"
}
}
<?xml version="1.0" ?>
<ns0:Create-Input xmlns:ns0="http://vmware.com/vcenter/vm/hardware/cdrom" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<spec>
<ide>
<primary>true</primary>
<master>true</master>
</ide>
<sata>
<unit>1</unit>
<bus>1</bus>
</sata>
<allow_guest_control>true</allow_guest_control>
<type>IDE</type>
<backing>
<device_access_type>EMULATION</device_access_type>
<iso_file>string</iso_file>
<type>ISO_FILE</type>
<host_device>string</host_device>
</backing>
<start_connected>true</start_connected>
</spec>
</ns0:Create-Input>

#### Request Body Parameters:

Name | Type | Description
--- | --- | ---
bold = required
spec | create_spec | Specification for the new virtual CD-ROM device.
spec.type | string | Type of host bus adapter to which the device should be attached. Optional. If unset, guest-specific default values will be used.
spec.ide | ide_address_spec | Address for attaching the device to a virtual IDE adapter. Optional. It is only relevant when type has value IDE. If unset, the server will choose an available address; if none is available, the request will fail.
spec.ide.primary | boolean | Flag specifying whether the device should be attached to the primary or secondary IDE adapter of the virtual machine. Optional. If unset, the server will choose a adapter with an available connection. If no IDE connections are available, the request will be rejected.
spec.ide.master | boolean | Flag specifying whether the device should be the master or slave device on the IDE adapter. Optional. If unset, the server will choose an available connection type. If no IDE connections are available, the request will be rejected.
spec.sata | sata_address_spec | Address for attaching the device to a virtual SATA adapter. Optional. It is only relevant when type has value SATA. If unset, the server will choose an available address; if none is available, the request will fail.
spec.sata.bus | long | Bus number of the adapter to which the device should be attached.
spec.sata.unit | long | Unit number of the device. Optional. If unset, the server will choose an available unit number on the specified adapter. If there are no available connections on the adapter, the request will be rejected.
spec.backing | backing_spec | Physical resource backing for the virtual CD-ROM device. Optional. If unset, defaults to automatic detection of a suitable host device.
spec.backing.type | string | Backing type for the virtual CD-ROM device. Defines the valid backing types for a virtual CD-ROM device. Value is one of: ISO_FILE: Virtual CD-ROM device is backed by an ISO file. HOST_DEVICE: Virtual CD-ROM device is backed by a device on the host where the virtual machine is running. CLIENT_DEVICE: Virtual CD-ROM device is backed by a device on the client that is connected to the virtual machine console.
spec.backing.iso_file | string | Path of the image file that should be used as the virtual CD-ROM device backing. Optional. It is only relevant when type has value ISO_FILE. This field is optional and it is only relevant when the value of `type` is ISO_FILE.
spec.backing.host_device | string | Name of the device that should be used as the virtual CD-ROM device backing. Optional. It is only relevant when type has value HOST_DEVICE. If unset, the virtual CD-ROM device will be configured to automatically detect a suitable host device.
spec.backing.device_access_type | string | Access type for the device backing. Optional. It is only relevant when type has value [HOST_DEVICE, CLIENT_DEVICE]. If unset, defaults to EMULATION.
spec.start_connected | boolean | Flag indicating whether the virtual device should be connected whenever the virtual machine is powered on. Optional. Defaults to false if unset.
spec.allow_guest_control | boolean | Flag indicating whether the guest can connect and disconnect the device. Optional. Defaults to false if unset.

### Response:

#### HTTP Status Code: 200

#### Representations:

- JSON
- XML

{
"value": "obj-103"
}
<?xml version="1.0" ?>
<ns0:Create-Result xmlns:ns0="http://vmware.com/vcenter/vm/hardware/cdrom" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<value>obj-103</value>
</ns0:Create-Result>

#### Response Type:

Name | Type | Description
--- | --- | ---
bold = required
value | string | Virtual CD-ROM device identifier.

#### Errors:

HTTP Status Code | Type | Description
--- | --- | ---
500 | error | if the system reported that the CD-ROM device was created but was unable to confirm the creation because the identifier of the new device could not be determined.
404 | not_found | if the virtual machine is not found.
400 | not_allowed_in_current_state | if the virtual machine is suspended or if the virtual machine is powered on and virtual CD-ROM type is IDE.
400 | unable_to_allocate_resource | if the specified storage address is unavailable; for example, if the SCSI adapter requested does not exist.
400 | resource_in_use | if the specified storage address is in use.
400 | invalid_argument | if the specified storage address is out of bounds.
400 | resource_busy | if the virtual machine is busy performing another operation.
400 | resource_inaccessible | if the virtual machine's configuration state cannot be accessed.
503 | service_unavailable | if the system is unable to communicate with a service to complete the request.
401 | unauthenticated | if the user can not be authenticated.
403 | unauthorized | if the user doesn't have the required privileges.
400 | unsupported | if the guest operating system of the virtual machine is not supported and spec includes unset fields that default to guest-specific values.