Skip to main content

Converts NetJSON DeviceConfiguration objects to real router configurations

Project description Requirements Status

Converts NetJSON DeviceConfiguration objects to real router configurations.

Currently we are working only on OpenWrt support.

Work in progress.

Install stable version from pypi

Install from pypi:

pip install netjsonconfig

Install development version

Install tarball:

pip install

Alternatively you can install via pip using git:

pip install -e git+git://

If you want to contribute, install your cloned fork:

git clone<your_fork>/netjsonconfig.git
cd netjsonconfig
python develop

Basic Usage Example

from netjsonconfig import OpenWrt

o = OpenWrt({
    "type": "DeviceConfiguration",
    "interfaces": [
            "name": "eth0.1",
            "type": "ethernet",
            "addresses": [
                    "address": "",
                    "mask": 24,
                    "proto": "static",
                    "family": "ipv4"
                    "address": "",
                    "mask": 24,
                    "proto": "static",
                    "family": "ipv4"
                    "address": "fd87::1",
                    "mask": 128,
                    "proto": "static",
                    "family": "ipv6"

Will print:

package network

config interface 'eth0_1'
    option ifname 'eth0.1'
    option proto 'static'
    option ipaddr ''

config interface 'eth0_1_2'
    option ifname 'eth0.1'
    option proto 'static'
    option ipaddr ''

config interface 'eth0_1_3'
    option ifname 'eth0.1'
    option proto 'static'
    option ip6addr 'fd87::1/128'

Command line utility

netjsonconfig ships a command line utility that can be used from the interactive shell or in bash scripts:

netjsonconfig --help

A few common use scenarios:

# generate tar.gz from a NetJSON DeviceConfiguration object
netjsonconfig --backend openwrt config.json

# see output of OpenWrt render method
netjsonconfig --backend openwrt --method render config.json

# abbreviated options
netjsonconfig -b openwrt -m render config.json

Running tests

Install your forked repo:

git clone git://<your_fork>/netjsonconfig
cd netjsonconfig/
python develop

Install test requirements:

pip install -r requirements-test.txt

Run tests with:


Alternatively, you can use the nose command (which has a ton of available options):


See test coverage with:

coverage run --source=netjsonconfig && coverage report


  1. Announce your intentions in the issue tracker

  2. Fork this repo and install it

  3. Follow PEP8, Style Guide for Python Code

  4. Write code

  5. Write tests for your code

  6. Ensure all tests pass

  7. Ensure test coverage is not under 90%

  8. Document your changes

  9. Send pull request

Project details

Download files

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

Source Distribution

netjsonconfig-0.1b0.tar.gz (36.4 kB view hashes)

Uploaded Source

Built Distribution

netjsonconfig-0.1b0-py2.py3-none-any.whl (22.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page