This library wraps gNMI functionality to ease usage with Cisco implementations.
Project description
cisco-gnmi-python
This library wraps gNMI functionality to ease usage with Cisco implementations in Python programs. Derived from openconfig/gnmi.
Usage
pip install cisco-gnmi
python -c "import cisco_gnmi; print(cisco_gnmi)"
This library covers the gNMI defined capabilities
, get
, set
, and subscribe
RPCs, and helper clients provide OS-specific recommendations. As commonalities and differences are identified this library will be refactored as necessary.
It is highly recommended that users of the library learn Google Protocol Buffers syntax to significantly ease usage. Understanding how to read Protocol Buffers, and reference gnmi.proto
, will be immensely useful for utilizing gNMI and any other gRPC interface.
Client
Client
is a very barebones class simply implementing capabilities
, get
, set
, and subscribe
methods. It provides some context around the expectation for what should be supplied to these RPC functions and helpers for validation.
Methods are documented in src/cisco_gnmi/client.py
.
XRClient
XRClient
inherets from Client
and provides several wrapper methods which aid with IOS XR-specific behaviors of the gNMI implementation. These are delete_xpaths
, get_xpaths
, set_json
, and subscribe_xpaths
. These methods make several assumptions about what kind of information will be supplied to them in order to simplify usage of the gNMI RPCs.
Methods are documented in src/cisco_gnmi/xr.py
.
gNMI
gRPC Network Management Interface (gNMI) is a service defining an interface for a network management system (NMS) to interact with a network element. It may be thought of as akin to NETCONF or other control protocols which define operations and behaviors. The scope of gNMI is relatively simple - it seeks to "[define] a gRPC-based protocol for the modification and retrieval of configuration from a target device, as well as the control and generation of telemetry streams from a target device to a data collection system. The intention is that a single gRPC service definition can cover both configuration and telemetry - allowing a single implementation on the target, as well as a single NMS element to interact with the device via telemetry and configuration RPCs".
gNMI is a specification developed by OpenConfig, an operator-driven working-group. It is important to note that gNMI only defines a protocol of behavior - not data models. This is akin to SNMP/MIBs and NETCONF/YANG. SNMP and NETCONF are respectively decoupled from the data itself in MIBs and YANG modules. gNMI is a control protocol, not a standardization of data. OpenConfig does develop standard data models as well, and does have some specialized behavior with OpenConfig originating models, but the data models themselves are out of the scope of gNMI.
Development
Requires Python and utilizes pipenv
for environment management. Manual usage of pip
/virtualenv
is not covered. Uses black
for code formatting and pylint
for code linting. black
is not explicitly installed as it requires Python 3.6+.
Get Source
git clone https://github.com/cisco-ie/cisco-gnmi-python.git
cd cisco-gnmi-python
# If pipenv not installed, install!
pip install --user pipenv
# Now use pipenv
pipenv --three install --dev
# Enter virtual environment
pipenv shell
# Do your thing.
exit
Code Hygiene
We use black
for code formatting and pylint
for code linting. hygiene.sh
will run black
against all of the code under gnmi/
except for protoc
compiled protobufs, and run pylint
against Python files directly under gnmi/
. They don't totally agree, so we're not looking for perfection here. black
is not automatically installed due to requiring Python 3.6+. hygiene.sh
will check for regular path availability and via pipenv
, and otherwise falls directly to pylint
. If black
usage is desired, please install it into pipenv
if using Python 3.6+ or separate methods e.g. brew install black
.
# If using Python 3.6+
pipenv install --dev black
# Otherwise...
./hygiene.sh
Recompile Protobufs
If a new gnmi.proto
definition is released, use update_protos.sh
to recompile. If breaking changes are introduced the wrapper library must be updated.
./update_protos.sh
Licensing
cisco-gnmi-python
is licensed as Apache License, Version 2.0.
Issues
Open an issue :)
Related Projects
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 Distributions
Hashes for cisco_gnmi-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93daa0a6029a49177ffad7b6a80125c51706f4b8708a41cd6b6024b3f6fd03d7 |
|
MD5 | a459a89a2b8f1c56fa96f35ec7d3c496 |
|
BLAKE2b-256 | 7b4fb93e63b480ea46f53abd1f008b8065d176c1d5c236fd1f6cdd3de9129851 |
Hashes for cisco_gnmi-0.0.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79daf5eaa22feaed3b79ddec58569ebd8082b1f619eefa5772a3b36489fd91af |
|
MD5 | fa7219c52c906d3f421bc24891458abf |
|
BLAKE2b-256 | 6f01f6879484808dc3465752f3ce3a32ae4f6d7af1f015c85cf632f19cc596fe |