【问题标题】:how can i change a yang model into a xml or json file,when there is a union type element?当有联合类型元素时,如何将 yang 模型转换为 xml 或 json 文件?
【发布时间】:2019-12-13 01:35:48
【问题描述】:

''' 我想把一个yang模型改成xml,但是yang模型里面有union类型,odl检查xml有错误,不知道怎么解决 '''

''' 阳模部分

 leaf prefix {
       type leafref {
          path "../config/prefix";
       }
       description
       "Reference to the configured prefix for this aggregate";
  }

  typedef ip-prefix {
    type union {
      type ipv4-prefix;
      type ipv6-prefix;
    }
    description
      "An IPv4 or IPv6 prefix.";
  }

''' ''' xml部分

<prefix>10.0.0.0/24</prefix>

''' ''' 错误消息

<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
    <error>
        <error-type>protocol</error-type>
        <error-tag>malformed-message</error-tag>
        <error-message>Error parsing input: Invalid value ""10.0.0.0/24"" for union type.</error-message>
        <error-info>Invalid value ""10.0.0.0/24"" for union type.</error-info>
    </error>
</errors>

'''

【问题讨论】:

    标签: ietf-netmod-yang ietf-netconf


    【解决方案1】:

    这似乎与这是一个工会这一事实无关。 在这种情况下,前缀参数有几个规则:

    • 它是一个叶子引用,这意味着您提供的值 (10.0.0.0/24) 必须作为现有配置/前缀存在。
    • 该值还需要与 ipv4-prefix 或 ipv6-prefix 匹配。其中每一个都是具有特定正则表达式的字符串。 对于这种特殊情况,您提供的值看起来像是一个有效的 ipv4 前缀。

    简而言之,该错误很可能与未遵循 Leafref 约束有关。 我需要查看发送的实际 XML 才能知道错误的根本原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-10
      • 1970-01-01
      • 2020-04-02
      • 2023-04-10
      • 2019-01-29
      • 1970-01-01
      • 2012-06-17
      • 2018-10-26
      相关资源
      最近更新 更多