Bug 1135970 - Cannot remove current iso cdrom (eject - dynamically remove) using rest-api/sdk
Summary: Cannot remove current iso cdrom (eject - dynamically remove) using rest-api/sdk
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: oVirt
Classification: Retired
Component: ovirt-engine-api
Version: 3.5
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: 3.5.0
Assignee: Martin Betak
QA Contact: Ilanit Stein
URL:
Whiteboard: virt
: 1145035 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-01 11:25 UTC by Carlos Mestre González
Modified: 2016-02-10 19:49 UTC (History)
14 users (show)

Fixed In Version: ovirt-3.5.0_rc2
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-17 12:37:23 UTC
oVirt Team: Virt
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 32375 0 master MERGED restapi: Enable eject of cdrom via REST Never
oVirt gerrit 32407 0 ovirt-engine-3.5 MERGED restapi: Enable eject of cdrom via REST Never

Description Carlos Mestre González 2014-09-01 11:25:20 UTC
Description of problem:
The way to remove iso images is a rest-api call with DELETE. This works to change the VM properties (UpdateVmCommand).

The problem is it cannot update it dynamically (UpdateVmDynamicDataVDSCommand), seems to just ignore the current=true parameter. This parameter works perfectly fine with PUT or GET to modify the vm's cdrom on the fly, but fails in this regard.

This is the equivalent of Change CD->Eject in the Web UI.

Version-Release number of selected component (if applicable):
ovirt-engine-restapi-3.5.0-0.0.master.20140821064931.gitb794d66.el6.noarch
ovirt-engine-3.5.0-0.0.master.20140821064931.gitb794d66.el6.noarch

How reproducible:
100%

Steps to Reproduce:
1. DELETE api/vms/e0ba3f7d-b376-453d-813f-2d6817d77be8/cdroms/00000000-0000-0000-0000-000000000000;current=true

Actual results:
Call UpdateVmCommand in the backend. iso file is removed.

Expected results:
UpdateVmDynamicDataVDSCommand is called, ejecting "dynamically" the cdrom (or at least there's a way to do this, like the eject functionality in the web ui)


Additional info:
I don't know if this is the proper way to handle this calls for consistency

DELETE should delete the cdrom object like any other object in a collection.
Eject a cdrom (iso) should be done via PUT and in a way to pass a null file property, something like this:

<cdrom><file id=''/></cdrom>

Comment 1 Carlos Mestre González 2014-09-01 11:33:42 UTC
Blocking our tests to check if storage domains can be deactivated after cdroms are ejected.

Comment 2 Carlos Mestre González 2014-09-01 14:51:07 UTC
Moving to ovirt (as it should have been)

Comment 3 Carlos Mestre González 2014-09-16 08:51:40 UTC
So what is the solution implemented:

1) calling delete with current=true?

DELETE api/vms/e0ba3f7d-b376-453d-813f-2d6817d77be8/cdroms/00000000-0000-0000-0000-000000000000;current=true

2) sending <cdrom><file id=''/></cdrom> ?

Comment 4 Martin Betak 2014-09-22 09:11:43 UTC
The 2) one

Comment 5 Juan Hernández 2014-09-22 10:00:15 UTC
The solution is to allow an empty file identifier to the update operation:

#!/bin/sh -ex

url="https://ovirt.example.com/ovirt-engine/api"
user="admin@internal"
password="******"

curl \
--verbose \
--insecure \
--request PUT \
--user "${user}:${password}" \
--header "Content-Type: application/xml" \
--header "Accept: application/xml" \
--data '
<cdrom>
  <file id=""/>
</cdrom>
' \
"${url}/vms/e0ba3f7d-b376-453d-813f-2d6817d77be8/cdroms/00000000-0000-0000-0000-000000000000;current=true"

Comment 6 Juan Hernández 2014-09-22 10:02:38 UTC
*** Bug 1145035 has been marked as a duplicate of this bug. ***

Comment 7 Sandro Bonazzola 2014-10-17 12:37:23 UTC
oVirt 3.5 has been released and should include the fix for this issue.

Comment 8 Ilanit Stein 2014-11-30 12:54:25 UTC
Verified on rhevm vt12. Marking as Triaged.


Note You need to log in before you can comment on or make changes to this bug.