From Dan Kenigsberg <danken(a)redhat.com>:
Dan Kenigsberg has submitted this change and it was merged.
Change subject: virt: add the metadata module
......................................................................
virt: add the metadata module
Add module to act as central facade for the libvirt domain metadata.
The module provides classes to get/set data from either ElementTree,
to be used in the VM run flow, or from a libvirt Domain object, to be
used once the VM is running (e.g. hot(un)plug flows).
We use a custom serialization formats which tries to be compact and
readable, while mimicing the current schema as much as we can.
The code adds type hints to the XML elements to be able
to unmarshal the correct python types.
The module intentionally doesn't do any validation.
Should schema validation be needed, we will add one specific step.
Notes:
1. at XML define time, we must take care of namespaces ourselves,
and add prefixes to all the elements we add in the metadata area.
2. once the domain is succesfully started, and we access the metadata
elements using dom.metadata() and dom.setMetadata(), libvirt takes
care automatically of prefixing elements (including all
subelements) with their namespace string; so we must NOT do that
ourselves, otherwise we can end up with something illegal like
ovirt-vm:ovirt-vm:vm
^ ^ ^
| | `- the element name the code wants to use
| `- added by this module
`- added by libvirt
3. the API was simplified to only take care of marshalling and
unmarshalling python key/values to XML. Since we either
disallow or completely control nesting (e.g. device metadata)
we don't need anything extra besides our existing XML
processing tools (e.g. no dependency on 3rd party complex libs).
Change-Id: Iab8a1a78a8efce3200e66285cc37211132fcb247
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M lib/vdsm/virt/Makefile.am
A lib/vdsm/virt/metadata.py
A tests/virttests/metadata_test.py
M vdsm.spec.in
4 files changed, 480 insertions(+), 0 deletions(-)
Approvals:
Jenkins CI: Passed CI tests
Dan Kenigsberg: Looks good to me, approved
Francesco Romani: Verified
Martin Polednik: Looks good to me, but someone else must approve
Milan Zamazal: Looks good to me, but someone else must approve
--
To view, visit
https://gerrit.ovirt.org/74206
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iab8a1a78a8efce3200e66285cc37211132fcb247
Gerrit-PatchSet: 17
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Milan Zamazal <mzamazal(a)redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation(a)ovirt.org>