NETCONF中的include和import语句(.Yin/Yang文件)有什么区别 [英] What's the difference between the include and import statement in NETCONF (.Yin/Yang files)

查看:617
本文介绍了NETCONF中的include和import语句(.Yin/Yang文件)有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解您可以创建一个单独的yang文件(类似于文本约定,用于存储MIBS的语法值),然后将其导入另一个yang文件中,以使数据更加有条理和结构化,但是我似乎无法理解包含语句有何不同之处?

I understand that you can create a separate yang file (Something like a textual Convention to store syntax values for MIBS)and import it into another yang file to make the data more organised and structured, but I can't seem to understand what the include statement does differently?

它是否将整个文件导入"到包含该文件的文件中?如果是这样,会在包含该文件的文件之前读取它吗??

Does it "import" the entire file into the file that's including it - and if so would this be read before the file including it...?

请帮助:)

推荐答案

YANG在很大程度上依赖于称为命名空间"的概念,该概念源自XML命名约定.每个名称空间都有一个唯一的资源标识符,并允许定义(在不同的名称空间中)在相同的定义级别具有相同的名称,同时避免名称冲突.定义YANG模块时,实际上是在定义名称空间.

YANG relies heavily on a concept known as "namespaces", which stems from XML naming conventions. Each namespace has a unique resource identifier and allows definitions (in different namespaces) to have same names at same definition levels while avoiding name clashes. When you define a YANG module, you are actually defining a namespace.

import语句用于从外部名称空间(另一个模块)访问定义,而include语句引入了一种机制,该机制允许将单个名称空间(单个模块)从逻辑上拆分为多个文件,方便地命名为modulesubmodules.对于include,总是只有一个模块文件,其中包括属于它的所有 all 子模块文件.子模块只能属于一个模块,而不能(直接)导入.对于导入模块,包含子模块的模块看起来像单个实体.子模块可以互相包含,但是在YANG 1.1版中,这变得不必要了,因为子模块可以立即访问所有子模块及其所属模块中的所有定义.在YANG版本1中,您必须显式包含一个子模块才能在另一个子模块中使用它的定义,而 never 则不能访问它们所属模块中的定义.

An import statement is used to access definitions from a foreign namespace (another module), while an include statement introduces a mechanism that allows a single namespace (single module) to be logically split into several files, conveniently named module and submodules. For includes, there is always exactly one module file, which includes all submodule files that belong to it. A submodule may only belong to a single module and may not be imported (directly). To an importing module, a module that includes submodules, looks like a single entity. Submodules may include eachother, but with YANG version 1.1, this has become unnecessary, since a submodule immediately gains access to all definitions in all submodules and the module they all belong to. In YANG version 1 you had to explicitly include a submodule to use definitions from it in another submodule, while never being able to access definitions in the module to which they belonged.

import不会将定义内联"到导入模块中,而include确实可以做到这一点.导入模块使您可以访问其顶级定义(typedef,分组,标识,特征和扩展),并允许您使用架构节点标识符来标识导入模块中的节点(例如,出于扩充和偏离的目的)

An import does not "inline" definitions into the importing module, while an include does exactly that. Importing a module gives you access to its top-level definitions (typedefs, groupings, idenitites, features and extensions) and allows you to use schema node identifiers that identify nodes in the imported module (for the purpose of augmentation and deviation, for example).

总是通过prefix访问外部命名空间中的定义,而prefiximport语句定义的一部分.来自include的定义在使用时不需要加上前缀,如果是,则以include模块(或子模块)的前缀为前缀.

Definitions from a foreign namespace are always accessed via a prefix, which are part of an import statement's definition. Definitions that come from includes do not need to be prefixed when used, and if they are, are prefixed with the including module's (or submodule's) prefix.

YANG编译器"通常在命中importinclude语句时处理这些文件.他们需要处理它们,以便能够解析定义模块的主体语句中的定义.这就是为什么要求这些语句出现在模块的标题部分的原因.

YANG "compilers" usually process these files when they hit either an import or an include statement. They need to process them in order to be able to resolve definitions in body statements of the defining module. That is why these statements are required to appear in a module's header section.

YANG规范中有一个整个章节专门用于模块和子模块,您可以在此处阅读有关该主题的更多信息.

There is an entire section in YANG specification dedicated to modules and submodules, where you can read more on the topic.

这篇关于NETCONF中的include和import语句(.Yin/Yang文件)有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆