Skip to main content

Python API client for GenieACS REST API

Project description

PyPI version License: MIT

pygenieacs

A Python API client for GenieACS — a TR-069 / CWMP Auto-Configuration Server.
This library provides a simple interface to interact with the GenieACS REST API.


✨ Features

  • List, inspect, and delete devices
  • Run tasks (reboot, factory reset, firmware upgrade, etc.)
  • Manage presets
  • Manage provisions
  • Simple, Pythonic interface

📦 Installation

pip install pygenieacs

🚀 Usage

Initialize Client

from pygenieacs import GenieACSClient, DevicesAPI, TasksAPI

# Connect to your GenieACS server
client = GenieACSClient(base_url="http://localhost:7557")

devices = DevicesAPI(client)
tasks = TasksAPI(client)

List Devices

print(devices.list())

Get Device Details

device_id = "001A2B3C4D"
print(devices.get(device_id))

Reboot a Device

tasks.add(device_id, "reboot")

⚙️ Advanced Presets

from pygenieacs import PresetsAPI

presets = PresetsAPI(client)
presets.create("daily-reboot", {
    "weight": 0,
    "precondition": "true", # all devices
    "configurations": [
        {"parameter": "InternetGatewayDevice.ManagementServer.PeriodicInformInterval", "value": "60"}
    ]
})

Here’s a preset that applies a provision only if the device vendor is MikroTik:

from pygenieacs import PresetsAPI

presets = PresetsAPI(client)

presets.create("mikrotik-provision", {
    "weight": 1,
    "precondition": "DeviceId.Manufacturer == 'MikroTik'",
    "configurations": [],
    "provisions": ["default-config"],  
})

See mikrotik-provision below.

This preset matches devices running firmware lower than v6.48 and applies a firmware upgrade task:

from pygenieacs import PresetsAPI

presets = PresetsAPI(client)

presets.create("firmware-upgrade", {
    "weight": 10,
    "precondition": "Device.DeviceInfo.SoftwareVersion < '6.48'",
    "configurations": [],
    "provisions": ["upgrade-firmware"],
})

This preset applies only to devices with OUI 001A2B (common for vendor-specific CPEs)/MAC prefix:

from pygenieacs import PresetsAPI

presets = PresetsAPI(client)

presets.create("oui-target", {
    "weight": 5,
    "precondition": "DeviceId.OUI == '001A2B'",
    "configurations": [
        {
            "parameter": "InternetGatewayDevice.LANDevice.1.LANHostConfigManagement.DHCPServerEnable",
            "value": False
        }
    ],
    "provisions": [],
})

Provisions Here’s how to create a provision that ensures TR-069 Inform Interval is set correctly and also pushes a default Wi-Fi SSID.

mikrotik-provision

from pygenieacs import ProvisionsAPI

provisions = ProvisionsAPI(client)

#Ensure inform interval is set to 300 seconds (5 min)
#Set default Wi-Fi SSID if missing
script = """
let interval = declare("InternetGatewayDevice.ManagementServer.PeriodicInformInterval", {value: 1});
if (interval.value[0] != 300) {
  declare("InternetGatewayDevice.ManagementServer.PeriodicInformInterval", null, {value: 300});
}

let ssid = declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID", {value: 1});
if (!ssid.value[0]) {
  declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID", null, {value: "MyDefaultSSID"});
}
"""

# Upload provision to GenieACS
provisions.create("default-config", script)

🛠 Development Clone the repo and install locally:

git clone https://github.com/uberkie/pygenieacs.git
cd pygenieacs
pip install -e .

Run tests:

pytest

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

pygenieacs-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

pygenieacs-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pygenieacs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 35c9c7c69c1d6f3a911a89906be4f465282799a1e6b27da61c3eacfcdbeef3ce
MD5 1bd15462065caa02b261c3546ae409f7
BLAKE2b-256 408fae5c5b8eda50c6ca18ffc3e812ff7bd064abae67c0bb18b63a1a703be676

See more details on using hashes here.

Provenance

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

Publisher: python-publish.yml on uberkie/pygenieacs

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

File details

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

File metadata

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

File hashes

Hashes for pygenieacs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31d9d1e4096e3095ccf87b01027a4d1ff38bd84d1efec13cbbf3977adab4712c
MD5 ac5ca41b3776766b57fe33b414f4aa47
BLAKE2b-256 bb3d30552155bfa585e5ee413f7cd9626cc43aa5d401bcaac7a42a0685d9cfcd

See more details on using hashes here.

Provenance

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

Publisher: python-publish.yml on uberkie/pygenieacs

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