Class List Method List File List

# Class: Com::Vmware::Vcenter::Vm::Hardware::Disk

Inherits:
  VAPI::Bindings::VapiService
  - Object
  - VAPI::Bindings::VapiService
  - Com::Vmware::Vcenter::Vm::Hardware::Disk
  show all
Defined in:
  /build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/vcenter/vm/hardware.rb

## Overview

The ``Com::Vmware::Vcenter::Vm::Hardware::Disk`` class provides methods for configuring the virtual disks of a virtual machine. A virtual disk has a backing such as a VMDK file. The backing has an independent lifecycle from the virtual machine when it is detached from the virtual machine. The :func:`Com::Vmware::Vcenter::Vm::Hardware::Disk.create` method provides the ability to create a new virtual disk. When creating a virtual disk, a new VMDK file may be created or an existing VMDK file may used as a backing. Once a VMDK file is associated with a virtual machine, its lifecycle will be bound to the virtual machine. In other words, it will be deleted when the virtual machine is deleted. The :func:`Com::Vmware::Vcenter::Vm::Hardware::Disk.delete` method provides the ability to detach a VMDK file from the virtual machine. The :func:`Com::Vmware::Vcenter::Vm::Hardware::Disk.delete` method does not delete the VMDK file that backs the virtual disk. Once detached, the VMDK file will not be destroyed when the virtual machine to which it was associated is deleted.

## Defined Under Namespace

Classes: BackingInfo, BackingSpec, BackingType, CreateSpec, HostBusAdapterType, Info, Summary, UpdateSpec, VmdkCreateSpec

## Constant Summary

RESOURCE_TYPE =

      'com.vmware.vcenter.vm.hardware.Disk'

## Instance Method Summary (collapse)

- - (String) create(vm, spec)

  Adds a virtual disk to the virtual machine.

- - (Void) delete(vm, disk)

  Removes a virtual disk from the virtual machine.

- - (Com::Vmware::Vcenter::Vm::Hardware::Disk::Info) get(vm, disk)

  Returns information about a virtual disk.

- - (Disk) initialize(config) constructor

  Constructs a new instance.

- - (Array<Com::Vmware::Vcenter::Vm::Hardware::Disk::Summary>) list(vm)

  Returns commonly used information about the virtual disks belonging to the virtual machine.

- - (Void) update(vm, disk, spec)

  Updates the configuration of a virtual disk.

## Constructor Details

### - (`Disk`) initialize(config)

Constructs a new instance.

Parameters:

- config (`VAPI::Bindings::StubConfig`) —

  A hash with the api provider details.

    1716
    1717
    1718
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/vcenter/vm/hardware.rb', line 1716

    def initialize(config)
        super(config, @@service_info)
    end

## Instance Method Details

### - (`String`) create(vm, spec)

Adds a virtual disk to the virtual machine. While adding the virtual disk, a new VMDK file may be created or an existing VMDK file may be used to back the virtual disk.

Parameters:

- vm (`String`) —

  Virtual machine identifier.

- spec (`Com::Vmware::Vcenter::Vm::Hardware::Disk::CreateSpec`) —

  Specification for the new virtual disk.

Returns:

- (`String`) —

  Virtual disk identifier.

Raises:

- (`Com::Vmware::Vapi::Std::Errors::Error`) —

  if system reported that the disk device was created but was unable to confirm the creation because the identifier of the new device could not be determined.

- (`Com::Vmware::Vapi::Std::Errors::Error`) —

  if the system reports an error while responding to the request.

- (`Com::Vmware::Vapi::Std::Errors::NotFound`) —

  if the virtual machine is not found.

- (`Com::Vmware::Vapi::Std::Errors::NotAllowedInCurrentState`) —

  if the virtual machine is suspended or if the virtual machine is powered on and virtual disk type is IDE.

- (`Com::Vmware::Vapi::Std::Errors::UnableToAllocateResource`) —

  if the specified storage address is unavailable; for example, if the SCSI adapter requested does not exist.

- (`Com::Vmware::Vapi::Std::Errors::ResourceInUse`) —

  if the specified storage address is in use.

- (`Com::Vmware::Vapi::Std::Errors::InvalidArgument`) —

  if the specified storage address is out of bounds.

- (`Com::Vmware::Vapi::Std::Errors::ResourceBusy`) —

  if the virtual machine is busy performing another operation.

- (`Com::Vmware::Vapi::Std::Errors::ResourceInaccessible`) —

  if the virtual machine’s configuration state cannot be accessed.

- (`Com::Vmware::Vapi::Std::Errors::ServiceUnavailable`) —

  if the system is unable to communicate with a service to complete the request.

- (`Com::Vmware::Vapi::Std::Errors::Unauthenticated`) —

  if the user can not be authenticated.

- (`Com::Vmware::Vapi::Std::Errors::Unauthorized`) —

  if the user doesn’t have the required privileges.

- (`Com::Vmware::Vapi::Std::Errors::Unsupported`) —

  if the guest operating system of the virtual machine is not supported and spec includes nil fields that default to guest-specific values.

    1810
    1811
    1812
    1813
    1814
    1815
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/vcenter/vm/hardware.rb', line 1810

    def create(vm, spec)
        invoke_with_info(@@create_info, {
            'vm' => vm,
            'spec' => spec,
        })
    end

### - (`Void`) delete(vm, disk)

Removes a virtual disk from the virtual machine. This method does not destroy the VMDK file that backs the virtual disk. It only detaches the VMDK file from the virtual machine. Once detached, the VMDK file will not be destroyed when the virtual machine to which it was associated is deleted.

Parameters:

- vm (`String`) —

  Virtual machine identifier.

- disk (`String`) —

  Virtual disk identifier.

Returns:

- (`Void`)

Raises:

- (`Com::Vmware::Vapi::Std::Errors::Error`) —

  if the system reports an error while responding to the request.

- (`Com::Vmware::Vapi::Std::Errors::NotFound`) —

  if the virtual machine or virtual disk is not found.

- (`Com::Vmware::Vapi::Std::Errors::NotAllowedInCurrentState`) —

  if the virtual machine is suspended or if the virtual machine is powered on and virtual disk type is IDE.

- (`Com::Vmware::Vapi::Std::Errors::ResourceBusy`) —

  if the virtual machine is busy performing another operation.

- (`Com::Vmware::Vapi::Std::Errors::ResourceInaccessible`) —

  if the virtual machine’s configuration state cannot be accessed.

- (`Com::Vmware::Vapi::Std::Errors::ServiceUnavailable`) —

  if the system is unable to communicate with a service to complete the request.

- (`Com::Vmware::Vapi::Std::Errors::Unauthenticated`) —

  if the user can not be authenticated.

- (`Com::Vmware::Vapi::Std::Errors::Unauthorized`) —

  if the user doesn’t have the required privileges.

    1875
    1876
    1877
    1878
    1879
    1880
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/vcenter/vm/hardware.rb', line 1875

    def delete(vm, disk)
        invoke_with_info(@@delete_info, {
            'vm' => vm,
            'disk' => disk,
        })
    end

### - (`Com::Vmware::Vcenter::Vm::Hardware::Disk::Info`) get(vm, disk)

Returns information about a virtual disk.

Parameters:

- vm (`String`) —

  Virtual machine identifier.

- disk (`String`) —

  Virtual disk identifier.

Returns:

- (`Com::Vmware::Vcenter::Vm::Hardware::Disk::Info`) —

  Information about the specified virtual disk.

Raises:

- (`Com::Vmware::Vapi::Std::Errors::Error`) —

  if the system reports an error while responding to the request.

- (`Com::Vmware::Vapi::Std::Errors::NotFound`) —

  if the virtual machine or virtual disk is not found.

- (`Com::Vmware::Vapi::Std::Errors::ResourceInaccessible`) —

  if the virtual machine’s configuration state cannot be accessed.

- (`Com::Vmware::Vapi::Std::Errors::ServiceUnavailable`) —

  if the system is unable to communicate with a service to complete the request.

- (`Com::Vmware::Vapi::Std::Errors::Unauthenticated`) —

  if the user can not be authenticated.

- (`Com::Vmware::Vapi::Std::Errors::Unauthorized`) —

  if the user doesn’t have the required privileges.

    1768
    1769
    1770
    1771
    1772
    1773
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/vcenter/vm/hardware.rb', line 1768

    def get(vm, disk)
        invoke_with_info(@@get_info, {
            'vm' => vm,
            'disk' => disk,
        })
    end

### - (`Array<Com::Vmware::Vcenter::Vm::Hardware::Disk::Summary>`) list(vm)

Returns commonly used information about the virtual disks belonging to the virtual machine.

Parameters:

- vm (`String`) —

  Virtual machine identifier.

Returns:

- (`Array<Com::Vmware::Vcenter::Vm::Hardware::Disk::Summary>`) —

  List of commonly used information about the virtual disks.

Raises:

- (`Com::Vmware::Vapi::Std::Errors::Error`) —

  if the system reports an error while responding to the request.

- (`Com::Vmware::Vapi::Std::Errors::NotFound`) —

  if the virtual machine is not found.

- (`Com::Vmware::Vapi::Std::Errors::ResourceInaccessible`) —

  if the virtual machine’s configuration state cannot be accessed.

- (`Com::Vmware::Vapi::Std::Errors::ServiceUnavailable`) —

  if the system is unable to communicate with a service to complete the request.

- (`Com::Vmware::Vapi::Std::Errors::Unauthenticated`) —

  if the user can not be authenticated.

- (`Com::Vmware::Vapi::Std::Errors::Unauthorized`) —

  if the user doesn’t have the required privileges.

    1741
    1742
    1743
    1744
    1745
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/vcenter/vm/hardware.rb', line 1741

    def list(vm)
        invoke_with_info(@@list_info, {
            'vm' => vm,
        })
    end

### - (`Void`) update(vm, disk, spec)

Updates the configuration of a virtual disk. An update method can be used to detach the existing VMDK file and attach another VMDK file to the virtual machine.

Parameters:

- vm (`String`) —

  Virtual machine identifier.

- disk (`String`) —

  Virtual disk identifier.

- spec (`Com::Vmware::Vcenter::Vm::Hardware::Disk::UpdateSpec`) —

  Specification for updating the virtual disk.

Returns:

- (`Void`)

Raises:

- (`Com::Vmware::Vapi::Std::Errors::Error`) —

  if the system reports an error while responding to the request.

- (`Com::Vmware::Vapi::Std::Errors::NotFound`) —

  if the virtual machine or virtual disk is not found.

- (`Com::Vmware::Vapi::Std::Errors::NotAllowedInCurrentState`) —

  if one or more of the fields specified in the ``spec`` parameter cannot be modified due to the current power state of the virtual machine or the connection state of the virtual disk.

- (`Com::Vmware::Vapi::Std::Errors::ResourceBusy`) —

  if the virtual machine is busy performing another operation.

- (`Com::Vmware::Vapi::Std::Errors::ResourceInaccessible`) —

  if the virtual machine’s configuration state cannot be accessed.

- (`Com::Vmware::Vapi::Std::Errors::ServiceUnavailable`) —

  if the system is unable to communicate with a service to complete the request.

- (`Com::Vmware::Vapi::Std::Errors::Unauthenticated`) —

  if the user can not be authenticated.

- (`Com::Vmware::Vapi::Std::Errors::Unauthorized`) —

  if the user doesn’t have the required privileges.

    1843
    1844
    1845
    1846
    1847
    1848
    1849
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/vcenter/vm/hardware.rb', line 1843

    def update(vm, disk, spec)
        invoke_with_info(@@update_info, {
            'vm' => vm,
            'disk' => disk,
            'spec' => spec,
        })
    end