Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 770971 - Expose 'virDomain{Get,Set}InterfaceParameters' APIs in python binding
Expose 'virDomain{Get,Set}InterfaceParameters' APIs in python binding
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.3
x86_64 Linux
high Severity high
: rc
: ---
Assigned To: Alex Jia
Virtualization Bugs
:
: 771015 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-30 11:40 EST by Alex Jia
Modified: 2012-06-20 02:40 EDT (History)
6 users (show)

See Also:
Fixed In Version: libvirt-0.9.10-2.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-06-20 02:40:49 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-12-30 11:40:23 EST
Description of problem:
Expose 'virDomain{Get,Set}InterfaceParameters' API in python binding.

Version-Release number of selected component (if applicable):
# rpm -q libvirt
libvirt-0.9.9-0rc1.el6.x86_64

How reproducible:
always

Steps to Reproduce:

Run the following codes in interactive python:

import libvirt
con = libvirt.open(None)
dom = con.lookupByName('foo')
dom.interfaceParameters('vnet0', None, None, 0)
dom.setInterfaceParameters('vnet0', None, None, 0)
  
Actual results:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    print dom.interfaceParameters('vnet0', None, None, 0)
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 635, in interfaceParameters
    ret = libvirtmod.virDomainGetInterfaceParameters(self._o, device, params, nparams, flags)
AttributeError: 'module' object has no attribute 'virDomainGetInterfaceParameters'


Traceback (most recent call last):
  File "test.py", line 5, in <module>
    print dom.setInterfaceParameters('vnet0', None, None, 0)
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 1140, in setInterfaceParameters
    ret = libvirtmod.virDomainSetInterfaceParameters(self._o, device, params, nparams, flags)
AttributeError: 'module' object has no attribute 'virDomainSetInterfaceParameters'

Expected results:
Expose them.

Additional info:

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

# nm -a -D /usr/lib64/python2.6/site-packages/libvirtmod.
so|grep virDomainSetInterfaceParameters
Comment 1 Alex Jia 2012-01-18 04:39:20 EST
Patch for upstream:
https://www.redhat.com/archives/libvir-list/2012-January/msg00695.html
Comment 2 Alex Jia 2012-01-18 04:42:52 EST
*** Bug 771015 has been marked as a duplicate of this bug. ***
Comment 3 Alex Jia 2012-02-15 22:11:14 EST
In POST:
commit 8b29c4598609d9b22a39e6f6bf3bf7afe8303faa
Author: Alex Jia <ajia@redhat.com>
Date:   Tue Feb 14 10:46:23 2012 +0800

    python: Expose virDomain{G,S}etInterfaceParameters APIs in python binding
    
    The v4 patch corrects indentation issues.
    
    The v3 patch follows latest python binding codes and change 'size'
    type from int to Py_ssize_t.
    
    An simple example to show how to use it:
    
    #!/usr/bin/env python
    
    import libvirt
    
    conn = libvirt.open(None)
    dom = conn.lookupByName('foo')
    
    print dom.interfaceParameters('vnet0', 0)
    
    params = {'outbound.peak': 10,
              'inbound.peak': 10,
              'inbound.burst': 20,
              'inbound.average': 20,
              'outbound.average': 30,
              'outbound.burst': 30}
    
    print dom.setInterfaceParameters('vnet0', params, 0)
    print dom.interfaceParameters('vnet0', 0)
    
    Signed-off-by: Alex Jia <ajia@redhat.com>
Comment 6 Wayne Sun 2012-02-22 02:59:22 EST
# rpm -q libvirt libvirt-python
libvirt-0.9.10-2.el6.x86_64
libvirt-python-0.9.10-2.el6.x86_64

1. prepare a running domain
# virsh start dom_test

2. check with python
# 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)
>>> domobj = conn.lookupByName("dom_test")
>>> domobj.interfaceParameters("vnet0", 0)
{'outbound.peak': 0, 'inbound.peak': 0, 'inbound.burst': 0, 'inbound.average': 0, 'outbound.average': 0, 'outbound.burst': 0}
>>> domobj.interfaceParameters("vnet0", 1)
{'outbound.peak': 0, 'inbound.peak': 0, 'inbound.burst': 0, 'inbound.average': 0, 'outbound.average': 0, 'outbound.burst': 0}
>>> params = {'outbound.peak': 40, 'inbound.peak': 40, 'inbound.burst': 20, 'inbound.average': 20, 'outbound.average': 30, 'outbound.burst': 30}
>>> domobj.setInterfaceParameters("vnet0", params, 0)
0
>>> domobj.interfaceParameters("vnet0", 1)
{'outbound.peak': 40, 'inbound.peak': 40, 'inbound.burst': 20, 'inbound.average': 20, 'outbound.average': 30, 'outbound.burst': 30}
>>> domobj.interfaceParameters("vnet0", 0)
{'outbound.peak': 40, 'inbound.peak': 40, 'inbound.burst': 20, 'inbound.average': 20, 'outbound.average': 30, 'outbound.burst': 30}
>>> domobj.setInterfaceParameters("54:52:00:98:92:8d", params, 2)
0

destroy domian in another console
# virsh destroy dom_test

recheck with python
>>> domobj.interfaceParameters("54:52:00:98:92:8d", 2)
{'outbound.peak': 40, 'inbound.peak': 40, 'inbound.burst': 20, 'inbound.average': 20, 'outbound.average': 30, 'outbound.burst': 30}
>>> domobj.interfaceParameters("54:52:00:98:92:8d", 0)
{'outbound.peak': 40, 'inbound.peak': 40, 'inbound.burst': 20, 'inbound.average': 20, 'outbound.average': 30, 'outbound.burst': 30}
>>> 


so, this is fixed.
Comment 8 errata-xmlrpc 2012-06-20 02:40:49 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.