Juan Hernandez has submitted this change and it was merged. Change subject: sdk: Add empty export method to decorator base ......................................................................
sdk: Add empty export method to decorator base Decorators for resources and collections extend a common base class, for example: class VMSnapshotDisks(Base) The resource decorators also extend the corresponding parameter class: class VMSnapshotDisk(params.Disk, Base) This means that resource decorators implement the "export" method, responsible for generating the XML representation of the entity, but collection decorators don't implement it. There are situations where decorators are used as parameters, for example, when creating a VM from a snapshot one could use the following code: snapshot = vm.snapshots.get(id="...") The resulting object is a decorator, and it contains references to decorators of collections, for example to the collection of disks. Later this object can be used as a parameter, as follows: snapshots = ovirtsdk.xml.params.Snapshots() snapshots.add_snapshot(snapshot) newvm = ovirtsdk.xml.params.VM( name="newvm", snapshots=snapshots, ...) api.vms.add(newvm) When doing this the infrastructure will try to generate the XML document, calling the "export" method on the new VM object, and this will recursively call the "export" methods of all the referenced objects, including the collection decorators, which will fail because they don't have such method. This usage is not good practice, and not efficient, it is better to avoid using decorators as parameters: snapshot = ovirtsdk.params.Snapshot(id="...") snapshots = ovirtsdk.params.Snapshots() snapshots.add_snapshot(snapshot) newvm = ovirtsdk.xml.params.VM( name="newvm", snapshots=snapshots, ...) api.vms.add(newvm) As this is difficult to enforce this patch adds to the Base class an empty "export" method, so that these operations won't fail. Change-Id: I6d2e6b9a42ad1a878f8edbbd41f3bb9d60db2bc8 Bug-Url: https://bugzilla.redhat.com/1024696 Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com> --- M src/ovirtsdk/infrastructure/common.py 1 file changed, 6 insertions(+), 0 deletions(-) Approvals: Ravi Nori: Looks good to me, but someone else must approve Juan Hernandez: Verified; Looks good to me, approved -- To view, visit http://gerrit.ovirt.org/32996 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6d2e6b9a42ad1a878f8edbbd41f3bb9d60db2bc8 Gerrit-PatchSet: 2 Gerrit-Project: ovirt-engine-sdk Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com> Gerrit-Reviewer: Juan Hernandez <juan.hernan...@redhat.com> Gerrit-Reviewer: Ravi Nori <rn...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches