Skip to main content

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.
    '''

    @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

Metadata

Release files for pyroute2 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyroute2 0.2.6
File Size Uploaded Provenance Actions
pyroute2-0.2.6.tar.gz 57.9 kB Without provenance Details for pyroute2-0.2.6.tar.gz

Release files / pyroute2-0.2.6.tar.gz

Download URL pyroute2-0.2.6.tar.gz
Size 57.9 kB
Tags Source
SHA-256 checksum
How to use checksums
eb17391c51a89e8e9195465af9e3b1b256f1e4f2a485c37b6b75e89463d94a76
BLAKE2b-256 checksum
How to use checksums
0baf0ca2c4440d463d1f1e30878269bd9f6c49dc9efb23db4f808ba1bfa3e89c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyroute2 0.2.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

0.3.17

This release

0.2.6 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page