You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue where '/junos/events' sensor path does not work with the subscribe2() function, even though it does with subscribe(). This is a Juniper specific sensor path on Junos 21.4R3-Evo. Other OpenConfig sensor paths work (although they are using "once" method, not "on_change"). I included an example when using the older subscribe() function which I understand will be deprecated. I am currently using pygnmi 0.8.5 as later versions include the qos feature which doesn't work in this Juniper code version, I'm waiting for a later pygnmi release that includes pull request #103.
I added debug=True when using subscribe2() but I get TypeError: argument of type 'NoneType' is not iterable. I don't think it would be much use though as when using subscribe2() you can't use telemetryParser() which is what displays the gNMI Response when debugging is enabled.
Example output with subscribe and json encoding
There are dozens of these being sent in just a few seconds, so I just picked one random one but they're all the same format.
Note that the code below is subscribe2() and does not show any data. To get it to show data, I just need to remove the 2 so it's using subscribe(). Example: telemetry_pull = gc.subscribe2(subscribe=subscribe)
#!/usr/bin/env python3
import grpc
from pygnmi.client import gNMIclient, telemetryParser
import json
from dotenv import load_dotenv
import os
ip='[omitted]'
port='32767'
load_dotenv()
username=os.getenv('TEST_USER')
password=os.getenv('TEST_PW')
sensor_path = '/junos/events'
subscribe = {
'subscription': [
{
'path': f'{sensor_path}',
'mode': 'ON_CHANGE'
}
],
'use_aliases': False,
'mode': 'stream',
'encoding': 'json'
}
def pull_telemetry_sub(ip, port, username, password, subscribe):
try:
with gNMIclient(target=(ip, port), username=username, password=password, insecure=True) as gc:
telemetry_pull = gc.subscribe2(subscribe=subscribe)
for telemetry_entry in telemetry_pull:
print(telemetry_entry)
except grpc.FutureTimeoutError as e:
print('Failed connecting to', ip, e)
except ValueError as e:
print(e)
pass
def main():
pull_telemetry_sub(ip, port, username, password, subscribe)
if __name__ == '__main__':
main()
Thanks,
Chris
The text was updated successfully, but these errors were encountered:
Hey @Menotomy ,
Thanks for raising that one. I don't have a Juniper to test against, but I shall finally have some time this week to look into this and other requests.
Best,
Anton
Hello,
I'm encountering an issue where '/junos/events' sensor path does not work with the
subscribe2()
function, even though it does withsubscribe()
. This is a Juniper specific sensor path on Junos 21.4R3-Evo. Other OpenConfig sensor paths work (although they are using "once" method, not "on_change"). I included an example when using the oldersubscribe()
function which I understand will be deprecated. I am currently using pygnmi 0.8.5 as later versions include the qos feature which doesn't work in this Juniper code version, I'm waiting for a later pygnmi release that includes pull request #103.I added
debug=True
when usingsubscribe2()
but I getTypeError: argument of type 'NoneType' is not iterable
. I don't think it would be much use though as when usingsubscribe2()
you can't usetelemetryParser()
which is what displays the gNMI Response when debugging is enabled.Example output with subscribe and json encoding
There are dozens of these being sent in just a few seconds, so I just picked one random one but they're all the same format.
pip freeze
Code
Note that the code below is
subscribe2()
and does not show any data. To get it to show data, I just need to remove the 2 so it's usingsubscribe()
. Example:telemetry_pull = gc.subscribe2(subscribe=subscribe)
Thanks,
Chris
The text was updated successfully, but these errors were encountered: