Skip to content

Commit

Permalink
Merge pull request #90 from akarneliuk/0.8.5
Browse files Browse the repository at this point in the history
0.8.5
  • Loading branch information
akarneliuk authored Jul 31, 2022
2 parents 1e4f04e + 449be19 commit 5739126
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ log/
**/coverage.json
**/htmlcov/
dist/
pygnmi_dev.py
pygnmi_dev.py
pcl
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ Contributors
Dev Log
=======

Release **0.8.5**:

- Fixed some issues with telemetry represenation with ``pygnmicli``.

Release **0.8.4**:

- Change logic of setting default values for some parameters to improve user experience.
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.4"
__version__ = "0.8.5"
5 changes: 0 additions & 5 deletions pygnmi/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def parse_args(msg):
"--token",
type=str,
required=False,
default="",
help="Specify the token for token-based authentication",
)
parser.add_argument(
Expand Down Expand Up @@ -100,7 +99,6 @@ def parse_args(msg):
"--gnmi-path-target",
type=str,
required=False,
default="",
help="Set target for GNMI path if it is different to the endpoint itself."
)
parser.add_argument(
Expand Down Expand Up @@ -137,21 +135,18 @@ def parse_args(msg):
"--ext-history-range-start",
type=str,
required=False,
default="",
help="Specify the start timestamp for the GNMI history range",
)
parser.add_argument(
"--ext-history-range-end",
type=str,
required=False,
default="",
help="Specify the end timestamp for the GNMI history range",
)
parser.add_argument(
"--ext-history-snapshot-time",
type=str,
required=False,
default="",
help="Specify the snapshit time for the GNMI history",
)

Expand Down
2 changes: 1 addition & 1 deletion pygnmi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, target: tuple, username: str = "", password: str = "",
debug: bool = False, insecure: bool = False, path_cert: str = None,
path_key: str = None, path_root: str = None, override: str = None,
skip_verify = False, gnmi_timeout: int = 5, grpc_options: list = None,
show_diff: str = "", token: str = None, **kwargs):
show_diff: str = None, token: str = None, **kwargs):

"""
Initializing the object
Expand Down
29 changes: 18 additions & 11 deletions scripts/pygnmicli
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import logging
import os
import sys

# Own modules
from pygnmi.arg_parser import parse_args
Expand Down Expand Up @@ -44,6 +45,9 @@ def main():

result = None

# Collecting supported capabilities (needed to figure out encoding for telemetry)
GC.capabilities()

if args.operation == 'capabilities':
print(f'Doing {args.operation} request to {args.target}...')
result = GC.capabilities()
Expand Down Expand Up @@ -73,9 +77,7 @@ def main():
subscription_list = [
{
'path': xpath,
'mode': 'sample',
'sample_interval': 10000000000,
'heartbeat_interval': 30000000000
'mode': 'target_defined'
}
for xpath in args.gnmi_path
]
Expand Down Expand Up @@ -121,20 +123,21 @@ def main():
else:
EXT = None

# Telemetry
result = GC.subscribe2(subscribe=subscribe,
target=args.gnmi_path_target,
extension=EXT)

if mode == "stream":
try:
for ent in result:
print(ent)
_print_result(ent)
except KeyboardInterrupt:
result.close()
sys.exit("Telemtry collection is temrinated.")

elif mode == "once":
for ent in result:
print(ent)
_print_result(ent)
if "sync_response" in ent:
break

Expand All @@ -143,13 +146,17 @@ def main():
try:
input("Press enter to poll, ctrl+c to quit")
ent = result.get_update(timeout=5)
print(ent)
_print_result(ent)
except KeyboardInterrupt:
result.close()
break
sys.exit("Telemtry collection is temrinated.")

if result and not args.debug and not args.operation.startswith('subscribe'):
_print_result(result)


if result and not args.debug:
print(json.dumps(result, indent=4))
def _print_result(value: dict) -> None:
"""This function prints the result in JSON format"""
print(json.dumps(value, indent=4))


if __name__ == "__main__":
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.v080', 'pygnmi.artefacts'],
version='0.8.4',
version='0.8.5',
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.4.tar.gz',
download_url='https://github.com/akarneliuk/pygnmi/archive/v0.8.5.tar.gz',
keywords=['gnmi', 'automation', 'grpc', 'network'],
install_requires=[
'grpcio',
Expand Down

0 comments on commit 5739126

Please sign in to comment.