Skip to main content

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.*")

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aio_openwrt-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aio_openwrt-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file aio_openwrt-0.1.0.tar.gz.

File metadata

  • Download URL: aio_openwrt-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aio_openwrt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 908c797f922a31ae1642c0bee988f1cb10dcd6b2fffc723a39cd51d961ebafad
MD5 4117262471f7644f302581d41c0b1c40
BLAKE2b-256 2c4e7e5c1c5dea5e9636e917e8a78d0db5231900077985302eaef8d83f6d2d09

See more details on using hashes here.

Provenance

The following attestation bundles were made for aio_openwrt-0.1.0.tar.gz:

Publisher: release.yml on xZise/aio-openwrt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aio_openwrt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aio_openwrt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aio_openwrt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c048dbdc5c5a00c1453aa0a8b557dc499de1354cb1275b0af96a6867d4beea9f
MD5 bb0a8a58817f297da310c0dc87fbf51e
BLAKE2b-256 1287542d2bc25d97afd73a4e40653e4a892a6c2cb4035a5a15fb139e35b84195

See more details on using hashes here.

Provenance

The following attestation bundles were made for aio_openwrt-0.1.0-py3-none-any.whl:

Publisher: release.yml on xZise/aio-openwrt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page