I didn't find a way to find the writer that correspond to a given type. Is there a way to do that, or it's up to the end user to manually manage this mapping ?
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