akarneliuk / pygnmi

The pure Python implementation of the gNMI client.
https://training.karneliuk.com
BSD 3-Clause "New" or "Revised" License
129 stars 44 forks source link

val.uint_val values are not returned in pygnmi response, when using get #23

Closed slieberth closed 3 years ago

slieberth commented 3 years ago

Hi Anton, I am encountering an issue, when using get with an path which returns val.uint_val. For val.json_ietf_val everything works for fine, but is just ignored.

gNMI response:

notification { update { path { elem { name: "interfaces" } elem { name: "interface" key { key: "name" value: "Management1" } } elem { name: "state" } elem { name: "counters" } elem { name: "out-unicast-pkts" } } val { uint_val: 15578 } } }


INFO||tE4_gnmiConnect.py||136||gnmi response {'notification': [{'timestamp': 0, 'update': [{'path': 'interfaces/interface[name=Management1]/state/counters/out-unicast-pkts'}]}]}

looking at the code, it looks to me, that uint_val is missing for get:

                            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)})

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

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

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

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

where asm it seems to be corrrect for the telemetry parser.

I think we have to copy the lines for those values from telemetry parser to the get section. I can take over that task and prepare a pull request.

what do you think?

akarneliuk commented 3 years ago

Hello @slieberth ,

sorry for a delay, was a bit hectic time. Thanks a lot for your kind suggestion. As it already took a bit for me to response, I've just added the missing lines in the latest release 0.5.3. Could you please test and let me know if that is good now?

Best, Anton

akarneliuk commented 3 years ago

Closed as there is no follow up.

slieberth commented 3 years ago

Hi Anton, sorry for the late reply, was on vacation, thanks for the fix, can confirm that it works ... regards Stefan