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

use yang prefix in first path element? #56

Closed hellt closed 2 years ago

hellt commented 2 years ago

Hi looking at this line it seems impossible to specify the path element to contain a yang prefix, as the element before : will be promoted to origin.

Consider the following OC path that specifies a fully qualified top level element by setting yang prefix in the first element:

/oc-netinst:network-instances/...

In this path oc-netinst is a yang prefix of a module and not the origin. It is expected that this path will translate to a path with a first path element to be oc-netinst:network-instances with no origin set.

akarneliuk commented 2 years ago

Hello @hellt ,

yes, here is explained expected formats: https://github.com/akarneliuk/pygnmi/blob/33c6fc04b7743b787f2d016e3cb9f9eed9a933fb/pygnmi/path_generator.py#L9

The paths are built in accordance with https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-path-conventions.md who specifically for OpenConfig it is expected that path should work without prefix as well. So far, this implementation was tested with Nokia SR OS (for Nokia and OpenConfig), Cisco IOS XR, Arista EOS, Juniper JUNOS.

If there is any particular problem, would be good to see derails.

Best, Anton

hellt commented 2 years ago

gnmi path conventions doc doesn't say that for a path/foo:bar/baz the foo part is promoted to path origin. And that is what pygnmi does

akarneliuk commented 2 years ago

Hey @hellt ,

I've done some tests, basically, we already have implementation of the origin:

string:
openconfig-platform://openconfig-interfaces:interfaces/

Path():
origin: "openconfig-platform"
elem {
  name: "openconfig-interfaces:interfaces"
}

string:
openconfig-platform:/openconfig-interfaces:interfaces/

Path():
origin: "openconfig-platform"
elem {
  name: "openconfig-interfaces:interfaces"
}

string:
/openconfig-platform://openconfig-interfaces:interfaces/

Path():
origin: "openconfig-platform"
elem {
  name: "openconfig-interfaces:interfaces"
}

string:
/openconfig-platform:/openconfig-interfaces:interfaces/

Path():
origin: "openconfig-platform"
elem {
  name: "openconfig-interfaces:interfaces"
}

So, I guess, we are align here.

Best, Anton

hellt commented 2 years ago

Great. That will help with using uniform path notation