Class: OvirtSDK4::DiskService
- Inherits:
-
MeasurableService
- Object
- Service
- MeasurableService
- OvirtSDK4::DiskService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary collapse
-
#convert(opts = {}) ⇒ Object
Converts disk format and/or preallocation mode.
-
#copy(opts = {}) ⇒ Object
This operation copies a disk to the specified storage domain.
-
#disk_snapshots_service ⇒ DiskSnapshotsService
Reference to the service that manages the DiskSnapshots.
-
#export(opts = {}) ⇒ Object
Exports a disk to an export storage domain.
-
#get(opts = {}) ⇒ Disk
Retrieves the description of the disk.
-
#move(opts = {}) ⇒ Object
Moves a disk to another storage domain.
-
#permissions_service ⇒ AssignedPermissionsService
Reference to the service that manages the permissions assigned to the disk.
-
#reduce(opts = {}) ⇒ Object
Reduces the size of the disk image.
-
#refresh_lun(opts = {}) ⇒ Object
Refreshes a direct LUN disk with up-to-date information from the storage.
-
#remove(opts = {}) ⇒ Object
Removes a disk.
-
#service(path) ⇒ Service
Locates the service corresponding to the given path.
-
#sparsify(opts = {}) ⇒ Object
Sparsify the disk.
-
#statistics_service ⇒ StatisticsService
Locates the
statisticsservice. -
#update(disk, opts = {}) ⇒ Disk
Updates the parameters of the specified disk.
Methods inherited from Service
Instance Method Details
#convert(opts = {}) ⇒ Object
Converts disk format and/or preallocation mode.
For example, to convert the disk format from preallocated-cow to a sparse-raw image, send a request like the following:
POST /ovirt-engine/api/disks/123/convert HTTP/1.1
With the following request body:
<action>
<disk>
<sparse>true</sparse>
<format>raw</format>
</disk>
</action>
Note: In order to sparsify a disk, two conversions might be needed if the disk is on a Block Storage Domain. For example: If a disk is RAW, converting it to QCOW will result in a larger disk. In order to reduce the size, it is possible to convert the disk again to QCOW and keep the same allocation policy.
36676 36677 36678 |
# File 'lib/ovirtsdk4/services.rb', line 36676 def convert(opts = {}) internal_action(:convert, nil, CONVERT, opts) end |
#copy(opts = {}) ⇒ Object
This operation copies a disk to the specified storage domain.
For example, a disk can be copied using the following request:
POST /ovirt-engine/api/disks/123/copy HTTP/1.1
With a request body like this:
<action>
<storage_domain id="456"/>
<disk>
<name>mydisk</name>
</disk>
</action>
If the disk profile or the quota currently used by the disk are not defined for the new storage domain, they can be explicitly specified. If they are not specified, the first available disk profile and the default quota are used.
For example, to specify 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>
36772 36773 36774 |
# File 'lib/ovirtsdk4/services.rb', line 36772 def copy(opts = {}) internal_action(:copy, nil, COPY, opts) end |
#disk_snapshots_service ⇒ DiskSnapshotsService
Reference to the service that manages the DiskSnapshots.
For example, to list all disk snapshots under the disks resource '123':
GET /ovirt-engine/api/disks/123/disksnapshots HTTP/1.1
For example, to retrieve a specific disk snapshot '789' under the disk resource '123':
GET /ovirt-engine/api/disks/123/disksnapshots/789 HTTP/1.1
37134 37135 37136 |
# File 'lib/ovirtsdk4/services.rb', line 37134 def disk_snapshots_service @disk_snapshots_service ||= DiskSnapshotsService.new(self, 'disksnapshots') end |
#export(opts = {}) ⇒ Object
Exports a disk to an export storage domain.
36804 36805 36806 |
# File 'lib/ovirtsdk4/services.rb', line 36804 def export(opts = {}) internal_action(:export, nil, EXPORT, opts) end |
#get(opts = {}) ⇒ Disk
Retrieves the description of the disk.
36846 36847 36848 |
# File 'lib/ovirtsdk4/services.rb', line 36846 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 HTTP/1.1
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>
36926 36927 36928 |
# File 'lib/ovirtsdk4/services.rb', line 36926 def move(opts = {}) internal_action(:move, nil, MOVE, opts) end |
#permissions_service ⇒ AssignedPermissionsService
Reference to the service that manages the permissions assigned to the disk.
37143 37144 37145 |
# File 'lib/ovirtsdk4/services.rb', line 37143 def @permissions_service ||= AssignedPermissionsService.new(self, 'permissions') end |
#reduce(opts = {}) ⇒ Object
Reduces the size of the disk image.
Invokes reduce on the logical volume (i.e. this is only applicable for block storage domains). This is applicable for floating disks and disks attached to non-running virtual machines. There is no need to specify the size as the optimal size is calculated automatically.
36956 36957 36958 |
# File 'lib/ovirtsdk4/services.rb', line 36956 def reduce(opts = {}) internal_action(:reduce, nil, REDUCE, opts) 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 HTTP/1.1
With the following request body:
<action>
<host id='456'/>
</action>
37002 37003 37004 |
# File 'lib/ovirtsdk4/services.rb', line 37002 def refresh_lun(opts = {}) internal_action(:refreshlun, nil, REFRESH_LUN, opts) end |
#remove(opts = {}) ⇒ Object
Removes a disk.
37027 37028 37029 |
# File 'lib/ovirtsdk4/services.rb', line 37027 def remove(opts = {}) internal_remove(REMOVE, opts) end |
#service(path) ⇒ Service
Locates the service corresponding to the given path.
37163 37164 37165 37166 37167 37168 37169 37170 37171 37172 37173 37174 37175 37176 37177 37178 37179 37180 37181 37182 37183 37184 37185 37186 |
# File 'lib/ovirtsdk4/services.rb', line 37163 def service(path) if path.nil? || path == '' return self end if path == 'disksnapshots' return disk_snapshots_service end if path.start_with?('disksnapshots/') return disk_snapshots_service.service(path[14..-1]) end if path == 'permissions' return end if path.start_with?('permissions/') return .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.
37056 37057 37058 |
# File 'lib/ovirtsdk4/services.rb', line 37056 def sparsify(opts = {}) internal_action(:sparsify, nil, SPARSIFY, opts) end |
#statistics_service ⇒ StatisticsService
Locates the statistics service.
37152 37153 37154 |
# File 'lib/ovirtsdk4/services.rb', line 37152 def statistics_service @statistics_service ||= StatisticsService.new(self, 'statistics') end |
#update(disk, opts = {}) ⇒ Disk
Updates the parameters of the specified disk.
This operation allows updating the following floating disk properties:
-
For Image disks:
provisioned_size,alias,description,wipe_after_delete,shareable,backupanddisk_profile. -
For LUN disks:
alias,descriptionandshareable. -
Cinder integration has been replaced by Managed Block Storage.
-
For Managed Block disks:
provisioned_size,aliasanddescription. -
For VM attached disks, the
qcow_versioncan also be updated.
For example, a disk’s update can be done by using the following request:
PUT /ovirt-engine/api/disks/123 HTTP/1.1
With a request body like this:
<disk>
<qcow_version>qcow2_v3</qcow_version>
<alias>new-alias</alias>
<description>new-desc</description>
</disk>
Since the backend operation is asynchronous, the disk element that is returned to the user might not be synced with the changed properties.
37113 37114 37115 |
# File 'lib/ovirtsdk4/services.rb', line 37113 def update(disk, opts = {}) internal_update(disk, Disk, UPDATE, opts) end |