Bug 1444114 - Missing association of writers to type in python SDK4
Summary: Missing association of writers to type in python SDK4
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine-sdk-python
Classification: oVirt
Component: Core
Version: 4.1.1
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ovirt-4.1.3
: 4.1.4
Assignee: Juan Hernández
QA Contact: Petr Matyáš
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-04-20 15:25 UTC by Fabrice Bacchella
Modified: 2017-07-06 13:25 UTC (History)
6 users (show)

Fixed In Version: python-ovirt-engine-sdk4-4.1.4
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-06 13:25:31 UTC
oVirt Team: Infra
Embargoed:
rule-engine: ovirt-4.1+
lsvaty: testing_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 75699 0 master MERGED Add generic writer 2020-06-04 10:17:54 UTC
oVirt gerrit 75735 0 sdk_4.1 MERGED Add generic writer 2020-06-04 10:17:54 UTC

Description Fabrice Bacchella 2017-04-20 15:25:26 UTC
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 ?

Comment 1 Juan Hernández 2017-04-20 15:33:33 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.

Comment 2 Fabrice Bacchella 2017-05-03 08:29:06 UTC
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

Comment 3 Juan Hernández 2017-05-03 08:35:07 UTC
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.

Comment 4 Fabrice Bacchella 2017-05-03 08:40:55 UTC
Until this bug is closed, I have no other choices.

Comment 5 Petr Matyáš 2017-06-02 13:01:57 UTC
Verified on 4.1.3-2


Note You need to log in before you can comment on or make changes to this bug.