The function FeatureTests.disable_libvirt_error_logging only removes the
error message that will be displayed on the console. Libvirt also logs
errors on messages log. To avoid flood messages log with metadata errors,
it will be verified manually if the xml has the tag.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
Changes:
v3:
Discard all code writed before. Aline suggested me a nice workaround, check
if the xml has metadata tag.
---
src/kimchi/model/utils.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/model/utils.py b/src/kimchi/model/utils.py
index 0c9d519..d4994d5 100644
--- a/src/kimchi/model/utils.py
+++ b/src/kimchi/model/utils.py
@@ -84,7 +84,8 @@ def _kimchi_set_metadata_node(dom, node):
def libvirt_get_kimchi_metadata_node(dom, mode="current"):
- FeatureTests.disable_libvirt_error_logging()
+ if not metadata_exists(dom):
+ return None
try:
xml = dom.metadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT,
KIMCHI_META_URL,
@@ -92,8 +93,6 @@ def libvirt_get_kimchi_metadata_node(dom, mode="current"):
return etree.fromstring(xml)
except libvirt.libvirtError:
return None
- finally:
- FeatureTests.enable_libvirt_error_logging()
def set_metadata_node(dom, node, metadata_support, mode="all"):
@@ -151,3 +150,12 @@ def get_metadata_node(dom, tag, metadata_support,
mode="current"):
if node is not None:
return etree.tostring(node)
return ""
+
+def metadata_exists(dom):
+ xml = dom.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE)
+ root = etree.fromstring(xml)
+
+ if root.find("metadata") == None:
+ return False
+ return True
+
--
2.1.0
Show replies by date
Consider v4 plz
On 06/04/2015 12:45 AM, Ramon Medeiros wrote:
Changes:
v3:
Discard all code writed before. Aline suggested me a nice workaround, check
if the xml has metadata tag.
--
Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
ramonn(a)br.ibm.com