Pygnmi
The pure Python implementation of the gNMI client.
Install / Use
/learn @akarneliuk/PygnmiREADME
========================== pyGNMI: Python gNMI client
.. image:: https://github.com/akarneliuk/pygnmi/blob/master/logo.png :width: 300 :height: 300 :alt: pyGNMI logo :align: center
|project|_ |version|_ |coverage|_ |tag|_ |license|_
This repository contains pure Python implementation of the gNMI client to interact with the network functions.
===== Usage
Sample code example:
.. code-block:: python3
Modules
from pygnmi.client import gNMIclient
Variables
host = ('169.254.255.64', '57400')
Body
if name == 'main': with gNMIclient(target=host, username='admin', password='admin', insecure=True) as gc: result = gc.get(path=['openconfig-interfaces:interfaces', 'openconfig-acl:acl'])
print(result)
Also integration with Nornir is supported (refer to examples <examples/nornir>_).
Video tutorial
Watch the detailed explanation how to use pyGNMI in our YouTube channel <https://www.youtube.com/watch?v=NooE_uHIgys&list=PLsTgo2tBPnTwmeP9zsd8B_tZR-kbguvla>_.
All gNMI RPCs supported
- Capabilities
- Get
- Set
- Subscribe
Supported operation modes
- insecure gRPC channel (without encryption)
- secure gRPC channel (with encryption and authentication based on certificate)
Tested Network Operating Systems (NOS)
- Arista EOS
- Nokia SR OS
- Cisco IOS XR
- Juniper JUNOS
- Nokia SRLinux
- Cisco NX-OS
Network Operating Systems (NOS) in test
- Broadcom SONiC
======= License
By using the pyGNMI tool you agree with the license <LICENSE.txt>_.
============ Contributors
Anton Karneliuk <https://github.com/akarneliuk>_Stefan Lieberth <https://github.com/slieberth>_Prem Anand Haridoss <https://github.com/hprem>_Andrew Southard <https://github.com/andsouth44>_Jeroen van Bemme <https://github.com/jbemmel>_Frédéric Perrin <https://github.com/fperrin>_Malanovo <https://github.com/malanovo>_Sebastian Lohff <https://github.com/sebageek>_
======= Dev Log
Release 0.8.15:
- IPv6 support:
Issue 166 <https://github.com/akarneliuk/pygnmi/pull/166>_. - Double support:
Issue 165 <https://github.com/akarneliuk/pygnmi/pull/165>_.
Release 0.8.14:
- Number of minor bug fixes and improvements.
- Adding support of
prefixtopygnmicli. Adding error propagation from child thread to main thread <https://github.com/akarneliuk/pygnmi/pull/142>_Changes to u_val <https://github.com/akarneliuk/pygnmi/pull/144>_Adding Master Arbitration support for Set <https://github.com/akarneliuk/pygnmi/pull/146>_Adding bytes_val and leaflist_val with string_val parsing <https://github.com/akarneliuk/pygnmi/pull/151>_
Release 0.8.13:
- Number of minor bug fixes and improvements.
Release 0.8.12:
- Fixed operation of
no_qos_markingflag forpygnmicli.
Release 0.8.11:
- Previous release introduced break for telemetry in
Juniperdue to inconsistency of communicated encoudings inCapabilities()and what is really supported inSubscribe().
Release 0.8.10:
- Automatic detection of supported encoding and using it where applicable (e.g., in
subscribe2method). - Possibility to remove
qosfromSubscribefor platforms, which doesn't support it (e.g.,Juniper).
Release 0.8.9:
- Default value for
encodingeverywhere is set toNone. - Method
capabilities()now is called as part ofconnect()to collect supported encoding as part of session establishing. - If
encodingis not specified by user, then it is auto-set based on the list collected viacapabilites()withjsonhaving the first priority follwed byjson_ietf.
Release 0.8.8:
- Added new argument
-e / --encodingtopygnmiclito specify the encoding, which overrides the default one. Fix forIssue 58 <https://github.com/akarneliuk/pygnmi/issues/58>_. - Fixed minor bug with encoding handling inside
get()andsubscribe2()methods. - Simplified the code.
Release 0.8.7:
- Fixed bug, when returned
json_valorjson_ietf_valis not processed correctly if the value is empty string. Fix forIssue 58 <https://github.com/akarneliuk/pygnmi/issues/58>_.
Release 0.8.6:
- Fixed minor issue with establishing
insecurechannel. - Fixed bug with inabillity to specify
prefixin Subscribe messages forsubscribe2()method. - Important: It is recommended to use method
subscribe2()instead ofsubscribe()for building telemetry collectors withpygnmias this method is further developed and throroughle tested. The methodsubscribe()will be deprecated in future releases. - Functionality
qosis now properly supported insubscribe2()method.
Release 0.8.5:
- Fixed some issues with telemetry representation with
pygnmicli.
Release 0.8.4:
- Change logic of setting default values for some parameters to improve user experience.
- Added
tokenauthentication topygnmicli.
Release 0.8.3:
- Changed behaviour of
subscribe2()to RPC to avoid adding the emptyExtensionfield for no extensions presenting. Fix forIssue 83 <https://github.com/akarneliuk/pygnmi/issues/83>_. - Uppdated documentation with examples in GitHub.
- Added support of History extensions to
pygnmicli.
Release 0.8.2:
- Implemented
History Extension <https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-history.md#1-purpose>_. - Implemented handling of corner case, where
--skip-verifywas failing trying to parse certificate,which doesn't have CN and SARs <https://github.com/akarneliuk/pygnmi/issues/71>_.
Release 0.8.1:
- Removed the need for
--no-binary=protobuffor operation.
Release 0.8.0:
- Important: potentially breaking change. The dependency is moved from
grpcio-toolstoprotobuf, which as a standalone package has a much newer serion. - Spec is rebuilt and updated to support gNMI of version
0.8.0.
Release 0.7.5:
- Amended the logic of
ONCEtelemetry mode to automatically terminate on receiving{"sync_response": True}message.
Release 0.7.4:
- Feature
skip_verifyis now stabilised and doesn't require subject alternative names any more.
Release 0.7.3:
- Amended the logic of
targetfunctionality to be more inline with gNMI Reference.
Release 0.7.2:
- Minor bug fixing in the
skip_verifylogic. Impotant: for this feature to work, you need at least one subject alternative name filed (DNS, IP address, email, - any will work). It also doesn't matter which value it has, but at least one item shall present.
Release 0.7.1:
- Added new argument
skip_verifytogNMIclient, which removes a need to set theoverrideargument manually. However, the latter one still stays for the backward compatibility. - Changed default values for arguments
usernameandpasswordfromNoneto"", as with token-based authentication they don't need to be specified. - Added new argument
targettogNMIclient.get(),gNMIclient.set(), andgNMIclient.subscribe2()methods. If provided, it addstargetkey toPath()perGNMI Specification 2.2.2.1 <https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#2221-path-target>_.
Release 0.7.0:
- Added authentication with Token using
Authorization: Bearer TOKEN, whereTOKENis a variable provided asgNMIclient(token=TOKEN)key (needed for Arista CVP). - Added functionality to change
GRPC_SSL_CIPHER_SUITESdynamically toHIGHvalue (needed for Nokia SR OS).
Release 0.6.9:
- Adding new documentation for mutual TLS feature.
Release 0.6.8:
- Minor bug-fixing.
Release 0.6.7:
- Added new
show_diffkey togNMIclientobject (supported valuesprintandget). When applied, it shows the changes happened to all keys following XPath from all arguments toSet()RPC at the network devices. It is so fair tailored to OpenConfig YANG modules as it uses some architectural principles of OpenConfig YANG module to re-construct XPath. - Added an optional timeout to
connect()method. - Minor bug-fixing.
Release 0.6.6:
- Minor bug-fixing.
Release 0.6.5:
- Implemented
prefixandtimestampinSetResponsemessage. - Implemented
aliasandatomicinNotificationmessage. - Minor bug-fixing.
Release 0.6.4:
- Minor bug-fixing.
Release 0.6.3:
- Implemented
prefixkey in theUpdatemessage. - Added possibility to provide password in STDIN rather than key.
- Minor bug-fixing.
Release 0.6.2:
- Added support of keepalive timer for gRPC session to prevent automatic closure each 2 hours.
- Fixed issue with
SubscribeRPC not sending delete notification in case of a path is removed from the node. - Added the CLI based tool.
- Minor bug-fixing.
Release 0.6.1:
- Added support of origin per RFC7951.
- Added timeout to the initial setup useful for long-living connections.
- Minor bug-fixing.
Release 0.6.0:
- Significant improvements in telemetry capabilities of the pygnmi. Now you can use
subscribe2method by simply providing the a corredponding dictionary at input and all modes (STREA, ONCE, POLL) are working correctly. - Function
telemetryParseris now automatically used insidesubscribe2. - Telemetry is now implemeted using
threading. - Added new unit tests with
pytestand added code coverage withcoverage.py.
Release 0.5.3:
- Minor improvements and bug fixing.
- Full coverage of unit tests for all operations (Capabilities, Get, Set(Update, Replace, Delete), Subscribe) and all notations of GNMI Path.
Release 0.5.2:
- Minor bug fixing.
- First release with unit tests.
Release 0.5.1:
- Added example for non-blockin
