pyroute2 release 0.4.0

Peter V. Saveliev peter at svinota.eu
Sun May 8 09:32:14 EDT 2016


pyroute2-0.4.0
--------------

An important release [1] of the most comprehensive Python netlink library.

description
===========

The library is focused on RTNL (though supports other netlink protocols 
as well):

* Interfaces: bridge, bond, vlan, vxlan, vrf, veth, gre, ...
* Bridge vlan filters
* Routes: metrics, multipath, ...
* AF_MPLS routes and MPLS lwtunnel [2]
* Neighbours cache management
* Traffic controls: HTB, TBF, ...
* BPF support [3]
...
* Basic support: nftables, ipset, nl80211, taskstats, ...
...
* Netns support (not via netlink :)


socket level
============

On the low level the library provides socket-like objects. They support 
all the normal socket methods like `sendmsg()`, `recv()`, `fileno()`, 
can be used in `poll()`/`select()`. But they also provide utility 
functions that implement specific protocol features, e.g.:

`IPRoute`:
* `link()` -- manage network interfaces,
* `addr()` -- ... addresses,
* `route()` -- ... routes,
...

`IPSet`:
* `list()`
* `create()`
* `destroy()`
...

`IW`:
* `scan()`
* `connect()`
* `join_ibss()`
...

See more details in docs [4]

ipdb
====

For the RTNL protocol the library provides also IPDB, a transactional 
database. Instead of polling the system and loading all the objects, 
IPDB relies on the netlink broadcasting. Every time some network object 
changes its state, the event is being propagated by the kernel. So 
despite the IPDB startup may be expensive (at that time it loads all the 
system info), for the long-running programs it gives significant 
performance improvement, providing fast cache of the network objects. It 
is important when there are hundreds and thousands of routes, 
neighbours, addresses etc.

All the changes made via IPDB are tracked and asserted; running any code 
after the `commit()` call you can be sure that it works in the system 
with certain settings. If IPDB meets some issues running `commit()`, it 
rolls back all the changes made in the transaction and raises an exception::

     with IPDB() as ipdb:
         #
         # assume here eth0 is down, w/o ipaddr, mtu == 1500
         #
	with ipdb.interfaces['eth0'] as i:
             i.add_ip('10.0.0.2/24')
             i.up()
             i.set_mtu(1460)
             i.set_address('00:11:22:33:44:55')
         #
         # here eth0 will be up AND with ipaddr AND with new macaddr
         # AND with mtu 1460
         #
         # if something goes wrong, all the eth0 settings will be
         # reverted to the last working state
         #


references
==========

Project home: https://github.com/svinota/pyroute2

Also in the text:

[1] https://pypi.python.org/pypi/pyroute2
[2] http://docs.pyroute2.org/mpls.html
[3] in cooperation with https://github.com/iovisor/bcc
[4] http://docs.pyroute2.org/usage.html


More information about the Python-announce-list mailing list