简体   繁体   English

未找到阳型

[英]Yang type not found

There is not too many questions about YANG models here in stackoverflow, but I hope you can help me out. 在stackoverflow中,关于YANG模型的问题没有太多,但是希望您能为我提供帮助。

I have created a YANG model and I want to import it into another module. 我已经创建了YANG模型,并将其导入到另一个模块中。 The import statement is like this: import语句是这样的:

import service-abstract-type-definition {
    prefix sfc-satd;
    revision-date 2015-11-15;
}

And the usage of it looks like this: 它的用法如下所示:

leaf abstract-type {
  type sfc-satd:service-abstract-type-definition;
  description
    "Abstract Type definition for the Service Function";
}

This leaf is inside a grouping. 此叶在分组内。

The imported module looks like this: 导入的模块如下所示:

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

When compiling I get the ERROR saying 编译时出现错误提示

type satd:service-abstract-type-definition is not found satd类型:未找到服务抽象类型定义

and I really don't get it. 我真的不明白。 Any idea? 任何想法?

Thanks 谢谢

You generally use import statements for two reasons in NETMOD YANG 1.0: reusing top-level definitions from another module and injecting definitions from your module into another module. 在NETMOD YANG 1.0中,通常使用import语句有两个原因:重用另一个模块中的顶级定义,以及将模块中的定义注入另一个模块中。

There are five top-level definitions that may be imported from another module in YANG: groupings, typedefs, extensions, features and identities. 可以从YANG的另一个模块中导入五个顶级定义:分组,typedef,扩展名,功能和标识。 In your case you were trying to import a definition that is not one of those - a YANG container, which represents one of the data definition statements (they define nodes that may be instantiated AKA the data tree). 在您的情况下,您尝试导入的定义不是其中之一-YANG容器,它代表数据定义语句之一(它们定义可以实例化为数据树的节点)。 The other data definition statements are: leaf, leaf-list, list, choice, case, augment, uses, and anyxml. 其他数据定义语句是:叶,叶列表,列表,选择,大小写,扩充,用途和anyxml。

You cannot import data definition statements for use in your module, unless they are defined within a grouping and referenced with the uses statement. 您不能导入数据定义语句以供在模块中使用,除非它们在分组中定义并由uses语句引用。 Furthermore, the leaf statement's type child statement represents the data type of a leaf instance, which restricts the set of valid values for the instance's value (the set of values for the text node of an XML element in XML encoding for example). 此外,叶子语句的类型子语句表示叶子实例的数据类型,它限制了实例值的有效值集(例如XML编码的XML元素的文本节点的值集)。 Leaf statements also cannot be parents to other data definition statements - that is why they are called leafs (a data tree branch ends with them). 叶子语句也不能成为其他数据定义语句的父对象,这就是为什么它们被称为叶子(数据树分支以它们结尾)的原因。

The term type in YANG is more like the data types in programming languages and should not be confused with certain terms from other schema languages (complex types), which define structure. YANG中的术语type更像编程语言中的数据类型,不应与其他定义结构的模式语言(复杂类型)中的某些术语相混淆。 Like you found out yourself, you may define custom data types in YANG by using the typedef statement. 就像发现自己一样,您可以使用typedef语句在YANG中定义自定义数据类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM