07-29-2019 09:44 AM
I am looking over the guides and trying to find information on the correct way to use external yang files. For example, lets say I do not want to recreate ethernet-groupings for XE and just want to import Cisco's submodule
Cisco-IOS-XE-interfaces
and from there use the grouping
grouping ethernet-grouping
Would I just copying over the "Cisco-IOS-XE-interfaces" over to the "/opt/ncs/ncs-4.7.3.1/src/ncs/yang" folder that contains all the other default talif/ietf yang files and then import it into my yang?
module TESTPKG { namespace "http://example.com/TESTPKG"; prefix TESTPKG; import Cisco-IOS-XE-native { prefix xe; } }
Is this recommended our is a better method preferred over copying the source yang files? Or is it better to use the ios-ned and create choices/groupings similar to the accepted solution in this thread?
Thanks
Solved! Go to Solution.
07-29-2019 12:00 PM - edited 07-29-2019 12:01 PM
Hi,
You do not need to "copy and paste", you could simply write:
uses xe:ethernet-grouping
Now, this only works because ethernet-grouping is was originally grouped. What if it wasn't? Well, there is a YANG Schema Mount standard just out of the IETF (RFC 8528) but NSO only supports it for the NEDs but not for other packages.
07-29-2019 12:00 PM - edited 07-29-2019 12:01 PM
Hi,
You do not need to "copy and paste", you could simply write:
uses xe:ethernet-grouping
Now, this only works because ethernet-grouping is was originally grouped. What if it wasn't? Well, there is a YANG Schema Mount standard just out of the IETF (RFC 8528) but NSO only supports it for the NEDs but not for other packages.
07-29-2019 06:40 PM - edited 07-29-2019 06:42 PM
Just read over the Yang Schema mount rfc, looks very handy. Any plans to release it to more than NEDS?
Also, I must be missing something trivial on getting external yang files to work in my package. I created the following structure to test a custom yang file in the /opt/ncs/current/src/ncs/yang directory.
/opt/ncs/ncs-4.7.2/src/ncs/yang/ └── test-external-pkg.yang module test-external-pkg { namespace "http://example.com/test-external-pkg"; prefix tpext; }
When I run make on my test package src folder it comes back fine. When I went to reload NSO I got a namespace error. I tried adding it as a required-package in the package-meta-data.xml, thinking this is not the right approach but I find a similar error on this post so I tried it.
<ncs-package xmlns="http://tail-f.com/ns/ncs-packages"> <name>testpkg</name> <package-version>1.0</package-version> <description>Generated Python package</description> <ncs-min-version>4.7</ncs-min-version> <required-package> <name>test-external-pkg</name> </required-package> <component> <name>main</name> <application> <python-class-name>testpkg.main.Main</python-class-name> </application> </component> </ncs-package>
The reload gives the error that the package is undefined so I must be missing a piece since this isn't a package, only a single yang file.
Error: Failed to load NCS package: testpkg; required package test-external-pkg of version undefined is not present (found none)
07-29-2019 07:06 PM
07-29-2019 08:35 PM
I put my custom test-external-pkg.yang into the /opt/ncs/current/src/ncs/yang directory where all the other default yang files ( for example ietf-inet-types.yang)
Then ran the make command, it created my test-external-pkg.fxs inside of the /opt/ncs/current/src/ncs/yang.
After watching the debug logs of NSO trying to start I noticed that all the other default .fxs files were located in:
/opt/ncs/ncs-4.7.2/etc/ncs/
I manually moved my test-external-pkg.fxs to that above directory and it worked.
sudo mv /opt/ncs/current/src/ncs/yang/test-external-pkg.fxs /opt/ncs/ncs-4.7.2/etc/ncs/
Still looking for docs on the correct process of adding a custom yang then getting the .fxs to create in the proper load directory. Thinking something with the way I am running the make command.
Thanks
07-30-2019 06:11 AM
07-30-2019 08:15 AM
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