Async Python library for interfacing with OpenWRT via ubus
Project description
OpenWRT ubus API
A Python library for asynchronous access to the ubus interface on OpenWRT devices.
Requirements
- Python 3.10+
aiohttp
Quick Start
from aio_openwrt import Ubus
async with Ubus("192.168.1.1", "username", "password") as client:
await client.login()
dev = await client.network.device.status(name="lan1")
print(dev)
Usage
Connection livetime
Use async with to automatically manage the session:
async with Ubus(host, user, password) as client:
await client.login()
dev = await client.network.device.status(name="lan1")
Without a with block, a session is created automatically on the first request. In that case, call close() manually when done:
client = Ubus(host, user, password)
try:
await client.login()
dev = await client.network.device.status(name="lan1")
finally:
await client.close()
Making Calls
There are two ways to interact with the device:
Typed wrappers — available for common paths and methods:
await ubus.session.login(username="...", password="...")
await ubus.network.device.status(name="lan1")
await ubus.system.board()
Direct call() — for any path/method not covered by a typed wrapper:
await ubus.call("session", "login", {"username": "...", "password": "..."})
await ubus.call("network.device", "status", {"name": "lan1"})
await ubus.call("system", "board")
Both are equivalent. The typed wrappers are a convenience layer over call().
Subscript Access For dynamically named entries such as network interfaces, use subscript notation:
await ubus.network.interface["wan"].status()
Listing objects
To list the objects directly use list():
await ubus.list("hostapd.*")
Typed wrappers with subscript access can be iterated over using list_children():
await ubus.hostapd.list_children()
Permissions
Depending on the device configuration, most features require authentication first. The authenticated user must be configured in /etc/config/rpcd with a corresponding ACL file in /usr/share/rpcd/acl.d/ granting the necessary ubus permissions. See the OpenWRT wiki for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aio_openwrt-0.2.0.tar.gz.
File metadata
- Download URL: aio_openwrt-0.2.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb76a147af0a1d44666b45a6125ce7ddf15af7bb5b1e8a8f021faecd1040e1bd
|
|
| MD5 |
80c7ef4e1c97910e1399916ddc6cb421
|
|
| BLAKE2b-256 |
c27a765b42fa9fea674be059e267eb6d4422a592f813ee778c6c41794aa47e0f
|
Provenance
The following attestation bundles were made for aio_openwrt-0.2.0.tar.gz:
Publisher:
release.yml on xZise/aio-openwrt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aio_openwrt-0.2.0.tar.gz -
Subject digest:
bb76a147af0a1d44666b45a6125ce7ddf15af7bb5b1e8a8f021faecd1040e1bd - Sigstore transparency entry: 1203610712
- Sigstore integration time:
-
Permalink:
xZise/aio-openwrt@b95d9029b81aaea589423ce4b9e5585ca7a6ca38 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/xZise
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b95d9029b81aaea589423ce4b9e5585ca7a6ca38 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aio_openwrt-0.2.0-py3-none-any.whl.
File metadata
- Download URL: aio_openwrt-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a6532d628440e8180471ccabe43fe085d9aa22341aed4a4b121f60eda43051a
|
|
| MD5 |
48e02a1410c066cd010a1534eadc8bcb
|
|
| BLAKE2b-256 |
f59b863c8dc8d0e4bd65e1547bd337374e4483e2bb6172795b4848a242e10a35
|
Provenance
The following attestation bundles were made for aio_openwrt-0.2.0-py3-none-any.whl:
Publisher:
release.yml on xZise/aio-openwrt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aio_openwrt-0.2.0-py3-none-any.whl -
Subject digest:
3a6532d628440e8180471ccabe43fe085d9aa22341aed4a4b121f60eda43051a - Sigstore transparency entry: 1203610714
- Sigstore integration time:
-
Permalink:
xZise/aio-openwrt@b95d9029b81aaea589423ce4b9e5585ca7a6ca38 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/xZise
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b95d9029b81aaea589423ce4b9e5585ca7a6ca38 -
Trigger Event:
push
-
Statement type: