/sysrepo-python

Python bindings for sysrepo

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

sysrepo-python

Python CFFI bindings to sysrepo.

pypi-project__ python-versions__ build-status__ license__ code-style__

Installation

This assumes that libsysrepo.so is installed on the system and that sysrepo.h is available in the system include dirs.

Since sysrepo depends on libyang, the latter needs to be installed on the system as well.

You need the following system dependencies installed:

  • Python development headers
  • GCC
  • Python CFFI module

On a Debian/Ubuntu system:

Compatibility

The current version requires at least C sysrepo 2.2.0.

The last version of the bindings that works with C sysrepo 1.x is v0.7.0.

Compilation Flags

If sysrepo headers and libraries are installed in a non-standard location, you can export the SYSREPO_HEADERS and SYSREPO_LIBRARIES variables. Additionally, for finer control, you may use SYSREPO_EXTRA_CFLAGS and SYSREPO_EXTRA_LDFLAGS:

Note

This Python package depends on libyang CFFI bindings, if it is not installed yet and libyang headers and libraries are also installed in a non-standard location, you must export additional variables. See the "Compilation Flags" section here: https://pypi.org/project/libyang/.

Examples

Module Config Replacement

Operational Data Request

RPC Call

Subscription

See the examples/ folder for more details.

Differences With libsysrepo.so C API

This project has been created with Python users in mind. In order to get a more pythonic API there are significant divergences with the C API.

Supported Features

  • Connection handling (sr_connect(), sr_disconnect())
  • YANG modules management (sr_install_module(), sr_remove_module())
  • libyang context retrieval (sr_get_context() wrapped using the libyang CFFI bindings).
  • Session management (sr_session_start(), sr_session_stop(), sr_session_switch_ds(), sr_session_get_ds(), sr_unsubscribe())
  • Module change subscriptions (sr_module_change_subscribe() also with async callbacks, sr_get_changes_iter()).
  • Operational data subscriptions (sr_oper_get_items_subscribe() also with async callbacks).
  • RPC/action call subscriptions (sr_rpc_subscribe_tree() also with async callbacks).
  • Notifications subscriptions (sr_event_notif_subscribe_tree() also with async callbacks).
  • Notification dispatch (sr_event_notif_send_tree()).
  • RPC/action calling (sr_rpc_send_tree())
  • Datastore edition (sr_set_item_str(), sr_delete_item(), sr_edit_batch(), sr_validate(), sr_apply_changes(), sr_discard_changes(), sr_replace_config())
  • Get data (sr_get_data(), sr_get_item(), sr_get_items())
  • Module locking (sr_*lock*)

Partially Supported Features

All other features are not yet or only partially supported by sysrepo-python. The most notable are:

  • Module management (sr_*_module_*)

Contributing

This is an open source project and all contributions are welcome.

See the CONTRIBUTING.rst file for more details.