Converts NetJSON DeviceConfiguration objects to real router configurations
Project description
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 https://github.com/openwisp/netjsonconfig/tarball/master
Alternatively you can install via pip using git:
pip install -e git+git://github.com/openwisp/netjsonconfig#egg=netjsonconfig
If you want to contribute, install your cloned fork:
git clone git@github.com:<your_fork>/netjsonconfig.git
cd netjsonconfig
python setup.py develop
Basic Usage Example
from netjsonconfig import OpenWrt
o = OpenWrt({
"type": "DeviceConfiguration",
"interfaces": [
{
"name": "eth0.1",
"type": "ethernet",
"addresses": [
{
"address": "192.168.1.1",
"mask": 24,
"proto": "static",
"family": "ipv4"
},
{
"address": "192.168.2.1",
"mask": 24,
"proto": "static",
"family": "ipv4"
},
{
"address": "fd87::1",
"mask": 128,
"proto": "static",
"family": "ipv6"
}
]
}
]
})
print(o.render())
Will print:
package network config interface 'eth0_1' option ifname 'eth0.1' option proto 'static' option ipaddr '192.168.1.1/24' config interface 'eth0_1_2' option ifname 'eth0.1' option proto 'static' option ipaddr '192.168.2.1/24' 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://github.com/<your_fork>/netjsonconfig
cd netjsonconfig/
python setup.py develop
Install test requirements:
pip install -r requirements-test.txt
Run tests with:
./runtests.py
Alternatively, you can use the nose command (which has a ton of available options):
nosetests
See test coverage with:
coverage run --source=netjsonconfig runtests.py && coverage report
Contributing
Announce your intentions in the issue tracker
Fork this repo and install it
Write code
Write tests for your code
Ensure all tests pass
Ensure test coverage is not under 90%
Document your changes
Send pull request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file netjsonconfig-0.1b0.tar.gz
.
File metadata
- Download URL: netjsonconfig-0.1b0.tar.gz
- Upload date:
- Size: 36.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ac35cabccd70b52c2f593d54c02783b826179c8abb49665c995c2d447ea4e57 |
|
MD5 | 22aa87bef25952ac09ace2fd85d6879b |
|
BLAKE2b-256 | 94a4d069bb5449468c2bf235d427b9f58394301df2218e2d61e5d407280c727b |
File details
Details for the file netjsonconfig-0.1b0-py2.py3-none-any.whl
.
File metadata
- Download URL: netjsonconfig-0.1b0-py2.py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62ab698eeb7a3136d776928e91dba473afe2cf9709e9e7a5270c5149ee5d8006 |
|
MD5 | 1bc40dc7b5efedc6f014eb23cf6d03ca |
|
BLAKE2b-256 | 05ca0b5f8be3f3af919a2fa311469e6b822fc7cca5241f64cad86d0e406180f0 |