09-30-2019 12:04 AM
Hi Team,
Tried a gNMI subscribe request with encoding option as 'PROTO', able to get ServiceResponse in str.
But with encoding type as "JSON/JSON_IETF" we are getting unsupported error as below,
>>> gnmi.subscribe(provider, subscription, 10, "ONCE", "JSON")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nobackup/kuamrend/env/lib64/python3.6/site-packages/ydk/gnmi/services/gnmi_service.py", line 78, in subscribe
self._gs.subscribe(provider, subscription, qos, mode, encoding, gnmi_subscribe_callback)
RuntimeError: YServiceProviderError: SubscribeRequest failed with error:
gNMI: subscribe: unsupported encoding: JSON
>>> gnmi.subscribe(provider, subscription, 10, "ONCE", "JSON_IETF")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nobackup/kuamrend/env/lib64/python3.6/site-packages/ydk/gnmi/services/gnmi_service.py", line 78, in subscribe
self._gs.subscribe(provider, subscription, qos, mode, encoding, gnmi_subscribe_callback)
RuntimeError: YServiceProviderError: SubscribeRequest failed with error:
gNMI: subscribe: unsupported encoding: JSON_IETF
Our Requirement : Subscibe ServiceResponse o/p as Entity
- gNMI get we are able to get the response as Entity. Is it possible to convert the Subnsribe response into entity with any available PACAKEGE. Any pointers to achieve this will be very helpful.
Also can you point if I missed any dependency.
Example str 0/p of SERVICEResponse with "PROTO" encoding option,
>>> gnmi.subscribe(provider, subscription, 10, "ONCE", "PROTO")
... >>> Globals.subscribe_data[3]
... 'update {\n timestamp: 1569613926524000000\n prefix {\n origin: "openconfig-interfaces"\n elem {\n name: "interfaces"\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "in-octets"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "out-octets"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "in-multicast-pkts"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "in-broadcast-pkts"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "out-multicast-pkts"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "out-broadcast-pkts"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "in-unknown-protos"\n }\n }\n val {\n uint_val: 2442\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "in-errors"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "out-errors"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "in-unicast-pkts"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "in-discards"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "out-unicast-pkts"\n }\n }\n val {\n uint_val: 0\n }\n }\n update {\n path {\n elem {\n name: "interface"\n key {\n key: "name"\n value: "FourHundredGigE0/0/0/23"\n }\n }\n elem {\n name: "state"\n }\n elem {\n name: "counters"\n }\n elem {\n name: "out-discards"\n }\n }\n val {\n uint_val: 0\n }\n }\n}\n'
Regards,
Kousalya
09-30-2019 09:58 AM
Hi Kousalya
You are getting this error, because the gNMI server that you are connecting to does not support JSON encoding for subscribe requests. I know that IOS-XR gNMI server currently supports only Proto encoding. You will need provide parsing of proto encoded response and translation to JSON in your callback function.
We have been considering adding the translation from Proto to JSON to YDK codec services, but have not implemented it due to luck of resources. That would be a good project for YDK development.
Thanks,
Yan
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide