这里没有太多关于杨模特的问题,但是我希望你能帮我解决问题。
我已经创建了一个YANG模型,我想将它导入到另一个模块中。导入语句如下所示:
import service-abstract-type-definition {
prefix sfc-satd;
revision-date 2015-11-15;
}它的用法如下:
leaf abstract-type {
type sfc-satd:service-abstract-type-definition;
description
"Abstract Type definition for the Service Function";
}这片叶子在一个分组内。
导入的模块如下所示:
module service-abstract-type-definition {
namespace "urn:odl:params:xml:ns:yang:sfc-satd";
prefix sfc-satd;
import service-locator {
prefix sfc-sl;
revision-date 2014-07-01;
}
description
"This module contains YANG definitions for managing Service Abstract Type Definition";
revision 2015-11-15 {
description
"First version of Service Abstract Type Definition.";
}
// Service Function
// Service Abstract Type definitions
container service-abstract-type-definition {
description
"List of parameters to define an abstract type of Service Function";
leaf name {
type string;
description "Service Function type names such as firewall, dpi, tcp-proxy, etc";
}
leaf symmetry {
type boolean;
description "SF is involved in a symmetric service path";
}
leaf bidirectionality {
type boolean;
description "SF handles uplink and downlink traffic";
}
leaf nsh-aware {
type boolean;
description "Service Function can handle Network Service Headers";
}
container dpl {
description "Data Plane Locators from the Service Function";
uses sfc-sl:data-plane-locator;
}
}
}编译时,我会看到错误的说法:
类型satd:找不到服务抽象类型定义
我真的不明白。有什么想法吗?
谢谢
发布于 2015-11-25 08:54:19
在NETMOD 1.0中,使用导入语句通常有两个原因:重用来自另一个模块的顶级定义和将模块中的定义注入到另一个模块。
有五个顶级定义可以从YANG中的另一个模块导入:分组、类型防御、扩展、特性和标识。在您的示例中,您试图导入一个不是这样的定义-- YANG容器,它表示数据定义语句之一(它们定义的节点可能被实例化为AKA数据树)。其他数据定义语句有:叶子、叶列表、列表、选择、大小写、扩展、使用和anyxml。
不能导入数据定义语句以供在模块中使用,除非这些语句是在分组内定义的,并与uses语句引用。此外,叶语句的类型子语句表示叶实例的数据类型,它限制实例值的有效值集(例如XML编码中XML元素的文本节点的值集)。叶子语句也不能是其他数据定义语句的父级语句--这就是为什么它们被称为leafs (数据树分支以它们结尾)的原因。
杨中的术语type更像编程语言中的数据类型,不应与定义结构的其他模式语言(复杂类型)中的某些术语混淆。就像您自己发现的那样,您可以使用typedef语句在YANG中定义自定义数据类型。
https://stackoverflow.com/questions/33846074
复制相似问题