initial commit
This commit is contained in:
commit
75f9497998
3 changed files with 69 additions and 0 deletions
21
generate.py
Normal file
21
generate.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
import routeros_api
|
||||
import os
|
||||
import sys
|
||||
import csv
|
||||
|
||||
connection = routeros_api.RouterOsApiPool(
|
||||
os.getenv("ROUTER_IP", "192.168.42.1"),
|
||||
username='admin',
|
||||
password=os.getenv("ROUTER_PASSWORD"),
|
||||
plaintext_login=True
|
||||
)
|
||||
api = connection.get_api()
|
||||
|
||||
registered = api.get_resource('/caps-man/registration-table').call('print')
|
||||
leases = api.get_resource('/ip/dhcp-server/lease').call('print')
|
||||
|
||||
writer = csv.writer(sys.stdout)
|
||||
for client in registered:
|
||||
if os.getenv("SSID", "anabasis") in client['ssid']:
|
||||
lease = next(l for l in leases if l.get('active-mac-address') == client['mac-address'])
|
||||
writer.writerow((lease['active-address'], lease['active-mac-address'], lease.get('host-name', "???")))
|
33
poetry.lock
generated
Normal file
33
poetry.lock
generated
Normal file
|
@ -0,0 +1,33 @@
|
|||
[[package]]
|
||||
name = "routeros-api"
|
||||
version = "0.17.0"
|
||||
description = "Python API to RouterBoard devices produced by MikroTik."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.dependencies]
|
||||
six = "*"
|
||||
|
||||
[[package]]
|
||||
name = "six"
|
||||
version = "1.15.0"
|
||||
description = "Python 2 and 3 compatibility utilities"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.0"
|
||||
python-versions = "^3.7"
|
||||
content-hash = "3ab50217eea285c11ccd2f1b4ab50a57d19cdf03f1c8e71e6bfd63e3e225cb59"
|
||||
|
||||
[metadata.files]
|
||||
routeros-api = [
|
||||
{file = "RouterOS-api-0.17.0.tar.gz", hash = "sha256:1b9898460ecc4667b54e477d495b74c2f24ae0aac4c90dd0e62f23ec7eae8252"},
|
||||
{file = "RouterOS_api-0.17.0-py2.py3-none-any.whl", hash = "sha256:bf38da94a570875eaa87ff537558f765a4697dbce1a9753070194b687f441bf0"},
|
||||
]
|
||||
six = [
|
||||
{file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
|
||||
{file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
|
||||
]
|
15
pyproject.toml
Normal file
15
pyproject.toml
Normal file
|
@ -0,0 +1,15 @@
|
|||
[tool.poetry]
|
||||
name = "anabasis-clients"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Tomáš Mládek <t@mldk.cz>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.7"
|
||||
routeros-api = "^0.17.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
build-backend = "poetry.masonry.api"
|
Loading…
Reference in a new issue