[Libvirt-cim] Problem of Python dependancies

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Aug 14 22:30:36 UTC 2009


Daniel Veillard wrote:
>   Hi,
> 
> trying to run the testsuite as checkout from hg today on a Fedora 11
> box I got the following error:
> 
> [root at paphio cimtest]# CIM_NS=root/virt CIM_USER=root CIM_PASS=xxxxxx
> ./runtests libvirt-cim -v KVM -i  localhost
> Starting test suite: libvirt-cim
> Traceback (most recent call last):
>   File "main.py", line 41, in <module>
>     from XenKvmLib.common_util import create_netpool_conf,
> destroy_netpool, \
>   File "./lib/XenKvmLib/common_util.py", line 29, in <module>
>     from XenKvmLib.test_xml import *
>   File "./lib/XenKvmLib/test_xml.py", line 32, in <module>
>     from xml import xpath
> ImportError: cannot import name xpath

This error is caused by a missing PyXML / pyxml package.  This is 
mentioned as a requirement on our wiki 
(http://wiki.libvirt.org/page/Cimtest_setup), but not on our main webpage.

I've been meaning to update the documentation on the webpage for awhile 
now.  I'll add cimtest instructions to the list of items I need to 
update. =)

> 
>  Looking at suites/libvirt-cim/lib/XenKvmLib/test_xml.py

This file should be removed, as it is obsolete.  A few tests still 
reference it, but those should be updated as the functionality in 
test_xml.py has been replaced by suites/libvirt-cim/lib/XenKvmLib/vxml.py

> it seems to try to use the native xml support of Python
> 
> from xml import xpath
> from xml.dom import minidom, Node
> 
> to implement:
> 
> ------------------------------------------------
> def get_value_xpath(xmlStr, xpathStr):
>     xmldoc = minidom.parseString(xmlStr)
>     nodes = xpath.Evaluate(xpathStr, xmldoc.documentElement)
> 
>     if len(nodes) != 1:
>         raise LookupError('Zero or multiple xpath results found!')
> 
>     node = nodes[0]
>     if node.nodeType == Node.ATTRIBUTE_NODE:
>         return node.value
>     if node.nodeType == Node.TEXT_NODE:
>         return node.toxml()
>     if node.nodeType == Node.ELEMENT_NODE:
>         ret = ''
>         for child in node.childNodes:
>             ret = ret + child.toxml()
>         return ret
> --------------------------------------------------
> 
>  Then get_value_xpath() is used in the module to poke various values.
> First it's not really optimal, the XML should probably be parsed once
> but the performance impact is really neglectible :-)
> 
>   Is there a workaround to have that code run on a standard Fedora 11
> setup or did I missed anything ?
> 
>   I wonder if there are other uses of xml::xpath in the regression
> suite. In any case it might be a good idea to use libxml2 bindings
> instead since libvirt uses libxml2 it's not likely to be a problem

Would you recommend using libxml2 over using PyXML?

> and would avoid this kind of Python XML portability problems. I may
> even provide the trivial patch to replace that fragment of code (but
> if there is many other use of python xml code in the test suite, that's
> a different matter :-)
> 
>   thanks,
> 
> Daniel
> 


-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list