Skip to main content

Django implementation of NetJSON NetworkGraph

Project description

https://travis-ci.org/interop-dev/django-netjsongraph.svg https://coveralls.io/repos/interop-dev/django-netjsongraph/badge.svg Requirements Status https://badge.fury.io/py/django-netjsongraph.svg https://img.shields.io/pypi/dm/django-netjsongraph.svg

Reusable django app for collecting and visualizing network topology.

https://raw.githubusercontent.com/interop-dev/django-netjsongraph/master/docs/images/visualizer.png https://raw.githubusercontent.com/interop-dev/django-netjsongraph/master/docs/images/admin.png

Current features

  • network topology collector supporting different formats:
    • NetJSON NetworkGraph

    • OLSR (jsoninfo/txtinfo)

    • batman-adv (jsondoc/txtinfo)

    • BMX6 (q6m)

    • CNML 1.0

  • network topology visualizer based on netjsongraph.js

  • simple HTTP API that exposes data in NetJSON NetworkGraph format

  • admin interface that allows to easily manage, audit and debug topologies and their relative data (nodes, links)

Project goals

  • make it easy to visualize network topology data for the formats supported by netdiff

  • expose topology data via RESTful resources in NetJSON NetworkGraph format

  • make it easy to integrate in larger django projects to improve reusability

  • make it easy to extend its models by providing abstract models (needs improvement in this point)

  • provide ways to customize or replace the visualizer (needs improvement in this point)

  • keep the core very simple

  • provide ways to extend the default behaviour

  • encourage new features to be published as extensions

Install stable version from pypi

Install from pypi:

pip install django-netjsongraph

Install development version

Install tarball:

pip install https://github.com/interop-dev/django-netjsongraph/tarball/master

Alternatively you can install via pip using git:

pip install -e git+git://github.com/interop-dev/django-netjsongraph#egg=django-netjsongraph

If you want to contribute, install your cloned fork:

git clone git@github.com:<your_fork>/django-netjsongraph.git
cd django-netjsongraph
python setup.py develop

Setup (integrate in an existing django project)

Add rest_framework and django_netjsongraph to INSTALLED_APPS:

INSTALLED_APPS = [
    # other apps
    'rest_framework',
    'django_netjsongraph'
    # ...
]

Include urls in your urlconf (you can change the prefixes according to your needs):

from django.conf.urls import include, url

from django_netjsongraph.api import urls as netjsongraph_api
from django_netjsongraph.visualizer import urls as netjsongraph_visualizer

urlpatterns = [
    # your URLs ...
    url(r'^api/', include(netjsongraph_api)),
    url(r'', include(netjsongraph_visualizer)),
]

Management Commands

update_topology

After topology URLs (URLs exposing the files that the topology of the network) have been added in the admin, the update_topology management command can be used to collect data and start playing with the network graph:

./manage.py update_topology

The management command accepts a --label argument that will be used to search in topology labels, eg:

./manage.py update_topology --label mytopology

Logging

The update_topology management command will automatically try to log errors.

For a good default LOGGING configuration refer to the test settings.

Settings

Setting

Default value

Description

NETJSONGRAPH_PARSERS

[]

List with additional custom netdiff parsers

NETJSONGRAPH_SIGNALS

None

String representing python module to import on initialization. Useful for loading django signals or to define custom behaviour.

NETJSONGRAPH_TIMEOUT

8

Timeout when requesting topology URLs

NETJSONGRAPH_LINK_EXPIRATION

60

If a link is down for more days than this number, it will be deleted by the update_topology management command. Setting this to False will disable this feature.

Installing for development

Install sqlite:

sudo apt-get install sqlite3 libsqlite3-dev

Install your forked repo:

git clone git://github.com/<your_fork>/django-netjsongraph
cd django-netjsongraph/
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 visualizer at http://127.0.0.1:8000/ and the admin interface at http://127.0.0.1:8000/admin/.

Run tests with:

./runtests.py

Contributing

First off, thanks for taking the time to read these guidelines.

Trying to follow these guidelines is important in order to minimize waste and avoid misunderstandings.

  1. Ensure your changes meet the Project Goals

  2. If you found a bug please send a failing test with a patch

  3. If you want to add a new feature, announce your intentions in the issue tracker

  4. Fork this repo and install it by following the instructions in Installing for development

  5. Follow PEP8, Style Guide for Python Code

  6. Write code

  7. Write tests for your code

  8. Ensure all tests pass

  9. Ensure test coverage is not under 90%

  10. Document your changes

  11. Send pull request

Changelog

See CHANGES.

License

See LICENSE.

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

django-netjsongraph-0.1.2.tar.gz (80.4 kB view details)

Uploaded Source

Built Distribution

django_netjsongraph-0.1.2-py2.py3-none-any.whl (90.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-netjsongraph-0.1.2.tar.gz.

File metadata

File hashes

Hashes for django-netjsongraph-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c2cd46d1440c583c521fe43e2eb82fbe682440a01cdcf600649b003cd0e5d0d1
MD5 119c9bb07eaa3dafe17a974aeeca9a13
BLAKE2b-256 b9a0ac52a0cf56295f4873be613c4451dc8d12b78e6829364792e1d22b4420c1

See more details on using hashes here.

Provenance

File details

Details for the file django_netjsongraph-0.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_netjsongraph-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e3375f7cce33c1f92d52a754fbd10266820687948b32eff4d4f5bab3f7222276
MD5 7704817996a612ad6da3d6d8c047379c
BLAKE2b-256 19855472408d6f2eca5214af2cbd045f42815469862a640ab079c56963887b75

See more details on using hashes here.

Provenance

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