Package: dt-pygnmi
pyGNMI: Python gNMI clientThis repository contains pure Python implementation of the gNMI client to interact with the network functions.UsageSample code example:# Modulesfrompygnmi.clientimportgNMIclient# Variableshost=('169.254.255.64','57400')# Bodyif__name__=='__main__':withgNMIclient(target=host,username='admin',password='admin',insecure=True)asgc:result=gc.get(path=['openconfig-interfaces:interfaces','openconfig-acl:acl'])print(result)Also integration with Nornir is supported (refer to examples).Video tutorialWatch the detailed explanation how to use pyGNMIin our YouTube channel.All gNMI RPCs supportedCapabilitiesGetSetSubscribeSupported operation modesinsecure gRPC channel (without encryption)secure gRPC channel (with encryption and authentication based on certificate)Tested Network Operating Systems (NOS)Arista EOSNokia SR OSCisco IOS XRJuniper JUNOSNokia SRLinuxCisco NX-OSNetwork Operating Systems (NOS) in testBroadcom SONiCLicenseBy using the pyGNMI tool you agree withthe license.ContributorsAnton KarneliukStefan LieberthPrem Anand HaridossAndrew SouthardJeroen van BemmeFrédéric PerrinMalanovoSebastian LohffDev LogRelease0.8.13:
- Number of minor bug fixes and improvements.Release0.8.12:
- Fixed operation ofno_qos_markingflag forpygnmicli.Release0.8.11:
- Previous release introduced break for telemetry inJuniperdue to inconsistency of communicated encoudings inCapabilities()and what is really supported inSubscribe().Release0.8.10:
- Automatic detection of supported encoding and using it where applicable (e.g., insubscribe2method).
- Possibility to removeqosfromSubscribefor platforms, which doesn’t support it (e.g.,Juniper).Release0.8.9:Default value forencodingeverywhere is set toNone.Methodcapabilities()now is called as part ofconnect()to collect supported encoding as part of session establishing.Ifencodingis not specified by user, then it is auto-set based on the list collected viacapabilites()withjsonhaving the first priority follwed byjson_ietf.Release0.8.8:Added new argument-e/--encodingtopygnmiclito specify the encoding, which overrides the default one. Fix forIssue 58.Fixed minor bug with encoding handling insideget()andsubscribe2()methods.Simplified the code.Release0.8.7:Fixed bug, when returnedjson_valorjson_ietf_valis not processed correctly if the value is empty string.  Fix forIssue 58.Release0.8.6:Fixed minor issue with establishinginsecurechannel.Fixed bug with inabillity to specifyprefixin Subscribe messages forsubscribe2()method.Important: It is recommended to use methodsubscribe2()instead ofsubscribe()for building telemetry collectors withpygnmias this method is further developed and throroughle tested. The methodsubscribe()will be deprecated in future releases.Functionalityqosis now properly supported insubscribe2()method.Release0.8.5:Fixed some issues with telemetry representation withpygnmicli.Release0.8.4:Change logic of setting default values for some parameters to improve user experience.Addedtokenauthentication topygnmicli.Release0.8.3:Changed behaviour ofsubscribe2()to RPC to avoid adding the emptyExtensionfield for no extensions presenting. Fix forIssue 83.Uppdated documentation with examples in GitHub.Added support of History extensions topygnmicli.Release0.8.2:ImplementedHistory Extension.Implemented handling of corner case, where--skip-verifywas failing trying to parse certificate,which doesn’t have CN and SARs.Release0.8.1:Removed the need for--no-binary=protobuffor operation.Release0.8.0:Important: potentially breaking change. The dependency is moved fromgrpcio-toolstoprotobuf, which as a standalone package has a much newer serion.Spec is rebuilt and updated to support gNMI of version0.8.0.Release0.7.5:Amended the logic ofONCEtelemetry mode to automatically terminate on receiving{"sync_response": True}message.Release0.7.4:Featureskip_verifyis now stabilised and doesn’t require subject alternative names any more.Release0.7.3:Amended the logic oftargetfunctionality to be more inline with gNMI Reference.Release0.7.2:Minor bug fixing in theskip_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.Release0.7.1:Added new argumentskip_verifytogNMIclient, which removes a need to set theoverrideargument manually. However, the latter one still stays for the backward compatibility.Changed default values for argumentsusernameandpasswordfromNoneto"", as with token-based authentication they don’t need to be specified.Added new argumenttargettogNMIclient.get(),gNMIclient.set(), andgNMIclient.subscribe2()methods. If provided, it addstargetkey toPath()perGNMI Specification 2.2.2.1.Release0.7.0:Added authentication with Token usingAuthorization: Bearer TOKEN, whereTOKENis a variable provided asgNMIclient(token=TOKEN)key (needed for Arista CVP).Added functionality to changeGRPC_SSL_CIPHER_SUITESdynamically toHIGHvalue (needed for Nokia SR OS).Release0.6.9:Adding new documentation for mutual TLS feature.Release0.6.8:Minor bug-fixing.Release0.6.7:Added newshow_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 toconnect()method.Minor bug-fixing.Release0.6.6:Minor bug-fixing.Release0.6.5:ImplementedprefixandtimestampinSetResponsemessage.ImplementedaliasandatomicinNotificationmessage.Minor bug-fixing.Release0.6.4:Minor bug-fixing.Release0.6.3:Implementedprefixkey in theUpdatemessage.Added possibility to provide password in STDIN rather than key.Minor bug-fixing.Release0.6.2:Added support of keepalive timer for gRPC session to prevent automatic closure each 2 hours.Fixed issue withSubscribeRPC not sending delete notification in case of a path is removed from the node.Added the CLI based tool.Minor bug-fixing.Release0.6.1:Added support of origin per RFC7951.Added timeout to the initial setup useful for long-living connections.Minor bug-fixing.Release0.6.0:Significant improvements in telemetry capabilities of the pygnmi. Now you can usesubscribe2method by simply providing the a corredponding dictionary at input and all modes (STREA, ONCE, POLL) are working correctly.FunctiontelemetryParseris now automatically used insidesubscribe2.Telemetry is now implemeted usingthreading.Added new unit tests withpytestand added code coverage withcoverage.py.Release0.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.Release0.5.2:Minor bug fixing.First release with unit tests.Release0.5.1:Added example for non-blocking iterator for telemetry.Added the extra support for Juniper TLS certificates.Fixed regexp warnings.Changed the logging functionality.Enabled Unix domain socket.Addedclose()Many thanks for all contributors to make this release happen.Release0.5.0:Added possibility to extract certificate from the destination network function.Release0.4.8:Added documentation in module regading supported the different paths naming conventions. Supported options:yang-module:container/container[key=value],/yang-module:container/container[key=value],/yang-module:/container/container[key=value],/container/container[key=value]Release0.4.6:FixedgNMI Path issue.Release0.4.6:Replaced thesys.exitwith raising exceptions.Minor bug fix.Brought the gNMI path to the canonical format:/origin:element1/element2....Added possibility to omit the YANG module name, as some vendors doesn’t include that in the request per their gNMI implementation:/element1/element2....Release0.4.5:Minor bug fix.Release0.4.4:Minor bug fix.Release0.4.3:Added possibility to modify the timeout (default value is 5 seconds) for the session usinggnmi_timeoutkey forgNMIclientclass.Release0.4.2:Modified the path generation to comply withgNMI Path encoding conventions.Fixed the problemdebugoutput, where the requests where not printed in case of response failing.Release0.4.1:Minor bug fix.Release0.4.0:Added support for Juniper JUNOSFixed the issue withoverridefor PKI-based certificatesRelease0.3.12:Minor bug fix.Release0.3.11:Minor bug fix.Release0.3.10:Renamed the debug mode. Add argumentdebug=Trueupon object creation to see the Protobuf messages.Release0.3.9:Added functionality to list the full the device configuration in case the path is empty:get(path[]).Release0.3.8:Merged the proposal how to implement TLS with override for Cisco IOS XR (tested for Cisco IOS XR, to be tested for other vendors yet)Merged examples with TLSRelease0.3.7:Added the argumentencodingas an extra key toSetoperationRelease0.3.6:Added the argumentencodingtoGetoperationRelease0.3.5:Added the example for Nornir IntegrationAdded the topology diagramAdded links to the video tutorialRelease0.3.4:Added theclosemethod togNMIClientclass for those, who doesn’t usewith ... as ...context manager.Release0.3.3:Added the functionality to pass gRPC messages to the code executionRelease0.3.2:Minor bugs fixed.Release0.3.1:Minor bugs fixed.Added examples of gNMI operations.Release0.3.0:Added new functiontelemetryParser, which converts Protobuf messages in Python dictionary.Fixed the errors with the telemetry parsing.Release0.2.7:Modified core so that telemetry is working inonceandstreammode.Release0.2.6:Added alpha version of theSubscribeoperation.Release0.2.5:Added typing hints.Release0.2.4:Minor bugfixing.Release0.2.3:Added support for IPv6 transport (now you can connect to the network function over IPv6).Release0.2.2:Added conversion of the collected information over the gNMI into a Python dictionary for Set operation.Release0.2.1:Fixing the bugs with improper Protobuf paths generation.Now allSetoperations (delete,replace, andupdate) are working properly.Releast0.2.0:Added theSetoperation from gNMI specification.Releast0.1.9:Added the propertydatatype='all'to the get() request. The values are per the gNMI specification: all, config, state, operatonal.Release0.1.8:Added conversion of the collected information over the gNMI into a Python dictionary for Get operation.Release0.1.7:Changing packages modules.Release0.1.6:Restructuring internal context.Release0.1.5:Minor bugfixing.Release0.1.4:Minor bugfixing.Release0.1.3:Minor bugfixing.Release0.1.2:The gNMIClient is recreated as context manger.Tests with Nokia SR OS done, the module is working nice for insecure channel.Release0.1.1:Added theGetoperation out of gNMI specification.Release0.1.0:The first release.(c)2020-2022, karneliuk.com