Django implementation of NetJSON DeviceConfiguration based on netjsonconfig.
Install from pypi:
pip install django-netjsonconfig
Install tarball:
pip install https://github.com/openwisp/django-netjsonconfig/tarball/master
Alternatively you can install via pip using git:
pip install -e git+git://github.com/openwisp/django-netjsonconfig#egg=django-netjsonconfig
If you want to contribute, install your cloned fork:
git clone git@github.com:<your_fork>/django-netjsonconfig.git
cd django-netjsonconfig
python setup.py develop
Add django_netjsonconfig
, sortedm2m
and reversion
to INSTALLED_APPS
:
INSTALLED_APPS = [
# other apps
'django_netjsonconfig',
'sortedm2m',
'reversion' # optional, can be removed if not needed
# ...
]
Add the controller URLs to your main urls.py
:
urlpatterns = [
# ... other urls in your project ...
# controller URLs
# used by devices to download/update their configuration
# keep the namespace argument unchanged
url(r'^', include('django_netjsonconfig.controller.urls', namespace='controller')),
# common URLs
# shared among django-netjsonconfig components
# keep the namespace argument unchanged
url(r'^', include('django_netjsonconfig.urls', namespace='netjsonconfig')),
]
Then run:
./manage.py migrate
If you need to deploy django-netjsonconfig by itself (that is without including it in a larger project), you may want to check out the ansible-openwisp2 role.
Install sqlite:
sudo apt-get install sqlite3 libsqlite3-dev
Install your forked repo:
git clone git://github.com/<your_fork>/django-netjsonconfig
cd django-netjsonconfig/
python setup.py develop
Install test requirements:
pip install -r requirements-test.txt
Create database:
cd tests/
./manage.py migrate
./manage.py createsuperuser
Launch development server:
./manage.py runserver
You can access the admin interface at http://127.0.0.1:8000/admin/.
Run tests with:
./runtests.py
type: | list |
default: | [] |
Additional custom netjsonconfig backends.
type: | bool |
default: | True |
Whether devices can automatically register through the controller or not.
This feature is enabled by default.
type: | str |
default: | "" |
A secret key which must be used by devices to perform automatic registration.
This key MUST be explicitly set in production (if settings.DEBUG is False
), otherwise an ImproperlyConfigured
exception will be raised on startup.
type: | dict |
default: | {} |
Additional context that is passed to the default context of each Config
object.
Each Config
object gets the following attributes passed as configuration variables:
id
key
name
NETJSONCONFIG_CONTEXT
can be used to define system-wide configuration variables.
For more information, see netjsonconfig context: configuration variables.
type: | str |
default: | netjsonconfig.OpenWrt |
The preferred backend that will be used as initial value when adding new Config
or Template
objects in the admin.
Set it to None
in order to force the user to choose explicitly.
- Announce your intentions in the OpenWISP Mailing List
- Fork this repo and install it
- Follow PEP8, Style Guide for Python Code
- Write code
- Write tests for your code
- Ensure all tests pass
- Ensure test coverage is not under 90%
- Document your changes
- Send pull request
See CHANGES.
See LICENSE.