2015-11-21 64 views
1

关于杨模型在这里没有太多的问题在stackoverflow,但我希望你能帮助我。Yang type not found

我创建了一个YANG模型,我想将其导入到另一个模块中。 import语句是这样的:

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; 
    } 
    } 
} 

当编译我得到的错误,说类型饱和:服务抽象类定义没有找到,我真的不明白这一点。任何想法??

感谢

+0

好吧,我想我想通了: 为了把引用作为一个类型的模块,你需要在该模块内创建一个typedef。我的情况就是这样。 – Ricardo

+0

你能告诉我我需要在我的ubuntu系统上安装哪些工具来编译和测试yang模块? –

回答

1

您通常使用在NETMOD杨1.0两个原因import语句:从另一个模块重用顶级的定义和注入定义从模块到另一个模块。

可以从YANG中的另一个模块导入五个顶级定义:分组,类型定义,扩展,功能和标识。在你的情况下,你试图导入一个不是其中之一的定义 - 一个YANG容器,它代表了一个数据定义语句(它们定义了可能被实例化的数据树和数据树)。其他数据定义语句为:叶,叶列表,列表,选择,大小写,扩充,使用和anyxml。

您不能导入数据定义语句以供在您的模块中使用,除非它们在分组内定义并使用uses语句引用。此外,叶子语句的类型子语句代表叶子实例的数据类型,它限制实例值的有效值集合(例如XML编码中的XML元素的文本节点的值集合)。叶子语句也不能成为其他数据定义语句的父母 - 这就是为什么他们被称为叶子(数据树分支以它们结束)的原因。

YANG中的术语type更像是编程语言中的数据类型,不应与其他定义结构的模式语言(复杂类型)中的某些术语混淆。就像你自己发现的一样,你可以使用typedef语句在YANG中定义自定义数据类型。