Bug 1145035 - Cannot remove 'current' CD image through REST API
Summary: Cannot remove 'current' CD image through REST API
Keywords:
Status: CLOSED DUPLICATE of bug 1135970
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine-restapi
Version: 3.5.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Juan Hernández
QA Contact: Shai Revivo
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-22 09:03 UTC by Christophe Fergeau
Modified: 2014-09-22 13:50 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-09-22 10:02:38 UTC
oVirt Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Christophe Fergeau 2014-09-22 09:03:47 UTC
I'm sending DELETE requests through oVirt REST API in order to remove a CD image from a CD drive. This is working for the persistant configuration (ie the CD image which will be available when starting up the VM), but this is not working for the 'current' configuration.
I've tested this with curl on https://rhevm35.spice.brq.redhat.com/

$ curl --user admin@internal -H "filter: true" -H "content-type:application/xml" -k -X DELETE "https://rhevm35.spice.brq.redhat.com/ovirt-engine/api/vms/55e5af3e-3e9e-45df-b534-b3c10a72f248/cdroms/00000000-0000-0000-0000-000000000000;current"
Enter host password for user 'admin@internal':
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><action><job href="/ovirt-engine/api/jobs/b292db6d-f1ce-4b11-9b7d-28c016dfeaa3" id="b292db6d-f1ce-4b11-9b7d-28c016dfeaa3"/><status><state>complete</state></status></action>


$ curl --user admin@internal -H "filter: true" -H "content-type: application/xml" -k "https://rhevm35.spice.brq.redhat.com/ovirt-engine/api/vms/55e5af3e-3e9e-45df-b534-b3c10a72f248/cdroms/00000000-0000-0000-0000-000000000000;current"
Enter host password for user 'admin@internal':
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cdrom href="/ovirt-engine/api/vms/55e5af3e-3e9e-45df-b534-b3c10a72f248/cdroms/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000">
  <vm href="/ovirt-engine/api/vms/55e5af3e-3e9e-45df-b534-b3c10a72f248" id="55e5af3e-3e9e-45df-b534-b3c10a72f248"/>
  <file id="WANemv2.3.iso"/>
</cdrom>

Comment 1 Juan Hernández 2014-09-22 10:02:38 UTC
The way to eject the CD is to update it (not delete) using an empty file identifier:

#!/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"

This used to fail due to bug 1135970, but it should work now.

*** This bug has been marked as a duplicate of bug 1135970 ***

Comment 2 Christophe Fergeau 2014-09-22 10:13:23 UTC
Hmm but DELETEing the !current image was removing the CD when I tested this, has this changed in fixed versions? Is calling DELETE on such resources returning an error now rather than doing nothing? Last but not least, the example in https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.5-Beta/html/Technical_Guide/Virtual_Machine_CD-ROMs_Sub-Collection.html is wrong then

Comment 3 Juan Hernández 2014-09-22 10:30:10 UTC
The vms/{vm:id}/cdroms/{cdrom:id} resource represents the CD reader device, not the CD disk inside the device. Changing/ejecting the CD disk inside the CD reader device should be implemented by updating (using the PUT method) the "file.id" property of the device. The DELETE method should be used only to actually remove the device from the VM. Unfortunately we initially implemented this in such a way that DELETE means the same that PUT, and we can't change it now, as it would break backwards compatibility. The previous behavior, without the "current" parameter, is preserved. The documentation is wrong.

Comment 4 Juan Hernández 2014-09-22 10:36:20 UTC
I openend bug 1145074 to track the issue in the documentation.

Comment 5 Christophe Fergeau 2014-09-22 13:45:09 UTC
Thanks for opening the documentation bug! One more question, this bug was filed against RHEV, the duplicate one is an oVirt bug, I assume this bug will be / is fixed as well in RHEV?

Comment 6 Juan Hernández 2014-09-22 13:50:45 UTC
Yes, it is fixed in RHEV as well.


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