Class: OvirtSDK4::DisksService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary collapse
-
#add(disk, opts = {}) ⇒ Disk
Adds a new floating disk.
-
#add_lun(disk, opts = {}) ⇒ Disk
Add a new lun disk to the storage domain.
-
#add_on_storage_domain(disk, opts = {}) ⇒ Disk
Add a new disk to the storage domain with the specified size allocating space from the storage domain.
-
#disk_service(id) ⇒ DiskService
Reference to a service managing a specific disk.
-
#list(opts = {}) ⇒ Array<Disk>
Get list of disks.
-
#service(path) ⇒ Service
Locates the service corresponding to the given path.
Methods inherited from Service
Instance Method Details
#add(disk, opts = {}) ⇒ Disk
Adds a new floating disk.
There are three types of disks that can be added - disk image, direct LUN and Managed Block disk. Cinder integration has been replaced by Managed Block Storage.
Adding a new image disk:
When creating a new floating image Disk, the API requires the storage_domain, provisioned_size
and format attributes.
Note that block storage domains (i.e. storage domains with the storage type of iSCSI or
FCP) do not support the combination of the raw format with sparse=true, so sparse=false must be stated
explicitly.
To create a new floating image disk with specified provisioned_size, format and name on a storage domain
with an id 123 and enabled for incremental backup, send a request as follows:
POST /ovirt-engine/api/disks HTTP/1.1
With a request body as follows:
<disk>
<storage_domains>
<storage_domain id="123"/>
</storage_domains>
<name>mydisk</name>
<provisioned_size>1048576</provisioned_size>
<format>cow</format>
<backup>incremental</backup>
</disk>
Adding a new direct LUN disk:
When adding a new floating direct LUN via the API, there are two flavors that can be used:
-
With a
hostelement - in this case, the host is used for sanity checks (e.g., that the LUN is visible) and to retrieve basic information about the LUN (e.g., size and serial). -
Without a
hostelement - in this case, the operation is a database-only operation, and the storage is never accessed.
To create a new floating direct LUN disk with a host element with an id 123, specified alias, type and
logical_unit with an id 456 (that has the attributes address, port and target),
send a request as follows:
POST /ovirt-engine/api/disks HTTP/1.1
With a request body as follows:
<disk>
<alias>mylun</alias>
<lun_storage>
<host id="123"/>
<type>iscsi</type>
<logical_units>
<logical_unit id="456">
<address>10.35.10.20</address>
<port>3260</port>
<target>iqn.2017-01.com.myhost:444</target>
</logical_unit>
</logical_units>
</lun_storage>
</disk>
To create a new floating direct LUN disk without using a host, remove the host element.
Adding a new Cinder disk:
Cinder integration has been replaced by Managed Block Storage.
Adding a floating disks in order to upload disk snapshots:
Since version 4.2 of the engine it is possible to upload disks with
snapshots. This request should be used to create the base image of the
images chain (The consecutive disk snapshots (images), should be created
using disk-attachments element when creating a snapshot).
The disk has to be created with the same disk identifier and image identifier
of the uploaded image. I.e. the identifiers should be saved as part of the
backup process. The image identifier can be also fetched using the
qemu-img info command. For example, if the disk image is stored into
a file named b7a4c6c5-443b-47c5-967f-6abc79675e8b/myimage.img:
$ qemu-img info b7a4c6c5-443b-47c5-967f-6abc79675e8b/myimage.img
image: b548366b-fb51-4b41-97be-733c887fe305
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 196K
cluster_size: 65536
backing file: ad58716a-1fe9-481f-815e-664de1df04eb
backing file format: raw
To create a disk with with the disk identifier and image identifier obtained
with the qemu-img info command shown above, send a request like this:
POST /ovirt-engine/api/disks HTTP/1.1
With a request body as follows:
<disk id="b7a4c6c5-443b-47c5-967f-6abc79675e8b">
<image_id>b548366b-fb51-4b41-97be-733c887fe305</image_id>
<storage_domains>
<storage_domain id="123"/>
</storage_domains>
<name>mydisk</name>
<provisioned_size>1048576</provisioned_size>
<format>cow</format>
</disk>
7822 7823 7824 |
# File 'lib/ovirtsdk4/services.rb', line 7822 def add(disk, opts = {}) internal_add(disk, Disk, ADD, opts) end |
#add_lun(disk, opts = {}) ⇒ Disk
Add a new lun disk to the storage domain.
7920 7921 7922 |
# File 'lib/ovirtsdk4/services.rb', line 7920 def add_lun(disk, opts = {}) internal_add(disk, Disk, ADD_LUN, opts) end |
#add_on_storage_domain(disk, opts = {}) ⇒ Disk
Add a new disk to the storage domain with the specified size allocating space from the storage domain.
7947 7948 7949 |
# File 'lib/ovirtsdk4/services.rb', line 7947 def add_on_storage_domain(disk, opts = {}) internal_add(disk, Disk, ADD_ON_STORAGE_DOMAIN, opts) end |
#disk_service(id) ⇒ DiskService
Reference to a service managing a specific disk.
7958 7959 7960 |
# File 'lib/ovirtsdk4/services.rb', line 7958 def disk_service(id) DiskService.new(self, id) end |
#list(opts = {}) ⇒ Array<Disk>
Get list of disks.
GET /ovirt-engine/api/disks HTTP/1.1
You will get a XML response which will look like this one:
<disks>
<disk id="123">
<actions>...</actions>
<name>MyDisk</name>
<description>MyDisk description</description>
<link href="/ovirt-engine/api/disks/123/permissions" rel="permissions"/>
<link href="/ovirt-engine/api/disks/123/statistics" rel="statistics"/>
<actual_size>5345845248</actual_size>
<alias>MyDisk alias</alias>
...
<status>ok</status>
<storage_type>image</storage_type>
<wipe_after_delete>false</wipe_after_delete>
<disk_profile id="123"/>
<quota id="123"/>
<storage_domains>...</storage_domains>
</disk>
...
</disks>
The order of the returned list of disks is guaranteed only if the sortby clause is included in the
search parameter.
7893 7894 7895 |
# File 'lib/ovirtsdk4/services.rb', line 7893 def list(opts = {}) internal_get(LIST, opts) end |
#service(path) ⇒ Service
Locates the service corresponding to the given path.
7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 |
# File 'lib/ovirtsdk4/services.rb', line 7969 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return disk_service(path) end return disk_service(path[0..(index - 1)]).service(path[(index + 1)..-1]) end |