Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leafref broken for cross module leaf references ? #31

Closed
ramukima opened this issue Aug 23, 2016 · 5 comments
Closed

leafref broken for cross module leaf references ? #31

ramukima opened this issue Aug 23, 2016 · 5 comments
Assignees
Milestone

Comments

@ramukima
Copy link
Contributor

I have following models:

foo.yang

module foo {
  prefix foo;
  list foo {
   leaf name {
      type string;
   }
}

bar.yang

module bar {
  prefix bar;
  import foo { prefix f; }

  leaf bar {
    type leafref { path "/f:foo/f:name"; }
  }
}

When I create an instance of foo (under yang-express using published URLs), and then try to create a bar instance supplying correct value of bar leafref, I always see error regarding unable to resolve the leafref.

@sekur
Copy link
Collaborator

sekur commented Aug 23, 2016

Hi Amit, I actually don't think that is valid YANG schema? From the context of the module bar, it can use module foo's exported grouping, typedef, etc. it can also augment the foo module. But I don't think it can access data tree elements from module foo.

At least that's how I understood the spec. If there's public examples of how this should be possible, please share the reference.

@sekur
Copy link
Collaborator

sekur commented Aug 23, 2016

Sorry, you're right! I didn't realize you should be allowed to go outside your current module for leafref! Ok will need to fix. :-)

   The accessible tree depends on the context node:

   o  If the context node represents configuration data, the tree is the
      data in the NETCONF datastore where the context node exists.  The
      XPath root node has all top-level configuration data nodes in all
      modules as children.

   o  Otherwise, the tree is all state data on the device, and the
      <running/> datastore.  The XPath root node has all top-level data
      nodes in all modules as children.

@sekur sekur self-assigned this Aug 24, 2016
@sekur sekur added this to the 0.15 milestone Aug 24, 2016
@sekur sekur mentioned this issue Aug 24, 2016
sekur added a commit that referenced this issue Aug 26, 2016
… event subscription propagation from Model to Store. addresses edge case issues regarding #33. the new Store should resolve cross module leaf references (see #31).
@sekur
Copy link
Collaborator

sekur commented Aug 26, 2016

This should be addressed but I haven't verified.

Here's an example of how to test:

Yang = require 'yang-js'
store = new Yang.Store 'test'
store.import <schema or model>
store.import <schema or model>
console.log store.data.valueOf()

Basically, you can import YANG schema text or Yang expression instance or a Model and it will link all the top-level properties at the store.data property. This will make it possible for XPATH resolution for leafref/path to traverse across module boundaries.

It'd be great if you can give it a try with the latest yang-js published version (0.15.23).

@sekur
Copy link
Collaborator

sekur commented Aug 26, 2016

@ramukima - were you able to confirm/verify the cross-module leafref functionality?

@ramukima
Copy link
Contributor Author

I tested it with petstore example and I could see it work. But I am yet to validate multiple scenarios. Closing for now, will reopen if I find it broken again later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants