Bug 1135970

Summary: Cannot remove current iso cdrom (eject - dynamically remove) using rest-api/sdk
Product: [Retired] oVirt Reporter: Carlos Mestre González <cmestreg>
Component: ovirt-engine-apiAssignee: Martin Betak <mbetak>
Status: CLOSED CURRENTRELEASE QA Contact: Ilanit Stein <istein>
Severity: high Docs Contact:
Priority: unspecified    
Version: 3.5CC: bazulay, bugs, cfergeau, ecohen, gklein, iheim, mavital, mbetak, ofrenkel, oramraz, rbalakri, Rhev-m-bugs, s.kieske, yeylon
Target Milestone: ---Keywords: AutomationBlocker, Triaged
Target Release: 3.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: virt
Fixed In Version: ovirt-3.5.0_rc2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-17 12:37:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.