Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 748742 - Expose 'virNodeGetMemoryStats' and 'virNodeGetCPUStats' APIs in python binding
Expose 'virNodeGetMemoryStats' and 'virNodeGetCPUStats' APIs in python binding
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.2
x86_64 Linux
high Severity high
: rc
: ---
Assigned To: Peter Krempa
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-25 04:47 EDT by Alex Jia
Modified: 2012-06-20 02:36 EDT (History)
6 users (show)

See Also:
Fixed In Version: libvirt-0.9.9-1.el6
Doc Type: Bug Fix
Doc Text:
No Documentation needed
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-06-20 02:36:02 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)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0748 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2012-06-19 15:31:38 EDT

  None (edit)
Description Alex Jia 2011-10-25 04:47:52 EDT
Description of problem:
Virsh nodecpustats and nodememstats are find, need to expose 'virNodeGetMemoryStats' and 'virNodeGetCPUStats' APIs in python binding.


Version-Release number of selected component (if applicable):
libvirt-python-0.9.4-19.el6.x86_64

How reproducible:
always

Steps to Reproduce:
# python
Python 2.6.6 (r266:84292, Apr 11 2011, 15:50:32) 
[GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> con = libvirt.open(None)
>>> con.getCPUStats(-1, None, 0, 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 2173, in getCPUStats
    ret = libvirtmod.virNodeGetCPUStats(self._o, cpuNum, params, nparams, flags)
AttributeError: 'module' object has no attribute 'virNodeGetCPUStats'
>>> con.getMemoryStats(-1, None, 0, 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 2245, in getMemoryStats
    ret = libvirtmod.virNodeGetMemoryStats(self._o, cellNum, params, nparams, flags)
AttributeError: 'module' object has no attribute 'virNodeGetMemoryStats'
  
Actual results:
'module' object has no attribute 'virNodeGetCPUStats' and'virNodeGetMemoryStats'.

Expected results:
expose them in python binding.


Additional info:

# nm -a -D /usr/lib64/python2.6/site-packages/libvirtmod.so |grep virNodeGetCPUStats
# nm -a -D /usr/lib64/python2.6/site-packages/libvirtmod.so |grep virNodeGetMemoryStats

Notes, nothing return.
Comment 2 Peter Krempa 2011-12-05 06:52:52 EST
Requested functions were exported with upstream commits:
commit 17c7795561f408814a6925966d5ef57aaf17f7f2
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Mon Nov 28 18:19:28 2011 +0100

    python: Expose binding for virNodeGetMemoryStats()
    
    This patch adds binding for virNodeGetMemoryStats method of libvirtd.
    Return value is represented as a python dictionary mapping field
    names to values.

commit 49556023f28d7960c3a27b4a30270dcac08c5e52
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Mon Nov 28 18:19:27 2011 +0100

    python: Expose binding for virNodeGetCPUStats()
    
    This patch adds binding for virNodeGetCPUStats method of libvirtd.
    Return value is represented as a python dictionary mapping field names
    to values.


Tested with code:
import libvirt
conn = libvirt.open('qemu:///system')
mem = conn.getMemoryStats(libvirt.VIR_NODE_MEMORY_STATS_ALL_CELLS, 0)
cpu = conn.getCPUStats(libvirt.VIR_NODE_CPU_STATS_ALL_CPUS, 0)
print mem
print cpu

Result:
{'cached': 809104L, 'total': 2027708L, 'buffers': 70756L, 'free': 553156L}
{'kernel': 191770000000L, 'idle': 3176360000000L, 'user': 711340000000L, 'iowait': 92490000000L}
Comment 4 Wayne Sun 2012-01-10 05:05:08 EST
# python
Python 2.6.6 (r266:84292, Sep 12 2011, 14:03:14) 
[GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> conn = libvirt.open(None)
>>> conn.getCPUStats(libvirt.VIR_NODE_CPU_STATS_ALL_CPUS, 0)
{'kernel': 1155780000000L, 'idle': 161385760000000L, 'user': 1524500000000L, 'iowait': 319040000000L}
>>> conn.getMemoryStats(libvirt.VIR_NODE_MEMORY_STATS_ALL_CELLS, 0)
{'cached': 493128L, 'total': 3856644L, 'buffers': 140576L, 'free': 3000864L}
>>> 


so, this is fixed.
Comment 5 Wayne Sun 2012-01-10 05:20:21 EST
(In reply to comment #4)
> # python
> Python 2.6.6 (r266:84292, Sep 12 2011, 14:03:14) 
> [GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import libvirt
> >>> conn = libvirt.open(None)
> >>> conn.getCPUStats(libvirt.VIR_NODE_CPU_STATS_ALL_CPUS, 0)
> {'kernel': 1155780000000L, 'idle': 161385760000000L, 'user': 1524500000000L,
> 'iowait': 319040000000L}
> >>> conn.getMemoryStats(libvirt.VIR_NODE_MEMORY_STATS_ALL_CELLS, 0)
> {'cached': 493128L, 'total': 3856644L, 'buffers': 140576L, 'free': 3000864L}
> >>> 
> 
> 
> so, this is fixed.

# rpm -q libvirt libvirt-python
libvirt-0.9.9-1.el6.x86_64
libvirt-python-0.9.9-1.el6.x86_64
Comment 6 Peter Krempa 2012-05-02 05:51:37 EDT
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
No Documentation needed
Comment 8 errata-xmlrpc 2012-06-20 02:36:02 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0748.html

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