Skip to main content
Help us improve Python packaging – donate today!

Python Netlink library

Project Description

pyroute2
========

Pyroute2 is a pure Python netlink and messaging/RPC library.
It requires only Python stdlib, no 3rd party libraries. Later
it can change, but the deps tree will remain as simple, as
it is possible.

The library contains all you need to build either one-node,
or distributed netlink-related solutions. It consists of two
major parts:

* Netlink parsers: NETLINK\_ROUTE, TASKSTATS, etc.
* Messaging infrastructure: broker, clients, etc.

RTNETLINK sample
----------------

More samples you can read in the project documentation.
Low-level interface::

from pyroute2 import IPRoute

# get access to the netlink socket
ip = IPRoute()

# print interfaces
print ip.get_links()

# stop working with netlink and release all sockets
ip.release()

High-level transactional interface, IPDB::

from pyroute2 import IPDB
# local network settings
ip = IPDB()
# create bridge and add ports and addresses
# transaction will be started with `with` statement
# and will be committed at the end of the block
with ip.create(kind='bridge', ifname='rhev') as i:
i.add_port(ip.em1)
i.add_port(ip.em2)
i.add_ip('10.0.0.2/24')


The project contains several modules for different types of
netlink messages, not only RTNL.

RPC sample
----------

Actually, either side can act as a server or a client, there
is no pre-defined roles. But for simplicity, they're referred
here as "server" and "client".

Server side::

from pyroute2.rpc import Node
from pyroute2.rpc import public


class Namespace(object):
'''
This class acts as a namespace, that contains
methods to be published via RPC. Any method,
available through RPC, must be marked as @public.
'''

@public
def echo(self, msg):
'''
Simple echo method, that returns a modified
string.
'''
return '%s passed' % (msg)

# start the RPC node and register the namespace
node = Node()
node.register(Namespace())

# listen for network connections
node.serve('tcp://localhost:9824')

# wait for exit -- activity will be done in the
# background thread
raw_input(' hit return to exit >> ')

Client side::

from pyroute2.rpc import Node

# start the RPC node and connect to the 'server'
node = Node()
proxy = node.connect('tcp://localhost:9824')

# call a remote method through the proxy instance
print(proxy.echo('test'))


It will print out `test passed`.

installation
------------

`make install` or `pip install pyroute2`

requires
--------

Python >= 2.6

* test reqs (optional): **python-coverage**, **python-nose**

links
-----

* home: https://github.com/svinota/pyroute2
* bugs: https://github.com/svinota/pyroute2/issues
* pypi: https://pypi.python.org/pypi/pyroute2
* docs: http://peet.spb.ru/pyroute2/
* list: https://groups.google.com/d/forum/pyroute2-dev

Release history Release notifications

History Node

0.5.0

History Node

0.4.21

History Node

0.4.20

History Node

0.4.19

History Node

0.4.18

History Node

0.4.17

History Node

0.4.16

History Node

0.4.15

History Node

0.4.14

History Node

0.4.13

History Node

0.4.12

History Node

0.4.11

History Node

0.4.10

History Node

0.4.9

History Node

0.4.8

History Node

0.4.7

History Node

0.4.6

History Node

0.4.5

History Node

0.4.4

History Node

0.4.3

History Node

0.4.2

History Node

0.4.1

History Node

0.4.0

History Node

0.3.22

History Node

0.3.21

History Node

0.3.20

History Node

0.3.19

History Node

0.3.18

History Node

0.3.17

History Node

0.3.16

History Node

0.3.15

History Node

0.3.14

History Node

0.3.13

History Node

0.3.12

History Node

0.3.11

History Node

0.3.10

History Node

0.3.9

History Node

0.3.8

History Node

0.3.7

History Node

0.3.6

History Node

0.3.5

History Node

0.3.4

History Node

0.3.3

History Node

0.3.2

History Node

0.3.1

History Node

0.2.16

History Node

0.2.14

History Node

0.2.13

History Node

0.2.12

History Node

0.2.11

History Node

0.2.10

History Node

0.2.9

History Node

0.2.8

History Node

0.2.7

This version
History Node

0.2.6

History Node

0.2.4

History Node

0.2.3

History Node

0.2.2

History Node

0.1.12

History Node

0.1.10

History Node

0.1.9

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pyroute2-0.2.6.tar.gz (57.9 kB) Copy SHA256 hash SHA256 Source None Feb 9, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page