Coder Social home page Coder Social logo

kelixin / django-netjsongraph Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openwisp/django-netjsongraph

0.0 2.0 0.0 550 KB

Network Topology Visualizer & Network Topology Collector

License: MIT License

Python 71.91% CSS 2.84% JavaScript 21.97% HTML 3.28%

django-netjsongraph's Introduction

django-netjsongraph

Requirements Status

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
    • additional formats can be added by specifying custom parsers
  • 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)
  • receive topology from multiple nodes

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 [email protected]:<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)),
]

Create database tables:

./manage.py migrate

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.

Strategies

There are mainly two ways of collecting topology information:

  • FETCH strategy
  • RECEIVE strategy

Each Topology instance has a strategy field which can be set to the desired setting.

FETCH strategy

Topology data will be fetched from a URL.

When some links are not detected anymore they will be flagged as "down" straightaway.

RECEIVE strategy

Topology data is sent directly from one or more nodes of the network.

The collector waits to receive data in the payload of a POST HTTP request; when such a request is received, a key parameter it's first checked against the Topology key.

If the request is authorized the collector proceeds to update the topology.

If the data is sent from one node only, it's highly advised to set the expiration_time of the Topology instance to 0 (seconds), this way the system works just like in the FETCH strategy, with the only difference that the data is sent by one node instead of fetched by the collector.

If the data is sent from multiple nodes, you SHOULD set the expiration_time of the Topology instance to a value slightly higher than the interval used by nodes to send the topology, this way links will be flagged as "down" only if they haven't been detected for a while. This mechanism allows to visualize the topology even if the network has been split in several parts, the disadvantage is that it will take a bit more time to detect links that go offline.

Settings

NETJSONGRAPH_PARSERS

type: list
default: []

Additional custom netdiff parsers.

NETJSONGRAPH_SIGNALS

type: str
default: None

String representing python module to import on initialization.

Useful for loading django signals or to define custom behaviour.

NETJSONGRAPH_TIMEOUT

type: int
default: 8

Timeout when fetching topology URLs.

NETJSONGRAPH_LINK_EXPIRATION

type: int
default: 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.

django-netjsongraph's People

Contributors

nemesifier avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.