cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
199
Views
15
Helpful
6
Replies
Beginner

Recommended way to import external yang

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

1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: Recommended way to import external yang

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.

6 REPLIES 6
Cisco Employee

Re: Recommended way to import external yang

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.

Highlighted
Beginner

Re: Recommended way to import external yang

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)

 

 

 

Cisco Employee

Re: Recommended way to import external yang

Have you added to the yang path in the makefile? So that it can reach all the files.
Beginner

Re: Recommended way to import external yang

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

Beginner

Re: Recommended way to import external yang

Looks like you can add dirs as load paths in nso.conf. I think my process now is to create yangs, run make command to get the .fxs and move it to the load directory specified in ncs.conf

<load-path>
<dir>./packages</dir>
<dir>${NCS_DIR}/etc/ncs</dir>

<!-- To disable northbound snmp altogether -->
<!-- comment out the path below -->
<dir>${NCS_DIR}/etc/ncs/snmp</dir>
</load-path>
Cisco Employee

Re: Recommended way to import external yang

In your Makefile for your package, you can update the YANGPATH to include the path to the yang files you need.

In each package there is a load-dir where fxs files are loaded. The default makefile for a package places the fxs files there.