Re: [ovirt-users] Python SDK .remove() does not return True?
On Sun, Dec 18, 2016 at 9:34 PM, Yaniv Kaul wrote: > > > On Dec 18, 2016 8:39 PM, "Juan Hernández" 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/__init__.py#L37 > TIA, > Y. > > > > > ___ > Users mailing list > Users@ovirt.org > http://lists.ovirt.org/mailman/listinfo/users > ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [ovirt-users] Python SDK .remove() does not return True?
On Dec 18, 2016 8:39 PM, "Juan Hernández" 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. ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [ovirt-users] Python SDK .remove() does not return True?
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. ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users