You may import other modules in your own modules by using the import
statement. It is described in both RFC 7950 for YANG 1.1 and in RFC 6020 for YANG 1.0. In YANG 1.1 you may import two different revisions of the same module. Other that that, the import
statement works the same in both versions.
In practice the basic import looks like this:
module acme-system {
namespace "http://acme.example.com/system";
prefix "acme";
import ietf-yang-types {
prefix "yang";
revision-date 2013-07-15;
}
leaf acme-ip-address {
type yang:dotted-quad;
}
}
If you omit the optional revision-date
statement then an undefined module revision is imported. So, in general, it is a good practive to use it.
The mandatory prefix
statement lets you to refer to the things in the imported module. In the example the prefix of the imported ietf-yang-types
module is yang
and, thanks to that, it is clear that yang:dotted-quad
refers to a type from that module. In your case you have set the prefix to ospf
, so you should have ospf:area-id-type
to refer to a type definition from that module. If you import multiple modules you need to ensure their prefixes are unique.
Additionally, you are importing the oldest available revision of the ietf-ospf
module. I just hope that this is what you really want to do.
Anyway, once you import a module you are allowed to:
use any grouping
and typedef
defined at the top level in the imported module or its submodules.
use any extension
, feature
, and identity
defined in the imported module or its submodules.
use any node in the imported module's schema tree in must
, path
, and when
statements, or as the target node in augment
and deviation
statements.
In the above example the typedef dotted-quad
from the ietf-yang-types
is used in the acme-system
module.