Add Hard Disk operation


The Add Hard Disk operation enables you to add a hard disk or a virtual disk, using Raw Disk Mapping (RDM) or logical unit number (LUN) mapping, on the specified virtual machine.

When adding a disk with a controller type that is different from an existing controller type, you must power off the VM.

The following table describes the elements for this request.

Adapter request elements for the Add Hard Disk operation

Element

Definition

Required

<operation-type>

Specifies the type of the operation: Configure_Vm

Yes

<operation-name>

Specifies the name of the operation: Add_Hard_Disk

Yes

<soap-url>

Specifies the URL for the remote SOAP service running on the VMware VirtualCenter

If the <soap-url> element is not specified, the request uses the VirtualCenter Server details specified in the adapter configuration.

Default format for HTTPS: https://<hostName>:<port>/sdk/vim

Default format for HTTP: http://<hostName>:<port>/sdk/vim

Note

If you want to use an HTTP value, you might need to change the configuration of the VMware Infrastructure application.

No

<transport>

Specifies the transport protocol for the message

If the <transport> element is not provided, the request uses the VirtualCenter Server details specified in the adapter configuration.

Valid values: https-rpc (default), http-rpc

Note

If the value of the <transport> element is https-rpc, you must install the security certificate for the VMware Virtual Center to the keystore of the peer on which the adapter is enabled.

No

<user-name>

Specifies the user name that is used for HTTP basic authentication on the VMware Virtual Center

If no user name is specified, the request is executed with the user name that is specified in the configuration.

No

<password>

Specifies the password corresponding to <user-name>

Conditional; required if <user-name> is specified

<parameters>

Contains the elements required to execute the operation

Yes

<virtual-machine>

Specifies the virtual machine to which to add a hard disk

Yes

<file-name>

Specifies the name for the host file used in the operation

Ensure that you enclose the file name in square brackets.

Yes

<device>

Contains information about the hard disk that you want to add; contains the controller-type attribute

Valid values for controller-type:

  • VirtualBusLogicController (default)
  • VirtualLsiLogicController
  • VirtualLsiLogicSASController
  • ParaVirtualSCSIController

No

<bus-number>

Specifies the bus number associated with the controller as its index

Valid values: 0 (default), 1, 2, 3

You can place SCSI controllers at four indexes: 0, 1, 2, and 3 and each SCSI controller can have up to 16 hard disks with a disk index ranging from 0 to 15.

anyNumberBetween0-3:anyNumberBetween0-15 is interpreted as: SCSI controller index (0-3):Disk index (0-15)

Examples:

  • Index 0:0 is interpreted as:
    A SCSI controller type, for example, VirtualLsiLogicSASController at controller index 0:A disk at disk index 0

  • Index 1:1 is interpreted as:
    A SCSI controller type, for example, ParaVirtualSCSIController at controller index 1:A disk at disk index 0

No

<backing>

Contains information about the backing of a device in a virtual machine; contains the type attribute, which defines more refined subtypes for device-specific backing information

The type attribute is required when adding an RDM virtual disk.

Valid value (for type): VirtualDiskRawDiskMappingVer1BackingInfo

Yes

<device-name>

Specifies the host-specific device through which the LUN is accessed

Valid format: /vmfs/devices/disks/uniqueDiskOrLUNId

Conditional; required when adding an RDM virtual disk

<compatibility-mode>

Specifies the compatibility mode of the raw disk mapping (RDM)

Valid values:

  • physicalMode: Specifies that a disk device backed by a physical compatibility mode RDM cannot use disk modes, and commands are passed to the LUN indicated by the raw disk mapping
  • virtualMode: Specifies that a disk device backed by a virtual compatibility mode RDM can use disk modes

Conditional; required when adding an RDM virtual disk

<disk-mode>

Specifies the disk persistence mode

Valid values:

  • persistent: Changes are immediately and permanently written to the virtual disk
  • independent_persistent: Same as persistent, but not affected by snapshots
  • independent_nonpersistent: Same as non-persistent, but not affected by snapshots
  • nonpersistent: Changes to virtual disk are made to a redo log and discarded at power off

Yes

<split>

Specifies whether the type of virtual disk file is split or monolithic

Valid values: true, false

If <split> = true, the virtual disk is stored in multiple 2-GB files.

No

<thin-provisioned>

Specifies whether the virtual disk backing file should be allocated using thin provisioning

This flag is used only for file systems that support configuring the provisioning policy on a per-file basis, such as VMFS3.

Valid values: true, false (default)

If <thin-provisioned> = false, the virtual disk backing file is allocated using thick provisioning. For VMware Infrastructure 5.x, the lazy zeroed type of thick provisioning is used.

No

<write-through>

Specifies whether disk write operations are performed on the file system directly or are buffered

Valid values: true (direct), false (buffered)

No

<capacity-inKB>

Specifies the capacity of the virtual disk

Conditional:

  • Required when creating other disks
  • Not required when adding an RDM virtual disk
<shares>

Specifies the number of shares allocated

The value specified in the <shares> element is used to determine the resource allocation in case of resource contention. Specify a value for <shares> only if <level> = custom; otherwise, <shares> is ignored. Therefore, only <shares> with custom values can be compared.

The <shares> element has no units. It is a relative measure based on the settings for other resource pools.

Valid values: Any positive number

No

<level>

Indicates the allocation level

The level is a simplified view of <shares>. Levels map to a predetermined set of numeric values for shares. If the value of <shares> does not map to a predefined size, <level> is set to custom.

Valid values:

No

The following code sample shows a sample adapter request for the Add Hard Disk operation.

Sample adapter request for the Add Hard Disk operation

<vmware-infrastructure-request>
    
<soap-url />
    
<transport />
    
<user-name />
    
<password />
    
<operation-type>Configure_Vm</operation-type>
    
<operation-name>Add_Hard_Disk</operation-name>
    
<parameters>
      
<virtual-machine>VM1</virtual-machine>
      
<spec>
        
<device-change>
          
<device controller-type="VirtualLsiLogicSASController">
          
<bus-number>1</bus-number>// The value varies from 0 to 3.
          
<backing type="VirtualDiskRawDiskMappingVer1BackingInfo">
              
<file-name>[datastore1]</file-name>
              
<device-name>/vmfs/devices/disks/naa.60a980006e424f4f6c4a656c354c5677</device-name>
              
<compatibility-mode>physicalMode</compatibility-mode>
              
<disk-mode>persistent</disk-mode>
              
<split>false</split>
              
<write-through>false</write-through>
              
<thin-provisioned>true</thin-provisioned>
            
</backing>
            
<capacity-inKB>2048</capacity-inKB>
            
<shares>
              
<shares>1500</shares>
              
<level>custom</level>
            
</shares>
          
</device>
        
</device-change>
      
</spec>
    
</parameters>
  
</vmware-infrastructure-request>

The following code sample shows the response for the sample Add Hard Disk operation.

Sample adapter response for the Add Hard Disk operation

vmware-infrastructure-response>
 <metadata>
   <status>success</status>
 </metadata>
 <AddHardDiskResponse>
   <Task>task-8218</Task>
 </AddHardDiskResponse>
</vmware-infrastructure-response>

The following table describes the response element.

Adapter response element for the Add Hard Disk operation

Element

Definition

<Task>

Specifies the task ID of the submitted task

Use the task ID to obtain the status of the specified task.

For information about using the task ID to check the task status, see Request and response for the Retrieve_Task_Status operation.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*