CZ-NIC / yangson

GNU Lesser General Public License v3.0
53 stars 20 forks source link

yangson.exceptions.InvalidLeafrefPath: etsi-nfv-descriptors:cpd (Question) #101

Closed JHolcman-T closed 3 years ago

JHolcman-T commented 3 years ago

Hello there. I don't know if this is an issue but I always get this exception: "yangson.exceptions.InvalidLeafrefPath: etsi-nfv-descriptors:cpd" when I try to build up the DataModel of these modules: etsi-nfv-"name". Could you please verify this?

Hint: Leaf that produces this error is in etsi-nfv-vnf.yang at line 1477-1482.

          leaf cpd {
            type leafref {
              path "deref(../vdu-id)/../int-cpd/id";
            }
          }

How my python code looks like:

from json_builder import builder
from json_builder.builder import *
import os

module_path = "/home/jakub/PycharmProjects/yangdiff/src/yang/SOL006-master/src/yang/etsi-nfv-descriptors.yang"

import_paths = "/home/jakub/PycharmProjects/yangdiff/src/yang/5.3.0:" \
               "/home/jakub/PycharmProjects/yangdiff/src/yang/SOL006-master/src/yang"

paths = ["/home/jakub/PycharmProjects/yangdiff/src/yang/5.3.0",
         "/home/jakub/PycharmProjects/yangdiff/src/yang/SOL006-master/src/yang"]

b = builder.Build(module_path, import_paths)

paths.insert(0, os.path.dirname(module_path))

dm = DataModel.from_file(b.json_file.name, tuple(paths))

print(b.json_file.read())

print(dm.ascii_tree())

JSON modules-state:

{
  "ietf-yang-library:modules-state": {
    "module-set-id": "0",
    "module": [
      {
        "name": "ietf-yang-types",
        "namespace": "urn:ietf:params:xml:ns:yang:ietf-yang-types",
        "revision": "",
        "conformance-type": "implement"
      },
      {
        "name": "ietf-inet-types",
        "namespace": "urn:ietf:params:xml:ns:yang:ietf-inet-types",
        "revision": "",
        "conformance-type": "implement"
      },
      {
        "name": "etsi-nfv-descriptors",
        "namespace": "urn:etsi:nfv:yang:etsi-nfv-descriptors",
        "revision": "",
        "conformance-type": "implement",
        "submodule": [
          {
            "name": "etsi-nfv-common",
            "revision": ""
          },
          {
            "name": "etsi-nfv-vnf",
            "revision": ""
          },
          {
            "name": "etsi-nfv-pnf",
            "revision": ""
          },
          {
            "name": "etsi-nfv-ns",
            "revision": ""
          }
        ]
      }
    ]
  }
}
llhotka commented 3 years ago

XPath functions are not permitted in the argument of path. See sec. 9.9.2 in RFC 7950.

JHolcman-T commented 3 years ago

XPath functions are not permitted in the argument of path. See sec. 9.9.2 in RFC 7950.

Hmm.. I see it's not defined, what also means it is not illeagal to use it. I found someting interesting on tailf page (page 7-8): Deref

llhotka commented 3 years ago

It is defined quite clearly in the ABNF grammar for YANG 1.1, see the production for path-arg and following.

I don't know why tail-f has that false information in their whitepaper, I assume it is their proprietary YANG extension, and they should say so.