ConfD User Community

What is different of include and import?


#1

At RFC6020, include and import is different.
However, i can’t understand the difference between the two.

Would you explain it and give me some examples?

thanks you.


#2

Both the YANG 1.0 and 1.1 RFCs provide an include/import example.

From the YANG 1.1 RFC, the include/import example:
https://tools.ietf.org/html/rfc7950#section-7.1.10
The included submodule:
https://tools.ietf.org/html/rfc7950#section-7.2.3
The imported ietf-yang-types YANG module:
https://tools.ietf.org/html/rfc6991#section-3

One clarification in addition to the YANG RFC 7950 description that may be helpful is that “include” is just a way to structure a YANG module where the submodule(s) will belong to the same namespace.

When you import, you are making definitions from another YANG module with a different namespace available for use with a prefix in front of the definition.

If your definition is defined in the same namespace but in a YANG submodule that belongs-to the YANG module that include it, a prefix is obviously not needed.

If you prefer a ConfD example, see for example:
examples.confd/linuxcfg/ietf_routing/ietf-ipv6-unicast-routing.yang that include the ietf-ipv6-router-advertisements.yang submodule.