Created attachment 1213297 [details] ss of ruby output Description of problem: Via REST API cannot get disk information for Virtual machines Via ruby SDK Disk status is always `nil` Version-Release number of selected component (if applicable): oVirt Engine Version: 4.0.2.7-1.el7.centos gem.add_runtime_dependency 'ovirt-engine-sdk', '=4.0.2' How reproducible: Always Steps to Reproduce: 1. Create a virtual machine 2. Run snippet below to view disk status Actual results: disk status is `nil` Expected results: disk status to be `OK` Additional info: http://imgur.com/a/c6yFa > # `machine` is a VM returned from `.add` > # `server` is a virtual machine found by `vms_service.list({:search => "id=#{machine.id}"})` > vm_service = env[:vms_service].vm_service(server.id) > disk_attachments_service = vm_service.disk_attachments_service > disk_attachments = disk_attachments_service.list > disk_attachments.collect { |disk_at| "id: #{disk_at.disk.id} .... status_nil?: #{disk_at.disk.status.nil?}" } => ["id: aa689257-b6b7-4d77-9ff4-f15ae12a9517 .... status_nil?: true"] As for rest API: curl -k -L -v -u "admin@internal:redact" \ -H "Content-type: application/xml" \ https://server2.blindrage.local/ovirt-engine/api/vms/8a18ad60-4063-4ff5-8840-c5f2d3636a65 # returns a valid XMl object representing the VM: ``` <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <vm href="/ovirt-engine/api/vms/8a18ad60-4063-4ff5-8840-c5f2d3636a65" id="8a18ad60-4063-4ff5-8840-c5f2d3636a65"> <actions> <link href="/ovirt-engine/api/vms/8a18ad60-4063-4ff5-8840-c5f2d3636a65/cancelmigration" rel="cancelmigration"/> <link href="/ovirt-engine/api/vms/8a18ad60-4063-4ff5-8840-c5f2d3636a65/reordermacaddresses" rel="reordermacaddresses"/> <link href="/ovirt-engine/api/vms/8a18ad60-4063-4ff5-8840-c5f2d3636a65/clone" rel="clone"/> <link href="/ovirt-engine/api/vms/8a18ad60-4063-4ff5-8840-c5f2d3636a65/commitsnapshot" rel="commitsnapshot"/> ...snipping rest... ``` Per docs: https://www.ovirt.org/develop/api/rest-api/rest-api/ I should be able to add /disks to URL: ``` curl -k -L -v -u "admin@internal:redact" \ -H "Content-type: application/xml" \ https://server2.blindrage.local/ovirt-engine/api/vms/8a18ad60-4063-4ff5-8840-c5f2d3636a65/disks ``` returns ``` * About to connect() to server2.blindrage.local port 443 (#0) * Trying 192.168.2.51... connected * Connected to server2.blindrage.local (192.168.2.51) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * warning: ignoring value of ssl.verifyhost * skipping SSL peer certificate verification * SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * Server certificate: * subject: CN=server2.blindrage.local,O=blindrage.local,C=US * start date: Aug 01 16:49:11 2016 GMT * expire date: Jul 07 16:49:11 2021 GMT * common name: server2.blindrage.local * issuer: CN=server2.blindrage.local.90292,O=blindrage.local,C=US * Server auth using Basic with user 'admin@internal' > GET /ovirt-engine/api/vms/8a18ad60-4063-4ff5-8840-c5f2d3636a65/disks HTTP/1.1 > Authorization: Basic YWRtaW5AaW50ZXJuYWw6XjR6Sz54eFRYOkhHMnM8 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: server2.blindrage.local > Accept: */* > Content-type: application/xml > < HTTP/1.1 404 Not Found < Date: Mon, 24 Oct 2016 03:02:27 GMT < Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips < Set-Cookie: JSESSIONID=Qomkt12-NruQAaoh2Xsl3K4Pmq9Pq5OXRud3HMp5.server2; path=/ovirt-engine/api; secure; HttpOnly < Content-Length: 0 < * Connection #0 to host server2.blindrage.local left intact * Closing connection #0 ```
The expected value for the disk status is 'nil' because when retrieving a list of disk attachments the disk is just a _link_, not the actual data. Fore example: <disk_attachments> <disk_attachment href="/ovirt-engine/api/vms/123/diskattachments/456" id="456"> <active>true</active> <bootable>true</bootable> <interface>virtio</interface> <disk href="/ovirt-engine/api/disks/789" id="789"/> <vm href="/ovirt-engine/api/vms/123" id="123"/> </disk_attachment> </disk_attachments> To retrieve the actual disk data you have to perform another request, to the '/ovirt-engine/api/disk/789' URL in this case. With the Ruby SDK this is simplified using the 'follow_link' method of the connection: http://www.rubydoc.info/gems/ovirt-engine-sdk/OvirtSDK4/Connection#follow_link-instance_method For example: disk_attachments = disk_attachments_service.list disk_attachments.each do |disk_attachment| # This call to `follow_link` will take the `href` attribute from the # disk attachment and perform a GET request of that URL, and will # return the completely populated object: disk = connection.follow_link(disk_attachment.disk) # Then you can use all the attributes of the disk object: puts "name: #{disk.name}" puts "id: #{disk.id}" puts "status: #{disk.status}" puts "provisioned_size: #{disk.provisioned_size}" end I am trying to clarify that in the 'list_vm_disk' example included in the SDK: Clarify that DiskAttachment.disk is only a link https://gerrit.ovirt.org/65674 Regarding the /vm/{vm:id}/disk URL, it has been removed in version 4 of the API. The example that you mention talks about version 3 of the API. As this is the expected behavior and there is a way to get the disk details, using the 'follow_links' method, I am lowering the severity and moving the bug to the documentation component.
The fix for this issue should be included in oVirt 4.1.0 beta 1 released on December 1st. If not included please move back to modified.
Verified on ovirt-engine-sdk version 4.1.0.alpha3.