Skip to content

Instantly share code, notes, and snippets.

View pandafy's full-sized avatar
:octocat:
Full-time on OpenWISP

Gagan Deep pandafy

:octocat:
Full-time on OpenWISP
View GitHub Profile
@pandafy
pandafy / playbook.yml
Last active November 30, 2021 16:29
Example playbook for installing OpenWISP WIreGuard Intergration
- hosts: openwisp2
become: "{{ become | default('yes') }}"
roles:
- openwisp.openwisp2-dev # Install the development version of openwisp.openwisp2 from https://github.com/openwisp/ansible-openwisp2/tree/dev#deploying-the-upcoming-release-of-openwisp
vars:
openwisp2_controller_pip: https://github.com/openwisp/openwisp-controller/tarball/1.0.x
openwisp2_netjsonconfig_pip: https://github.com/openwisp/netjsonconfig/tarball/master
openwisp2_extra_django_apps:
- "openwisp_ipam"
- "openwisp_controller.subnet_division"
@pandafy
pandafy / monitoring_template.json
Created April 19, 2022 20:27
OpenWISP Monitoring Default Monitoring Template
{
"files": [
{
"path": "/usr/sbin/openwisp-monitoring",
"mode": "0744",
"contents": "uuid=$(uci get openwisp.http.uuid)\nkey=$(uci get openwisp.http.key)\nbase_url=$(uci get openwisp.http.url)\nverify_ssl=$(uci get openwisp.http.verify_ssl)\nincluded_interfaces=$(uci get openwisp.monitoring.included_interfaces)\nurl=\"$base_url/api/v1/monitoring/device/$uuid/?key=$key\"\ndata=$(/usr/sbin/netjson-monitoring \"$included_interfaces\")\nif [ \"$verify_ssl\" = 0 ]; then\n curl_command='curl -k'\nelse\n curl_command='curl'\nfi\n# send data via POST\n$curl_command -H \"Content-Type: application/json\" \\\n -X POST \\\n -d \"$data\" \\\n -v $url\n"
},
{
"path": "/usr/sbin/netjson-monitoring",
"mode": "0744",
@pandafy
pandafy / README.md
Last active June 13, 2025 17:56
OpenWISP Coding Conventions

OpenWISP Coding Conventions

Note: This document is a personal note where I add the unsaid coding conventions of the OpenWISP community. I usually find these while reviewing PRs of new contributors. Some of these are not hard rules but mere preferences, while some are the best practices adopted by the Python/Django community.

1. Accessing the app setting

Any setting which is related to an OpenWISP module should not be accessed from the django.conf.settings object. Rather, it should be accessed by importing the settings file from the module.

@pandafy
pandafy / update_mobile_location.py
Created January 7, 2026 13:13
Script to simulate updating of co-ordinates by mobile device
#!/usr/bin/env python3
"""Send sequential coordinate updates to OpenWISP device coordinates endpoint.
Set `DEVICE_UUID` and `DEVICE_KEY` globals below before running.
Usage examples:
python var/move-mobile-location.py --interval 5
python var/move-mobile-location.py --interval 2 --loop
"""
from __future__ import annotations