Skip to main content

Access AirControl2, AirOS & Mikrotik

Project description

Coverage Python CI Build Status

PyWisp installation

Install pywisp

pip3 install --user pywisp_emibcn

Configure PyWisp

Then configure as per ~/.pywisp

Finally, create the python script which implements the WISP infrastructure and authentication mechanisms, as per wisp.py

PyWisp usage

usage: pywisp [-h] [--conf CONF] {backup_ac,backup_mt,reorder_ac,host} ...

positional arguments:
  {backup_ac,backup_mt,reorder_ac,host}
    backup_ac           Backup all AirControl devices
    backup_mt           Backup all Mikrotik devices
    reorder_ac          Reorder branches from AirControl devices
    host                Find device by it's hostname, MAC or IP

optional arguments:
  -h, --help            show this help message and exit
  --conf CONF           Reads configuration from this file instead of default
                        (default: $HOME/.pywisp)

Backup all Ubiquiti's devices

usage: pywisp backup_ac [-h] [--retries] [PATH]

positional arguments:
  PATH        Directory in which save backup files (default: None)

optional arguments:
  -h, --help  show this help message and exit
  --retries   Retries for every device before stop trying (default: 3)

Backup all Mikrotik's devices

usage: pywisp backup_mt [-h] [--retries] [PATH]

positional arguments:
  PATH        Directory in which save backup files (default: None)

optional arguments:
  -h, --help  show this help message and exit
  --retries   Retries for every device before stop trying (default: 3)

Host lookup and actions

usage: pywisp host [-h] [--deep] [--from-br FROM_BR] [--getname] [--getjson]
                    [--getip] [--getid] [--getmac] [--getdhcp] [--getwifi]
                    [--getwifistations] [--getstatus] [--url] [--ssh]
                    [--cmd CMD]
                    host

positional arguments:
  host               Devices hostname, MAC or IP

optional arguments:
  -h, --help         show this help message and exit
  --deep             Find device by it's hostname, MAC or IP, using all BRs
                     station list as haystack (default: False)
  --from-br FROM_BR  Deep find only in this BR (default: None)
  --getname          Gets device name (default: False)
  --getjson          Gets device full data (default: False)
  --getip            Gets device IP (default: False)
  --getid            Gets device ID (default: False)
  --getmac           Gets device MAC (default: False)
  --getdhcp          Gets device's DHCP leases/stations (default: False)
  --getwifi          Gets device's wifi status (default: False)
  --getwifistations  Gets device's wifi stations (default: False)
  --getstatus        Gets device status (default: False)
  --url              Gets an authenticated URL to connect to the device using
                     browser (default: False)
  --ssh              Connects to device using SSH (default: False)
  --cmd CMD          Connects to device and run a command (default: None)

PyWisp config file: ~/.pywisp

[wisp]
path = ${env:HOME}/MyWISP/
module = wisp
class = MyWISP

[ac]
url = https://10.100.1.102:9082
user = admin
password = MyNotSoSecurePassword

[backup]
ac = /var/backups/mywisp/ac/
mt = /var/backups/mywisp/mt/

WISP infrastructure and host authentication definitions

${env:HOME}/MyWISP/wisp.py

In this example, we hardcode relations between IPs, some device names, users and passwords. We could be getting those relations from where ever, for example, an SQL database, a secure wallet downloaded from an S3, an spreadsheet at GoogleDocs (sic), an internal REST API, etc. Examples are welcome via pull request.

You can add more types of devices (for example, Mimosa) subclassing SSHDevice and instantiating it correctly from your wisp.py. If you do so, I appreciate pull requests ;)

You can create a complete subclassed Wisp object and pass it to PyWisp on instantiation. This way you can use PyWisp from within other projects, like from your Django APP or from your Zabbix scripts, mantaining your infrastructure and authentication mechanisms centralized.

TODO list

  • Move prints and similars to a good logging system.
  • Enhance logging system
  • Create examples repo with one wisp.py example
  • Create more examples (useful for testing, too)
  • Create more and useful documentation
  • Testing
  • Testing, testing, testing...

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

pywisp_emibcn-0.0.10.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

pywisp_emibcn-0.0.10-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file pywisp_emibcn-0.0.10.tar.gz.

File metadata

  • Download URL: pywisp_emibcn-0.0.10.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for pywisp_emibcn-0.0.10.tar.gz
Algorithm Hash digest
SHA256 815bfe7fbf903581aff09685c536214ca97795f27d84834b0feb749eaf1c1380
MD5 e3be96948fd0165295bdbd5bf15f7dff
BLAKE2b-256 14baf86851cc06835f60d927a44ab9ea5f1099a32e89f16517d917f9cb291349

See more details on using hashes here.

File details

Details for the file pywisp_emibcn-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: pywisp_emibcn-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for pywisp_emibcn-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d10cd5693e16e7ac16dda89e83301e7ec8c0260eabb43c8b5e164994d4dadba4
MD5 7e779e78d52563571ee4aeea25ba9742
BLAKE2b-256 bf3050377531321f9e29a002cc5a4d9189e1e2dec361ae532182b5545e1e1da9

See more details on using hashes here.

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