[Kimchi-devel] [PATCH 2/4] Allow setting multiple metadata nodes at once
Aline Manera
alinefm at linux.vnet.ibm.com
Tue Sep 1 22:49:09 UTC 2015
Sometimes it is useful to update multiple metadata nodes so allow it to
be done in one single virDomain.setMetadata() call.
Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
src/kimchi/model/utils.py | 6 ++++--
src/kimchi/model/vms.py | 4 ++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/kimchi/model/utils.py b/src/kimchi/model/utils.py
index c053807..feb67d9 100644
--- a/src/kimchi/model/utils.py
+++ b/src/kimchi/model/utils.py
@@ -71,11 +71,13 @@ def get_kimchi_metadata_node(dom, mode="current"):
return None
-def set_metadata_node(dom, node, mode="all"):
+def set_metadata_node(dom, nodes, mode="all"):
kimchi = get_kimchi_metadata_node(dom, mode)
kimchi = E.metadata() if kimchi is None else kimchi
- update_node(kimchi, node)
+ for n in nodes:
+ update_node(kimchi, n)
+
kimchi_xml = etree.tostring(kimchi)
# From libvirt doc, Passing None for @metadata says to remove that
# element from the domain XML (passing the empty string leaves the
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index a1f1798..fc2c92d 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -543,7 +543,7 @@ class VMModel(object):
return
node = self._build_access_elem(dom, users, groups)
- set_metadata_node(dom, node)
+ set_metadata_node(dom, [node])
def _get_access_info(self, dom):
users = groups = list()
@@ -578,7 +578,7 @@ class VMModel(object):
if distro is None:
return
os_elem = E.os({"distro": distro, "version": version})
- set_metadata_node(dom, os_elem)
+ set_metadata_node(dom, [os_elem])
def _update_graphics(self, dom, xml, params):
root = objectify.fromstring(xml)
--
2.1.0
More information about the Kimchi-devel
mailing list