I am trying to parse the given yang file and print all the leafs with their datatypes. Incase if the datatype is a derived datatype like – “oc-inet:domain-name”, I would like to look recursively into imported yang files and print the final base datatype of this derived datatype which is defined as
typedef domain-name {
type string {
length "1..253";
pattern
'(((([a-zA-Z0-9_]([a-zA-Z0-9-_]){0,61})?[a-zA-Z0-9].)*' +
'([a-zA-Z0-9_]([a-zA-Z0-9-_]){0,61})?[a-zA-Z0-9].?)' +
'|.)';
oc-ext:posix-pattern
'^(((([a-zA-Z0-9_]([a-zA-Z0-9-_]){0,61})?[a-zA-Z0-9].)*' +
'([a-zA-Z0-9_]([a-zA-Z0-9-_]){0,61})?[a-zA-Z0-9].?)' +
'|.)$';
}
In some cases, even these typedefs contains leafrefs like
typedef network-instance-ref {
type leafref {
path "/oc-netinst:network-instances/oc-netinst:network-instance/" +
"oc-netinst:config/oc-netinst:name";
}
description
"A re-usable type that can be referenced within other
modules that references a network instance.";
}
Tried Pyang and some plugins etc, but couldnt achieve. I am sure this must have been already solved and some parsers are existing already. Can someone pls point me to tools/parsers that can achieve this?
Even in this link – https://openconfig.net/projects/models/schemadocs/jstree/openconfig-system.html, when i hover the mouse pointer over the derived datatype, it shows the base datatype.