2015-11-21 67 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中定義自定義數據類型。