Bug 490572

Summary: three methods having the same name createXML() in the libvirt.py
Product: Red Hat Enterprise Linux 5 Reporter: Gunannan Ren <gren>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.4CC: apevec, berrange, crobinso, dallan, llim, nzhang, tyan, virt-maint, xen-maint
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-02 09:22:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Fix python generator none

Description Gunannan Ren 2009-03-17 02:36:53 UTC
Description of problem:

in the libvirt.py module in the libvirt-python version 0.6.1-1, there are three  
methods having the same name createXML() in the virConnect Class. It make confused to call the related function.

Version-Release number of selected component (if applicable):

libvirt-0.6.1-1 
libvirt-0.5.1-4.2

How reproducible:



Steps to Reproduce:
1.
2.
3.
  
Actual results:

make function call confused.

Expected results:

make it clear 

Additional info:

Comment 1 Daniel Berrangé 2009-03-18 11:16:54 UTC
Confirmed :-(

    def createXML(self, xmlDesc, flags):
        """Create a new storage based on its XML description. The pool
          is not persistent, so its definition will disappear when it
           is destroyed, or if the host is restarted """
        ret = libvirtmod.virStoragePoolCreateXML(self._o, xmlDesc, flags)
        if ret is None:raise libvirtError('virStoragePoolCreateXML() failed', conn=self)
        __tmp = virStoragePool(self, _obj=ret)
        return __tmp

    def createXML(self, xmlDesc):
        """Create and start a new virtual network, based on an XML
          description similar to the one returned by
           virNetworkGetXMLDesc() """
        ret = libvirtmod.virNetworkCreateXML(self._o, xmlDesc)
        if ret is None:raise libvirtError('virNetworkCreateXML() failed', conn=self)
        __tmp = virNetwork(self, _obj=ret)
        return __tmp

    def createXML(self, xmlDesc, flags):
        """Launch a new guest domain, based on an XML description
          similar to the one returned by virDomainGetXMLDesc() This
          function may requires privileged access to the hypervisor.
          The domain is not persistent, so its definition will
          disappear when it is destroyed, or if the host is restarted
           (see virDomainDefineXML() to define persistent domains). """
        ret = libvirtmod.virDomainCreateXML(self._o, xmlDesc, flags)
        if ret is None:raise libvirtError('virDomainCreateXML() failed', conn=self)
        __tmp = virDomain(self,_obj=ret)
        return __tmp




It is also generating bogus public APis for an internal method

    def ref(self):
        """Increment the reference count on the connection. For each
          additional call to this method, there shall be a
          corresponding call to virConnectClose to release the
          reference count, once the caller no longer needs the
          reference to this object.  This method is typically useful
          for applications where multiple threads are using a
          connection, and it is required that the connection remain
          open until all threads have finished using it. ie, each new
          thread using a connection would increment the reference
           count. """
        ret = libvirtmod.virConnectRef(self._o)
        if ret == -1: raise libvirtError ('virConnectRef() failed', conn=self)
        return ret


And several other 'ref' methods later

Comment 2 Alex Jia 2009-03-28 07:28:34 UTC
I suggest to rename createXML,like this:

createXML-->CreateStoragePoolXML               :virStoragePoolCreateXML
createXML-->CreateNetworkXML                   :virNetworkCreateXML
createXML-->CreateDomainXML                    :virDomainCreateXML

Comment 3 Perry Myers 2009-03-31 03:15:54 UTC
Moving to RHEL since libvirt is not supported in RHEV1.0 production builds and this problem will need to be addressed in RHEL5.4 release

Comment 4 Daniel Berrangé 2009-03-31 11:36:19 UTC
Created attachment 337290 [details]
Fix python generator

Comment 5 Daniel Berrangé 2009-03-31 12:19:48 UTC
Posted upstream

http://www.redhat.com/archives/libvir-list/2009-March/msg00493.html

Comment 6 Daniel Veillard 2009-06-05 19:00:47 UTC
That patch was actually included as part of the 0.6.3 rebase, so the fix
is in the current build,

Daniel

Comment 9 Nan Zhang 2009-06-08 07:51:07 UTC
Checking with "/usr/lib64/python2.4/site-packages/libvirt.py", the following function was renamed with the different name, and fixed this problem.

    def createXML(self, xmlDesc, flags):
        """Launch a new guest domain, based on an XML description
          similar to the one returned by virDomainGetXMLDesc() This
          function may requires privileged access to the hypervisor.
          The domain is not persistent, so its definition will
          disappear when it is destroyed, or if the host is restarted
           (see virDomainDefineXML() to define persistent domains). """
        ret = libvirtmod.virDomainCreateXML(self._o, xmlDesc, flags)
        if ret is None:raise libvirtError('virDomainCreateXML() failed', conn=self)
        __tmp = virDomain(self,_obj=ret)
        return __tmp

    def networkCreateXML(self, xmlDesc):
        """Create and start a new virtual network, based on an XML
          description similar to the one returned by
           virNetworkGetXMLDesc() """
        ret = libvirtmod.virNetworkCreateXML(self._o, xmlDesc)
        if ret is None:raise libvirtError('virNetworkCreateXML() failed', conn=self)
        __tmp = virNetwork(self, _obj=ret)
        return __tmp

    def storagePoolCreateXML(self, xmlDesc, flags):
        """Create a new storage based on its XML description. The pool
          is not persistent, so its definition will disappear when it
           is destroyed, or if the host is restarted """
        ret = libvirtmod.virStoragePoolCreateXML(self._o, xmlDesc, flags)
        if ret is None:raise libvirtError('virStoragePoolCreateXML() failed', conn=self)
        __tmp = virStoragePool(self, _obj=ret)
        return __tmp


This bug has been verified with libvirt 0.6.3-6 on RHEL-5.4.

Comment 11 errata-xmlrpc 2009-09-02 09:22:23 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2009-1269.html