skip to navigation
skip to content

pyroute2 0.2.7

Python Netlink library

Latest Version: 0.3.15

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.

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.

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

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

# listen for network connections

# 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

It will print out test passed.


make install or pip install pyroute2


Python >= 2.6

  • test reqs (optional): python-coverage, python-nose
File Type Py Version Uploaded on Size
pyroute2-0.2.7.tar.gz (md5) Source 2014-03-12 57KB
  • Downloads (All Versions):
  • 4030 downloads in the last day
  • 14998 downloads in the last week
  • 32491 downloads in the last month