Bug 748742 - Expose 'virNodeGetMemoryStats' and 'virNodeGetCPUStats' APIs in python binding
Summary: Expose 'virNodeGetMemoryStats' and 'virNodeGetCPUStats' APIs in python binding
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.2
Hardware: x86_64
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-10-25 08:47 UTC by Alex Jia
Modified: 2012-06-20 06:36 UTC (History)
6 users (show)

Fixed In Version: libvirt-0.9.9-1.el6
Doc Type: Bug Fix
Doc Text:
No Documentation needed
Clone Of:
Environment:
Last Closed: 2012-06-20 06:36:02 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0748 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2012-06-19 19:31:38 UTC

Description Alex Jia 2011-10-25 08:47:52 UTC
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 11:52:52 UTC
Requested functions were exported with upstream commits:
commit 17c7795561f408814a6925966d5ef57aaf17f7f2
Author: Peter Krempa <pkrempa>
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>
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 10:05:08 UTC
# 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 10:20:21 UTC
(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 09:51:37 UTC
    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 06:36:02 UTC
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.