【问题标题】:Yang type not found未找到杨型
【发布时间】:2016-02-24 02:03:05
【问题描述】:

stackoverflow 中关于 YANG 模型的问题不多,但希望大家能帮帮我。

我创建了一个 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;
    }
  }
}

编译时出现错误提示

type satd:service-abstract-type-definition is not found

我真的不明白。有什么想法吗?

谢谢

【问题讨论】:

  • 好的,我想我想通了:为了将引用模块作为一种类型,您需要在该模块中创建一个 typedef。就我而言,这是缺失的。
  • 你能告诉我我需要在我的 ubuntu 系统上安装哪些工具来编译和测试 yang 模块吗?

标签: data-modeling ietf-netmod-yang


【解决方案1】:

在 NETMOD YANG 1.0 中,您通常使用 import 语句有两个原因:重用来自另一个模块的顶级定义和​​将定义从您的模块注入另一个模块。

可以从 YANG 中的另一个模块导入五个顶级定义:分组、类型定义、扩展、特性和标识。在您的情况下,您试图导入不是其中之一的定义 - 一个 YANG 容器,它表示数据定义语句之一(它们定义可能被实例化的节点 AKA 数据树)。其他数据定义语句有:leaf、leaf-list、list、choice、case、augment、uses和anyxml。

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多