Skip to content

Commit

Permalink
Merge pull request #92 from akarneliuk/0.8.7
Browse files Browse the repository at this point in the history
0.8.7
  • Loading branch information
akarneliuk committed Aug 10, 2022
2 parents 569f667 + 673b991 commit 33893c7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ Contributors
Dev Log
=======

Release **0.8.7**:

- Fixed bug, when returned ``json_val`` or ``json_ietf_val`` is not processed correctly if the value is empty string. Fix for `Issue 58 <https://github.com/akarneliuk/pygnmi/issues/58>`_.

Release **0.8.6**:

- Fixed minor issue with establishing ``insecure`` channel.
Expand Down Expand Up @@ -401,7 +405,7 @@ Release **0.1.0**:

(c)2020-2022, karneliuk.com

.. |version| image:: https://img.shields.io/static/v1?label=latest&message=v0.8.6&color=success
.. |version| image:: https://img.shields.io/static/v1?label=latest&message=v0.8.7&color=success
.. _version: https://pypi.org/project/pygnmi/
.. |tag| image:: https://img.shields.io/static/v1?label=status&message=stable&color=success
.. _tag: https://pypi.org/project/pygnmi/
Expand Down
2 changes: 1 addition & 1 deletion pygnmi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
pyGNMI module to manage network devices with gNMI
(c)2020-2022, Karneliuk
"""
__version__ = "0.8.6"
__version__ = "0.8.7"
25 changes: 21 additions & 4 deletions pygnmi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import time
import threading
import os
from typing import Any
import cryptography
import grpc
from pygnmi.spec.v080.gnmi_pb2_grpc import gNMIStub
Expand Down Expand Up @@ -191,7 +192,7 @@ def connect(self, timeout: int = None):

# Set empty override if neither CN ans SARs exist
if not ssl_cert_common_name and not self.__cert_sans:
self.__options.append(("grpc.ssl_target_name_override", ""))
self.__options.append(("grpc.ssl_target_name_override", "".encode(encoding="utf-8")))

logger.warning('ssl_target_name_override is applied, should be used for testing only!')

Expand Down Expand Up @@ -438,13 +439,13 @@ def get(self, prefix: str = "", path: list = None,
# Message Update, Key val
if update_msg.HasField('val'):
if update_msg.val.HasField('json_ietf_val'):
update_container.update({'val': json.loads(update_msg.val.json_ietf_val)})
update_container.update({'val': process_potentially_json_value(update_msg.val.json_ietf_val)})

elif update_msg.val.HasField('json_val'):
update_container.update({'val': json.loads(update_msg.val.json_val)})
update_container.update({'val': process_potentially_json_value(update_msg.val.json_val)})

elif update_msg.val.HasField('string_val'):
update_container.update({'val':update_msg.val.string_val})
update_container.update({'val': update_msg.val.string_val})

elif update_msg.val.HasField('int_val'):
update_container.update({'val': update_msg.val.int_val})
Expand Down Expand Up @@ -1242,8 +1243,24 @@ def telemetryParser(in_message=None, debug: bool = False):


def debug_gnmi_msg(is_printable, what_to_print, message_name) -> None:
"""This helper function prints debug output"""
if is_printable:
print(message_name)
print("-" * os.get_terminal_size().columns)
print(what_to_print)
print("-" * os.get_terminal_size().columns, end="\n\n\n")


def process_potentially_json_value(input_val) -> Any:
"""This helper method converts value from bytestream"""
unprocessed_value = input_val.decode(encoding="utf-8")

if unprocessed_value:
try:
processed_val = json.loads(unprocessed_value)
except json.decoder.JSONDecodeError:
processed_val = unprocessed_value
else:
processed_val = None

return processed_val
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.v080', 'pygnmi.artefacts'],
version='0.8.6',
version='0.8.7',
license='bsd-3-clause',
description='Pure Python gNMI client to manage network functions and collect telemetry.',
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.8.6.tar.gz',
download_url='https://github.com/akarneliuk/pygnmi/archive/v0.8.7.tar.gz',
keywords=['gnmi', 'automation', 'grpc', 'network'],
install_requires=[
'grpcio',
Expand Down

0 comments on commit 33893c7

Please sign in to comment.