Python SDK .remove() does not return True?

I'd expect, like other actions, add() for example, that I can ensure .remove() (for clusters, DCs, etc.) will return True as a sign for success. Is that a bug or a design choice? TIA, Y.

On 12/18/2016 05:32 PM, Yaniv Kaul wrote:
I'd expect, like other actions, add() for example, that I can ensure .remove() (for clusters, DCs, etc.) will return True as a sign for success. Is that a bug or a design choice? TIA, Y.
It is by design. The method returns nothing, because in HTTP the DELETE method doesn't receive or return a body: it only returns the HTTP status code. In the SDK, success HTTP status code results in returning nothing, and failures result in throwing an exception. So, if the methods doesn't throw an exception then you can assume that it worked successfully.

On Dec 18, 2016 8:39 PM, "Juan Hernández" <jhernand@redhat.com> wrote: On 12/18/2016 05:32 PM, Yaniv Kaul wrote:
I'd expect, like other actions, add() for example, that I can ensure .remove() (for clusters, DCs, etc.) will return True as a sign for success. Is that a bug or a design choice? TIA, Y.
It is by design. The method returns nothing, because in HTTP the DELETE method doesn't receive or return a body: it only returns the HTTP status code. In the SDK, success HTTP status code results in returning nothing, and failures result in throwing an exception. So, if the methods doesn't throw an exception then you can assume that it worked successfully. So I should wrap it in try-except? And catch what? TIA, Y.

On Sun, Dec 18, 2016 at 9:34 PM, Yaniv Kaul <ykaul@redhat.com> wrote:
On Dec 18, 2016 8:39 PM, "Juan Hernández" <jhernand@redhat.com> wrote:
On 12/18/2016 05:32 PM, Yaniv Kaul wrote:
I'd expect, like other actions, add() for example, that I can ensure .remove() (for clusters, DCs, etc.) will return True as a sign for success. Is that a bug or a design choice? TIA, Y.
It is by design. The method returns nothing, because in HTTP the DELETE method doesn't receive or return a body: it only returns the HTTP status code. In the SDK, success HTTP status code results in returning nothing, and failures result in throwing an exception. So, if the methods doesn't throw an exception then you can assume that it worked successfully.
So I should wrap it in try-except? And catch what?
Yes, it should catch the Error[1] exception. [1] https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/lib/ovirtsdk4/__in...
TIA, Y.
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
participants (3)
-
Juan Hernández
-
Ondra Machacek
-
Yaniv Kaul