Bug 1117278
| Summary: | [python-sdk] Unable to delete storageconnection object | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Retired] oVirt | Reporter: | Gadi Ickowicz <gickowic> | ||||
| Component: | ovirt-engine-api | Assignee: | Daniel Erez <derez> | ||||
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Raz Tamir <ratamir> | ||||
| Severity: | high | Docs Contact: | |||||
| Priority: | unspecified | ||||||
| Version: | 3.5 | CC: | acanan, ajia, amureini, bugs, gklein, iheim, juan.hernandez, nlevinki, rbalakri, yeylon | ||||
| Target Milestone: | --- | ||||||
| Target Release: | 3.5.0 | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | storage | ||||||
| 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:43:28 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | Storage | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Attachments: |
|
||||||
|
Description
Gadi Ickowicz
2014-07-08 12:42:09 UTC
This happens because the definition of the delete operation of this resource includes a parameter of type Host. The generator of the Python SDK only expects parameters of type Action for delete operations, and when that parameter isn't given it creates an empty instance. In this case it creates an empty instance of the Host entity, that results in sending the following request: DELETE /api/storageconnections/85afd2fb-fcdd-4b99-a863-9c6143614ce <host/> This empty <host/> element triggers a NPE in the RESTAPI. In my opinion we should change the storage connections delete operation so that it takes an Action as parameter, like all other delete operations. This action can contain a Host, so we still can pass a host as parameter. This is a small backwards compatibility breakage, but one that is justified. We should also add validations in the storage connections resource to validate that when a host is provided its id or name is provided as well, as trying to access that is what is triggering the NPE. (In reply to Juan Hernández from comment #1) > In my opinion we should change the storage connections delete operation so > that it takes an Action as parameter, like all other delete operations. This > action can contain a Host, so we still can pass a host as parameter. This is > a small backwards compatibility breakage, but one that is justified. Agreed. What is the new/correct way to delete this object after this patch? If you are using directly the REST API it should be like this: #!/bin/sh -ex url="https://ovirt.example.com/ovirt-engine/api" user="admin@internal" password="******" storageconnectionid="..." curl \ --verbose \ --insecure \ --request DELETE \ --user "${user}:${password}" \ --header "Content-Type: application/xml" \ --header "Accept: application/xml" \ --data "\ <action/> " \ "${url}/storageconnections/${storageconnectionid}" If you are using the Python SDK: #!/usr/bin/python import ovirtsdk.api import ovirtsdk.xml api = ovirtsdk.api.API( url="https://ovirt.example.com/ovirt-engine/api", username="admin@internal", password="******", ca_file="/etc/pki/ovirt-engine/ca.pem", ) storageconnectionid = "..." action = ovirtsdk.xml.params.Action() api.storageconnections.get(id=storageconnectionid).delete(action) api.disconnect() If you also want to disconnect the storage then you will need to provide the reference to the host that will perform the operation. With a shell script you just need to change the submitted data: <action> <host> <name>myhost</myhost> </host> </action> Or using the host id: <action> <host id="..."/> </action> With the Python SDK change the way the Action object is created: action = ovirtsdk.xml.params.Action( host=ovirtsdk.xml.params.Host(name="myhost") ) Or using the host id: action = ovirtsdk.xml.params.Action( host=ovirtsdk.xml.params.Host(id="...") ) oVirt 3.5 has been released and should include the fix for this issue. |