Bug 490572 - three methods having the same name createXML() in the libvirt.py
three methods having the same name createXML() in the libvirt.py
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: libvirt (Show other bugs)
5.4
All Linux
medium Severity medium
: rc
: ---
Assigned To: Daniel Veillard
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-03-16 22:36 EDT by Gunannan Ren
Modified: 2016-04-26 10:33 EDT (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-09-02 05:22:23 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Fix python generator (956 bytes, patch)
2009-03-31 07:36 EDT, Daniel Berrange
no flags Details | Diff

  None (edit)
Description Gunannan Ren 2009-03-16 22:36:53 EDT
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 Berrange 2009-03-18 07:16:54 EDT
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 03:28:34 EDT
I suggest to rename createXML,like this:

createXML-->CreateStoragePoolXML               :virStoragePoolCreateXML
createXML-->CreateNetworkXML                   :virNetworkCreateXML
createXML-->CreateDomainXML                    :virDomainCreateXML
Comment 3 Perry Myers 2009-03-30 23:15:54 EDT
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 Berrange 2009-03-31 07:36:19 EDT
Created attachment 337290 [details]
Fix python generator
Comment 5 Daniel Berrange 2009-03-31 08:19:48 EDT
Posted upstream

http://www.redhat.com/archives/libvir-list/2009-March/msg00493.html
Comment 6 Daniel Veillard 2009-06-05 15:00:47 EDT
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 03:51:07 EDT
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 05:22:23 EDT
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

Note You need to log in before you can comment on or make changes to this bug.