Skip to content

Path

Description#

With path command it is possible to generate and search through the XPATH style paths extracted from a YANG file.

By extracting the XPATH styled paths from a YANG model it is made possible to utilize CLI search tools like awk, sed and alike to find the paths satisfying specific matching rules.

The embedded search capability allows to perform a quick and simple search through the model's paths using simple inclusion/exclusion operators.

Flags#

types#

When --types flag is present the extracted paths will also have a corresponding type printed out.

path-type#

The --path-type flag governs which style is used to display the path information. The default value is xpath which will produce the XPATH compatible paths.

The other option is gnmi which will result in the paths to be formatted using the gNMI Path Conventions.

/state/sfm[sfm-slot=*]/hardware-data/firmware-revision-status
elem:{name:"state"}  elem:{name:"sfm"  key:{key:"sfm-slot"  value:"*"}}  elem:{name:"hardware-data"}  elem:{name:"firmware-revision-status"}

With the --search flag present an interactive CLI search dialog is displayed that allows to navigate through the paths list and perform a search.

❯ gnmic path --file _test/nokia-state-combined.yang --search
Use the arrow keys to navigate: ↓ ↑ → ←  and : toggles search
? select path: 
    /state/aaa/radius/statistics/coa/dropped/bad-authentication
    /state/aaa/radius/statistics/coa/dropped/missing-auth-policy
  ▸ /state/aaa/radius/statistics/coa/dropped/invalid
    /state/aaa/radius/statistics/coa/dropped/missing-resource
    /state/aaa/radius/statistics/coa/received
    /state/aaa/radius/statistics/coa/accepted
    /state/aaa/radius/statistics/coa/rejected
    /state/aaa/radius/statistics/disconnect-messages/dropped/bad-authentication
    /state/aaa/radius/statistics/disconnect-messages/dropped/missing-auth-policy
↓   /state/aaa/radius/statistics/disconnect-messages/dropped/invalid

descr#

When the --descr flag is present, the leaf description is printed after the path, indented with a \t.

config-only#

When the --config-only flag is present, paths are generated only for YANG leaves representing config data.

state-only#

When the --state-only flag is present, paths are generated only for YANG leaves representing state data.

with-non-leaves#

When the --with-non-leaves flag is present, paths are generated not only for YANG leaves.

Examples#

# output to stdout the XPATH styled paths
# from the nokia-state module of nokia-state-combined.yang file
gnmic path --file nokia-state-combined.yang

# from the nokia-conf module
gnmic path -m nokia-conf --file nokia-conf-combined.yang

# with the gNMI styled paths
gnmic path --file nokia-state-combined.yang --path-type gnmi

# with path types
gnmic path --file nokia-state-combined.yang --types

# entering the interactive navigation prompt
gnmic path --file nokia-state-combined.yang --search

  1. Nokia combined models can be found in nokia/7x50_YangModels repo.