[Libvir] libvirt.py has the two functions that names are the same.

Hi, When I used the lookupByName() function of libvirt.py, it failed with the following error messages. ------ Traceback (most recent call last): File "./virt-install.mod", line 569, in <module> main() File "./virt-install.mod", line 499, in main guest, hvm, conn) File "./virt-install.mod", line 187, in get_disks disk, size) File "./virt-install.mod", line 186, in <lambda> map(lambda d, s: get_disk(d, s, sparse, guest, hvm, conn), File "./virt-install.mod", line 131, in get_disk vm = conn.lookupByName(name) File "/usr/lib/python2.5/site-packages/libvirt.py", line 483, in lookupByName if ret is None:raise libvirtError('virNetworkLookupByName() failed', conn=self) libvirt.libvirtError: virNetworkLookupByName() failed ------ The lookupByName() function is the same name for domain and for network in libvirt.py. The lookupByUUIDstring() function is similar. I think that generator of libvirt.py's function is incorrect. Thanks, Tatsuro Enokura --- cat /usr/lib/python2.5/site-packages/libvirt.py .. snip .. def lookupByName(self, name): """Try to lookup a domain on the given hypervisor based on its name. """ ret = libvirtmod.virDomainLookupByName(self._o, name) if ret is None:raise libvirtError('virDomainLookupByName() failed', conn=self) __tmp = virDomain(_obj=ret) __tmp.ref = self return __tmp def lookupByName(self, name): """Try to lookup a network on the given hypervisor based on its name. """ ret = libvirtmod.virNetworkLookupByName(self._o, name) if ret is None:raise libvirtError('virNetworkLookupByName() failed', conn=self) __tmp = virNetwork(_obj=ret) __tmp.ref = self return __tmp def lookupByUUIDString(self, uuidstr): """Try to lookup a network on the given hypervisor based on its UUID. """ ret = libvirtmod.virNetworkLookupByUUIDString(self._o, uuidstr) if ret is None:raise libvirtError('virNetworkLookupByUUIDString() failed', conn=self) __tmp = virNetwork(_obj=ret) __tmp.ref = self return __tmp def lookupByUUIDString(self, uuidstr): """Try to lookup a domain on the given hypervisor based on its UUID. """ ret = libvirtmod.virDomainLookupByUUIDString(self._o, uuidstr) if ret is None:raise libvirtError('virDomainLookupByUUIDString() failed', conn=self) __tmp = virDomain(_obj=ret) __tmp.ref = self return __tmp .. snip .. --

On Tue, Mar 13, 2007 at 06:38:56PM +0900, Tatsuro Enokura wrote:
Hi,
When I used the lookupByName() function of libvirt.py, it failed with the following error messages. [...] The lookupByName() function is the same name for domain and for network in libvirt.py. The lookupByUUIDstring() function is similar.
I think that generator of libvirt.py's function is incorrect.
Whoops ! That's nasty, I would have expected python to complain in case of double declaration of a method with same number of arguments, especially with a different content. I fixed the generator so that the virNetworkLookup... functions are now mapped as networkLookup... methods, that should fix the problem ! thanks for raising this, I commited the fix in CVS, Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Hi, Dan Daniel Veillard wrote:
When I used the lookupByName() function of libvirt.py, it failed with the following error messages. [...] The lookupByName() function is the same name for domain and for network in libvirt.py. The lookupByUUIDstring() function is similar.
I think that generator of libvirt.py's function is incorrect.
Whoops ! That's nasty, I would have expected python to complain in case of double declaration of a method with same number of arguments, especially with a different content. I fixed the generator so that the virNetworkLookup... functions are now mapped as networkLookup... methods, that should fix the problem !
thanks for raising this, I commited the fix in CVS,
Thanks for fixing. I try today's libvirt. The lookupBy..() methods is fine, but the defineXML() method still have the same problem. The attached patch adds to solve the problem. Signed-off-by: Tatsuro Enokura <fj7716hz@aa.jp.fujitsu.com> Thanks, Tatsuro Enokura Index: python/generator.py =================================================================== RCS file: /data/cvs/libvirt/python/generator.py,v retrieving revision 1.17 diff -u -p -r1.17 generator.py --- python/generator.py 15 Mar 2007 15:23:21 -0000 1.17 +++ python/generator.py 16 Mar 2007 08:14:05 -0000 @@ -583,9 +583,12 @@ def nameFixup(name, classe, type, file): if name[0:l] == listname: func = name[l:] func = string.lower(func[0:1]) + func[1:] + elif name[0:16] == "virNetworkDefine": + func = name[3:] + func = string.lower(func[0:1]) + func[1:] elif name[0:16] == "virNetworkLookup": - func = name[3:] - func = string.lower(func[0:1]) + func[1:] + func = name[3:] + func = string.lower(func[0:1]) + func[1:] elif name[0:12] == "virDomainGet": func = name[12:] func = string.lower(func[0:1]) + func[1:] ====================================================================

On Fri, Mar 16, 2007 at 05:49:11PM +0900, Tatsuro Enokura wrote: Hi Tatsuro,
Thanks for fixing. I try today's libvirt. The lookupBy..() methods is fine, but the defineXML() method still have the same problem.
The attached patch adds to solve the problem.
Heh, good catch I missed it, applied and commited to CVS, thanks a lot, Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (2)
-
Daniel Veillard
-
Tatsuro Enokura