Bug 1444114
Summary: | Missing association of writers to type in python SDK4 | ||
---|---|---|---|
Product: | [oVirt] ovirt-engine-sdk-python | Reporter: | Fabrice Bacchella <fabrice.bacchella> |
Component: | Core | Assignee: | Juan Hernández <juan.hernandez> |
Status: | CLOSED CURRENTRELEASE | QA Contact: | Petr Matyáš <pmatyas> |
Severity: | medium | Docs Contact: | |
Priority: | unspecified | ||
Version: | 4.1.1 | CC: | bugs, juan.hernandez, lsvaty, omachace, oourfali, stirabos |
Target Milestone: | ovirt-4.1.3 | Flags: | rule-engine:
ovirt-4.1+
lsvaty: testing_ack+ |
Target Release: | 4.1.4 | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | python-ovirt-engine-sdk4-4.1.4 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2017-07-06 13:25:31 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | Infra | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Fabrice Bacchella
2017-04-20 15:25:26 UTC
This can be addressed adding to the SDK a new Writer.write method that can be used to generate the XML for any SDK object: from ovirtsdk4 import types from ovirtsdk4 import writer from ovirtsdk4 import writers vm = types.Vm( id='123', name='myvm', ... ) xml = writer.Writer.write(vm) print(xml) Note that this Writer class (and the equivalent Reader class) are part of the contract of the SDK, and will be kept backwards compatible. But the specific writer and reader classes, for example VmWriter and VmReader, are internal implementation details and they may change at any point without notice. So avoid using them. I have started to write some code to wrap together services, types and writer. Declaring a new set can be as simple as : import ovlib.verb from ovlib import ListObjectWrapper, ObjectWrapper, wrapper from ovirtsdk4.types import Event from ovirtsdk4.services import EventService, EventsService from ovirtsdk4.writers import EventWriter @wrapper(writer_class=EventWriter, type_class=Event, service_class=EventService) class EventWrapper(ObjectWrapper): pass @wrapper(service_class=EventsService, service_root="events") class EventsWrapper(ListObjectWrapper): pass The relevant code for can be found at : https://github.com/fbacchella/ovirtcmd/blob/sdk4/ovlib/__init__.py#L193 Remember that the content of the ovirtsdk4.writers package is an internal implementation detail, and that it can change or dissappear at any time without notice. Until this bug is closed, I have no other choices. Verified on 4.1.3-2 |