[Libvir] Generate python binding for network APIs

I was about to make use of the new networking APIs in virt-manager/virt-install when I discovered we don't have any python binding for it. Attached is the quickest patch I could write to support it - I basically copied all the virDomain related bits & s/Domain/Network/ throughout. A simple demo script works: #!/usr/bin/python import libvirt con = libvirt.open(None) n = con.listNetworks() print str(n) for name in n: net = con.lookupByName(name) print net.XMLDesc(0) print net.bridgeName() I think there are a couple more methods which need manual implementations though - eg UUIDString() is generated incorrectly - in fact the UUIDString() impl for virDomains is already broken, and so is the binding for VCPU pinning. Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Fri, Mar 09, 2007 at 01:42:29AM +0000, Daniel P. Berrange wrote:
I was about to make use of the new networking APIs in virt-manager/virt-install when I discovered we don't have any python binding for it. Attached is the quickest patch I could write to support it - I basically copied all the virDomain related bits & s/Domain/Network/ throughout. A simple demo script works:
#!/usr/bin/python
import libvirt
con = libvirt.open(None)
n = con.listNetworks() print str(n) for name in n: net = con.lookupByName(name) print net.XMLDesc(0) print net.bridgeName()
I think there are a couple more methods which need manual implementations though - eg UUIDString() is generated incorrectly - in fact the UUIDString() impl for virDomains is already broken, and so is the binding for VCPU pinning.
Okay, that looks good to me and considering that I would like to push a new release real soon, it would be a bit sad to not have the python bindings for the new functionalities. Please apply :-), thanks ! On a related note, I think I would be ready to drop the generator stuff in some recent future, I can see how it makes things rather harder, and does not provide that much value considering we are trying to keep a rather small API. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Fri, Mar 09, 2007 at 04:24:34AM -0500, Daniel Veillard wrote:
On Fri, Mar 09, 2007 at 01:42:29AM +0000, Daniel P. Berrange wrote:
I was about to make use of the new networking APIs in virt-manager/virt-install when I discovered we don't have any python binding for it. Attached is the quickest patch I could write to support it - I basically copied all the virDomain related bits & s/Domain/Network/ throughout. A simple demo script works:
#!/usr/bin/python
import libvirt
con = libvirt.open(None)
n = con.listNetworks() print str(n) for name in n: net = con.lookupByName(name) print net.XMLDesc(0) print net.bridgeName()
I think there are a couple more methods which need manual implementations though - eg UUIDString() is generated incorrectly - in fact the UUIDString() impl for virDomains is already broken, and so is the binding for VCPU pinning.
Okay, that looks good to me and considering that I would like to push a new release real soon, it would be a bit sad to not have the python bindings for the new functionalities. Please apply :-), thanks ! On a related note, I think I would be ready to drop the generator stuff in some recent future, I can see how it makes things rather harder, and does not provide that much value considering we are trying to keep a rather small API.
I figure we can just take the current auto-generated C code and commit that to CVS, and remove the generator rules/scripts. Then we can incrementally cleanup the C code over time. The actual generated code is fairly sane and clear already. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Fri, 2007-03-09 at 01:42 +0000, Daniel P. Berrange wrote:
I was about to make use of the new networking APIs in virt-manager/virt-install when I discovered we don't have any python binding for it. Attached is the quickest patch I could write to support it
I've only glanced at it, but it looks fine to me. Cheers, Mark.
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Mark McLoughlin