Skip to main content

Python Netgear Switch Interface Library

Query and control all your Netgear switches — SNMP (managed), NSDP and HTTP web-UI (Plus) — behind one model-driven Python API and the ngsw CLI.

Documentation: https://python-netgear-switch-library.readthedocs.io/ — API reference, the complete ngsw CLI reference, the virtual-switch guide (how to test your own tools against a mock), and generated model × protocol and model × functionality support tables.

Status: early development. See docs/superpowers/specs/ for the design and docs/superpowers/plans/ for the implementation plans.

Installation

pip / uv (PyPI)

pip install python-netgear-switch-library
# or: uv add python-netgear-switch-library

Optional extras: [async] (pysnmp), [http] (httpx). The synchronous SNMP transport shells out to the net-snmp command-line tools, a system package (not a Python dependency):

sudo apt install snmp   # provides snmpget/snmpbulkwalk/snmpset

Debian / Ubuntu (apt)

Signed .deb packages for Debian trixie and sid are published to a GitHub Pages apt repository. Pick the line matching your suite:

sudo install -d -m0755 /etc/apt/keyrings
curl -fsSL https://mithro.github.io/python-netgear-switch-library/netgear-switch.gpg \
  | sudo tee /etc/apt/keyrings/netgear-switch.gpg > /dev/null

# trixie:
echo "deb [signed-by=/etc/apt/keyrings/netgear-switch.gpg] https://mithro.github.io/python-netgear-switch-library/trixie/ ./" \
  | sudo tee /etc/apt/sources.list.d/netgear-switch.list
# sid:
echo "deb [signed-by=/etc/apt/keyrings/netgear-switch.gpg] https://mithro.github.io/python-netgear-switch-library/sid/ ./" \
  | sudo tee /etc/apt/sources.list.d/netgear-switch.list

sudo apt update
sudo apt install python3-netgear-switch-library

This installs the netgear_switch library and the ngsw CLI, and pulls in the snmp net-snmp CLI tools automatically.

Either way, once installed run ngsw --help to see available commands.

Versioning

This project is a rolling release: the version is derived from git (0.0.postN / X.Y.postN), and every merge to main publishes a new version to PyPI and the apt repo. There are no tags or manual version bumps.

Mock switch daemons (ngsw serve)

The library ships in-repo virtual/mock switches. ngsw serve runs them as standalone, long-lived daemons on real sockets, so an external tool or library can point at a mock when real hardware is unavailable (CI, local development, demos).

# Serve one model (ephemeral ports), or several, or every registered model:
ngsw serve --model gsm7228ps
ngsw serve --model gsm7228ps --model gs305ep
ngsw serve --all

For each switch that comes up it prints the model, bind host, the actual bound port(s) (SNMP/NSDP over UDP, HTTP over TCP), and the SNMP community and HTTP password it accepts, then blocks until interrupted (Ctrl-C / SIGTERM), at which point every switch is stopped cleanly:

[gsm7228ps] host=127.0.0.1
    SNMP udp/36540
    HTTP tcp/42629
    community='public' http_password='password'
serving 1 mock switch(es); press Ctrl-C to stop

Point any tool at the printed port. For example, with the mock above serving SNMP on UDP 36540:

snmpwalk -v2c -c public 127.0.0.1:36540 1.3.6.1.2.1.1
# ...or the library's own CLI against the same mock:
ngsw --host 127.0.0.1 --model gsm7228ps --community public ports   # + your transport wiring

Options:

  • --model KEY — model to serve; repeatable. --all serves every registered model (see ngsw models).
  • --host IP — bind address (default 127.0.0.1). Pass 0.0.0.0 to expose the mock to other hosts on the network.
  • --community STR / --http-password STR — credentials the mock accepts (defaults public / password).
  • --port N / --http-port N — pin the SNMP/NSDP UDP port and the HTTP TCP port instead of using ephemeral ones. Because a pinned port is a single listener, these are only allowed when serving exactly one model; otherwise leave them unset and read the printed ephemeral ports.

Full details, including worked examples of testing an external tool against a mock, are in the virtual switch guide.

Development

uv sync --all-extras
uv run pytest
uv run ruff check
uv run mypy

Build the documentation (warnings are errors, as on Read the Docs):

uv sync --extra docs
make -C docs html

License

Apache-2.0.

Download files

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

Source Distribution

python_netgear_switch_library-0.0.post323.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file python_netgear_switch_library-0.0.post323.tar.gz.

File metadata

File hashes

Hashes for python_netgear_switch_library-0.0.post323.tar.gz
Algorithm Hash digest
SHA256 090bfd2fd94c38126682264fc48b52de6357b00f0c5d72546282ba910378d587
MD5 16ab62af0d774366721b30f579ce7f60
BLAKE2b-256 e39c2bcdf2fae32702c21a8a820c28a0cb3a09f76be82e3d248cf9fccb58c98e

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_netgear_switch_library-0.0.post323.tar.gz:

Publisher: publish-pypi.yml on mithro/python-netgear-switch-library

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

File details

Details for the file python_netgear_switch_library-0.0.post323-py3-none-any.whl.

File metadata

File hashes

Hashes for python_netgear_switch_library-0.0.post323-py3-none-any.whl
Algorithm Hash digest
SHA256 3a4c95aca133d5254dcb6ad36aa72e90eb5970a266a910e9a1ae395e8f42d2a7
MD5 1d869fbc253563e1376cba2908f855fe
BLAKE2b-256 83c34ade85f673eea5cb855d2a6a908c9196f413b042c71fc4f1ad6fbce1e783

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_netgear_switch_library-0.0.post323-py3-none-any.whl:

Publisher: publish-pypi.yml on mithro/python-netgear-switch-library

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