Class: OvirtSDK4::DiskService

Inherits:
MeasurableService show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary collapse

Methods inherited from Service

#inspect, #to_s

Instance Method Details

#copy(opts = {}) ⇒ Object

This operation copies a disk to the specified storage domain.

For example, copy of a disk can be facilitated using the following request:

POST /ovirt-engine/api/disks/123/copy

With a request body like this:

<action>
  <storage_domain id="456"/>
  <disk>
    <name>mydisk</name>
  </disk>
</action>

If the disk profile or the quota used currently by the disk aren’t defined for the new storage domain, then they can be explicitly specified. If they aren’t then the first available disk profile and the default quota are used.

For example, to explicitly use disk profile 987 and quota 753 send a request body like this:

<action>
  <storage_domain id="456"/>
  <disk_profile id="987"/>
  <quota id="753"/>
</action>

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the copy should be performed asynchronously.

  • :disk (Disk)
  • :disk_profile (DiskProfile)

    Disk profile for the disk in the new storage domain.

    Disk profiles are defined for storage domains, so the old disk profile will not exist in the new storage domain. If this parameter is not used, the first disk profile from the new storage domain to which the user has permissions will be assigned to the disk.

  • :filter (Boolean)

    Indicates if the results should be filtered according to the permissions of the user.

  • :quota (Quota)

    Quota for the disk in the new storage domain.

    This optional parameter can be used to specify new quota for the disk, because the current quota may not be defined for the new storage domain. If this parameter is not used and the old quota is not defined for the new storage domain, the default (unlimited) quota will be assigned to the disk.

  • :storage_domain (StorageDomain)

    The storage domain where the new disk will be created. Can be specified using the id or name attributes. For example, to copy a disk to the storage domain named mydata send a request like this:

    POST /ovirt-engine/api/storagedomains/123/disks/789

    With a request body like this:

    <action>
      <storage_domain>
        <name>mydata</name>
      </storage_domain>
    </action>
  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.



33700
33701
33702
# File 'lib/ovirtsdk4/services.rb', line 33700

def copy(opts = {})
  internal_action(:copy, nil, COPY, opts)
end

#export(opts = {}) ⇒ Object

Exports a disk to an export storage domain.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the export should be performed asynchronously.

  • :filter (Boolean)

    Indicates if the results should be filtered according to the permissions of the user.

  • :storage_domain (StorageDomain)
  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.



33732
33733
33734
# File 'lib/ovirtsdk4/services.rb', line 33732

def export(opts = {})
  internal_action(:export, nil, EXPORT, opts)
end

#get(opts = {}) ⇒ Disk

Retrieves the description of the disk.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :follow (String)

    Indicates which inner links should be followed. The objects referenced by these links will be fetched as part of the current request. See here for details.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



33761
33762
33763
# File 'lib/ovirtsdk4/services.rb', line 33761

def get(opts = {})
  internal_get(GET, opts)
end

#move(opts = {}) ⇒ Object

Moves a disk to another storage domain.

For example, to move the disk with identifier 123 to a storage domain with identifier 456 send the following request:

POST /ovirt-engine/api/disks/123/move

With the following request body:

<action>
  <storage_domain id="456"/>
</action>

If the disk profile or the quota used currently by the disk aren’t defined for the new storage domain, then they can be explicitly specified. If they aren’t then the first available disk profile and the default quota are used.

For example, to explicitly use disk profile 987 and quota 753 send a request body like this:

<action>
  <storage_domain id="456"/>
  <disk_profile id="987"/>
  <quota id="753"/>
</action>

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the move should be performed asynchronously.

  • :disk_profile (DiskProfile)

    Disk profile for the disk in the new storage domain.

    Disk profiles are defined for storage domains, so the old disk profile will not exist in the new storage domain. If this parameter is not used, the first disk profile from the new storage domain to which the user has permissions will be assigned to the disk.

  • :filter (Boolean)

    Indicates if the results should be filtered according to the permissions of the user.

  • :quota (Quota)

    Quota for the disk in the new storage domain.

    This optional parameter can be used to specify new quota for the disk, because the current quota may not be defined for the new storage domain. If this parameter is not used and the old quota is not defined for the new storage domain, the default (unlimited) quota will be assigned to the disk.

  • :storage_domain (StorageDomain)
  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.



33844
33845
33846
# File 'lib/ovirtsdk4/services.rb', line 33844

def move(opts = {})
  internal_action(:move, nil, MOVE, opts)
end

#permissions_serviceAssignedPermissionsService

Reference to the service that manages the permissions assigned to the disk.

Returns:



34001
34002
34003
# File 'lib/ovirtsdk4/services.rb', line 34001

def permissions_service
  @permissions_service ||= AssignedPermissionsService.new(self, 'permissions')
end

#refresh_lun(opts = {}) ⇒ Object

Refreshes a direct LUN disk with up-to-date information from the storage.

Refreshing a direct LUN disk is useful when:

  • The LUN was added using the API without the host parameter, and therefore does not contain any information from the storage (see DisksService::add).

  • New information about the LUN is available on the storage and you want to update the LUN with it.

To refresh direct LUN disk 123 using host 456, send the following request:

POST /ovirt-engine/api/disks/123/refreshlun

With the following request body:

<action>
  <host id='456'/>
</action>

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :host (Host)

    The host that will be used to refresh the direct LUN disk.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.



33892
33893
33894
# File 'lib/ovirtsdk4/services.rb', line 33892

def refresh_lun(opts = {})
  internal_action(:refreshlun, nil, REFRESH_LUN, opts)
end

#remove(opts = {}) ⇒ Object

Removes a disk.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.



33917
33918
33919
# File 'lib/ovirtsdk4/services.rb', line 33917

def remove(opts = {})
  internal_remove(REMOVE, opts)
end

#service(path) ⇒ Service

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.

Raises:



34021
34022
34023
34024
34025
34026
34027
34028
34029
34030
34031
34032
34033
34034
34035
34036
34037
34038
# File 'lib/ovirtsdk4/services.rb', line 34021

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'permissions'
    return permissions_service
  end
  if path.start_with?('permissions/')
    return permissions_service.service(path[12..-1])
  end
  if path == 'statistics'
    return statistics_service
  end
  if path.start_with?('statistics/')
    return statistics_service.service(path[11..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

#sparsify(opts = {}) ⇒ Object

Sparsify the disk.

Sparsification frees space in the disk image that is not used by its filesystem. As a result, the image will occupy less space on the storage.

Currently sparsification works only on disks without snapshots. Disks having derived disks are also not allowed.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.



33946
33947
33948
# File 'lib/ovirtsdk4/services.rb', line 33946

def sparsify(opts = {})
  internal_action(:sparsify, nil, SPARSIFY, opts)
end

#statistics_serviceStatisticsService

Locates the statistics service.

Returns:



34010
34011
34012
# File 'lib/ovirtsdk4/services.rb', line 34010

def statistics_service
  @statistics_service ||= StatisticsService.new(self, 'statistics')
end

#update(disk, opts = {}) ⇒ Disk

This operation updates the disk with the appropriate parameters. The only field that can be updated is qcow_version.

For example, update disk can be facilitated using the following request:

PUT /ovirt-engine/api/disks/123

With a request body like this:

<disk>
  <qcow_version>qcow2_v3</qcow_version>
</disk>

Since the backend operation is asynchronous the disk element which will be returned to the user might not be synced with the changed properties.

Parameters:

  • disk (Disk)

    The update to apply to the disk.

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



33992
33993
33994
# File 'lib/ovirtsdk4/services.rb', line 33992

def update(disk, opts = {})
  internal_update(disk, Disk, UPDATE, opts)
end