06-27-2019 05:00 AM - edited 06-27-2019 05:01 AM
If I try to validate with pyang my YANG-model with imported submodules, I need to specify the path to the external submodules.
For the built-in yang-models, like ietf-inet-types, I don't need to specify the path.
But the man-page of pyang describes following:
See http://www.yang-central.org/twiki/pub/Main/YangTools/pyang.1.html
The following directories are always added to the search path:
current directory
$YANG_MODPATH
$HOME/yang/modules
$YANG_INSTALL/yang/modules OR if $YANG_INSTALL is unset <the default installation directory>/yang/modules (on Unix systems: /usr/share/yang/modules)
module my-module { namespace "http://test.com/my-module"; prefix mymodule; import ietf-inet-types { prefix inet; } import tailf-common { prefix tailf; } import tailf-ncs { prefix ncs; } import private-module { prefix private; } //yang code ... }
[root@c945565b350c yang]# pyang my-module.yang my-module.yang:15: error: module "private-module" not found in search path [root@c945565b350c yang]#
So, the default path for the built-in yang modules is /ncs/src/yang/.
Does NSO exposed the path to the built-in yang modules to pyang?
Thanks
Solved! Go to Solution.
06-27-2019 05:37 AM
Hello,
It depends what pyang you are using. If you type which pyang and it returns you some bin in $NCS_DIR/bin/pyang then this is a script which wraps pyang contained inside NSO and will set/add to the following env variables (snippet):
13 pyang=$ncsdir/lib/pyang/bin/pyang 14 15 if [ "x${PYTHONPATH}" != "x" ]; then 16 PYTHONPATH=$ncsdir/lib/pyang:$PYTHONPATH 17 else 18 PYTHONPATH=$ncsdir/lib/pyang 19 fi 20 if [ "x${YANG_MODPATH}" != "x" ]; then 21 YANG_MODPATH=$ncsdir/src/ncs/yang:$YANG_MODPATH 22 else 23 YANG_MODPATH=$ncsdir/src/ncs/yang 24 fi 25 export PYTHONPATH YANG_MODPATH 26 27 exec $pyang "$@"
So it is setting the YANG_MODPATH variable to a folder where the built-in module resides and according to the man page they will be used. So the answer is "yes, the wrapper script `pyang` in NSO is exposing the built-in modules"
Regards,
--
Guillaume
06-27-2019 05:37 AM
Hello,
It depends what pyang you are using. If you type which pyang and it returns you some bin in $NCS_DIR/bin/pyang then this is a script which wraps pyang contained inside NSO and will set/add to the following env variables (snippet):
13 pyang=$ncsdir/lib/pyang/bin/pyang 14 15 if [ "x${PYTHONPATH}" != "x" ]; then 16 PYTHONPATH=$ncsdir/lib/pyang:$PYTHONPATH 17 else 18 PYTHONPATH=$ncsdir/lib/pyang 19 fi 20 if [ "x${YANG_MODPATH}" != "x" ]; then 21 YANG_MODPATH=$ncsdir/src/ncs/yang:$YANG_MODPATH 22 else 23 YANG_MODPATH=$ncsdir/src/ncs/yang 24 fi 25 export PYTHONPATH YANG_MODPATH 26 27 exec $pyang "$@"
So it is setting the YANG_MODPATH variable to a folder where the built-in module resides and according to the man page they will be used. So the answer is "yes, the wrapper script `pyang` in NSO is exposing the built-in modules"
Regards,
--
Guillaume
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