Skip to content

Commit

Permalink
0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
akarneliuk committed Mar 14, 2021
1 parent 27f3847 commit 4c3019d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 13 deletions.
7 changes: 6 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ By using the pyGNMI tool you agree with `the license <LICENSE.txt>`_.
Dev Log
=======

Release **0.4.2**:

- Modified the path generation to comply with `gNMI Path encoding conventions <https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-path-conventions.md>`_.
- Fixed the problem ``debug`` output, where the requests where not printed in case of response failing.

Release **0.4.1**:

- Minor bug fix.
Expand Down Expand Up @@ -208,7 +213,7 @@ Release **0.1.0**:

(c)2020-2021, karneliuk.com

.. |version| image:: https://img.shields.io/static/v1?label=latest&message=v0.4.1&color=success
.. |version| image:: https://img.shields.io/static/v1?label=latest&message=v0.4.2&color=success
.. _version: https://pypi.org/project/pygnmi/
.. |tag| image:: https://img.shields.io/static/v1?label=status&message=in%20development&color=yellow
.. _tag: https://pypi.org/project/pygnmi/
Expand Down
Binary file removed dist/pygnmi-0.4.0.tar.gz
Binary file not shown.
Binary file added dist/pygnmi-0.4.1.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pygnmi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#(c)2019-2021, karneliuk.com

__version__ = '0.4.1'
__version__ = '0.4.2'
24 changes: 18 additions & 6 deletions pygnmi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@ def capabilities(self):

try:
gnmi_message_request = CapabilityRequest()
gnmi_message_response = self.__stub.Capabilities(gnmi_message_request, metadata=self.__metadata)

if self.__debug:
print("gNMI request:\n------------------------------------------------")
print(gnmi_message_request)
print("------------------------------------------------\n\n\ngNMI response:\n------------------------------------------------")
print("------------------------------------------------")

gnmi_message_response = self.__stub.Capabilities(gnmi_message_request, metadata=self.__metadata)

if self.__debug:
print("\n\n\ngNMI response:\n------------------------------------------------")
print(gnmi_message_response)
print("------------------------------------------------")

Expand Down Expand Up @@ -199,12 +203,16 @@ def get(self, path: list, datatype: str = 'all', encoding: str = 'json'):

try:
gnmi_message_request = GetRequest(path=protobuf_paths, type=pb_datatype, encoding=pb_encoding)
gnmi_message_response = self.__stub.Get(gnmi_message_request, metadata=self.__metadata)

if self.__debug:
print("gNMI request:\n------------------------------------------------")
print(gnmi_message_request)
print("------------------------------------------------\n\n\ngNMI response:\n------------------------------------------------")
print("------------------------------------------------")

gnmi_message_response = self.__stub.Get(gnmi_message_request, metadata=self.__metadata)

if self.__debug:
print("\n\n\ngNMI response:\n------------------------------------------------")
print(gnmi_message_response)
print("------------------------------------------------")

Expand Down Expand Up @@ -375,12 +383,16 @@ def set(self, delete: list = None, replace: list = None, update: list = None, en

try:
gnmi_message_request = SetRequest(delete=del_protobuf_paths, update=update_msg, replace=replace_msg)
gnmi_message_response = self.__stub.Set(gnmi_message_request, metadata=self.__metadata)

if self.__debug:
print("gNMI request:\n------------------------------------------------")
print(gnmi_message_request)
print("------------------------------------------------\n\n\ngNMI response:\n------------------------------------------------")
print("------------------------------------------------")

gnmi_message_response = self.__stub.Set(gnmi_message_request, metadata=self.__metadata)

if self.__debug:
print("\n\n\ngNMI response:\n------------------------------------------------")
print(gnmi_message_response)
print("------------------------------------------------")

Expand Down
12 changes: 9 additions & 3 deletions pygnmi/path_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ def gnmi_path_generator(path_in_question: list):
gnmi_path.origin = pe_entry.split(':')[0]
gnmi_path.elem.add(name=pe_entry.split(':')[1])

elif re.match('.+?\[\d+?\].*?', pe_entry):
key_id = int(re.sub('.+?\[(\d+?)\].*?', '\g<1>', pe_entry))
gnmi_path.elem.add(name=pe_entry.split('[')[0], key=keys[key_id])
elif re.match('.+?\[\d+?\]', pe_entry):
element_keys = {}
path_info = [re.sub(']', '', en) for en in pe_entry.split('[')]
element = path_info.pop(0)

for ek in path_info:
element_keys.update(keys[int(ek)])

gnmi_path.elem.add(name=element, key=element_keys)

else:
gnmi_path.elem.add(name=pe_entry)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
setup(
name = 'pygnmi',
packages = ['pygnmi', 'pygnmi.spec', 'pygnmi.artefacts'],
version = '0.4.1',
version = '0.4.2',
license='bsd-3-clause',
description = 'This repository contains pure Python implementation of the gNMI client to interact with the network functions.',
long_description = long_description,
long_description_content_type = 'text/x-rst',
author = 'Anton Karneliuk',
author_email = '[email protected]',
url = 'https://github.com/akarneliuk/pygnmi',
download_url = 'https://github.com/akarneliuk/pygnmi/archive/v0.4.1.tar.gz',
download_url = 'https://github.com/akarneliuk/pygnmi/archive/v0.4.2.tar.gz',
keywords = ['gnmi', 'automation', 'grpc', 'network'],
install_requires=[
'grpcio',
Expand Down

0 comments on commit 4c3019d

Please sign in to comment.