Comments (8)
@shlomiassaf - thanks for the details, it really helps.
I think the issue may be with how yang-js
is handling extensions from an included submodule. Looks like a bug. Let me try to reproduce and will let you know what I find.
Thanks!
from yang-js.
@shlomiassaf - thanks for flagging this issue!
So after digging into it, I found that it was a rather nasty state bleed-over issue with how I was treating the argument
sub-statement. The fix itself was fairly minor but I've committed the change along with something else I was working on so it may be less obvious based on the changeset.
You can try the fix now from the master branch. I'll probably publish a new 'yang-js' package later today so you can try that as well.
from yang-js.
Enabled extension attachment via .bind() in 731ff72
from yang-js.
@saintkepha I'm unable to import and parse.
I get this error: encountered unknown extension 'tailf:my-extension'
I'v imported the file declaring the extension (with the same prefix)
I believe it's related to this issue, can you provide an example how to use the .bind() method to attach extensions?
Thanks!
from yang-js.
Hi @shlomiassaf - I don't think the issue you're encountering is related to the ability to provide custom extension handling capability described in this ticket.
Take a look at the test case for using imported custom extension definition: https://github.com/corenova/yang-js/blob/master/test/extension/extension.coffee#L36
The error of encountered unknown extension
usually means that it was unable to resolve the extension my-extension
statement within the imported module prefix with tailf
. I would check to make sure that the module that contains the extension my-extension
statement is being properly imported by the module that is trying to use it.
The .bind() method as enhanced by this ticket enables custom compile logic to be used for implementing the extension and is not affected during parse
operation itself.
Also, for more extensive diagnostics, you can always run with DEBUG=yang:* as the environmental variable.
from yang-js.
@saintkepha Thanks for the quick response, the imports are there, here's a simplified exapmle:
FILE: module-ext-demo.yang
submodule module-ext-demo {
belongs-to module-demo {
prefix mdemo;
}
extension arg-type {
description
"Specifies the type of the argument.";
}
}
FILE: module-demo.yang
module module-demo {
prefix mdemo;
include module-ext-demo {
}
extension info {
argument text {
mdemo:arg-type {
type string;
}
}
description "info";
}
}
FILE: model-demo.yang
module model-demo {
namespace "http://tail-f.com/ned/cisco-nx";
prefix nx;
import module-demo {
prefix mdemo;
}
typedef test {
type union {
type uint32 {
mdemo:info "SomeInfo";
}
type enumeration {
enum auto {
mdemo:info "More Info"";
}
}
}
}
}
I run this code:
Yang.import('./module-demo.yang');
Yang.parse(fs.readFileSync('./model-demo.yang');
It fails on the 1st line:
ExpressionError: [module(module-demo)/extension(info)/argument(text)/mdemo:arg-type] encountered unknown extension 'mdemo:arg-type'
at Yang.Element.error (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/element.js:64:13)
at Yang.Expression.error (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/expression.js:191:40)
at Yang.error (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/yang.js:313:35)
at Yang.<anonymous> (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/yang.js:277:24)
at EventEmitter.g (events.js:291:16)
at emitOne (events.js:96:13)
at EventEmitter.emit (events.js:188:7)
at Yang.emit (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/yang.js:319:33)
at Yang.Expression.compile (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/expression.js:67:12)
at /Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/expression.js:80:18
DEBUG log:
yang:schema [match] with extension mdemo:arg-type +0ms
yang:schema [match] check if current module's prefix +3ms
yang:schema [match] checking if submodule's parent +1ms
yang:schema [match] check if one of current module's imports +0ms
yang:expression [module(module-demo)] compile enter... (undefined) +3ms
yang:element [module(module-demo)] found 1 new extension(s) +1ms
yang:expression [module(module-demo)/prefix] compile enter... (undefined) +0ms
yang:expression [module(module-demo)/prefix] compile: ok +0ms
yang:expression [module(module-demo)/include(module-ext-demo)] compile enter... (undefined) +0ms
yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/yang-demo/package.json +1ms
yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/package.json +0ms
yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/package.json +1ms
yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/Cisco/cisco/package.json +0ms
yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/Cisco/package.json +0ms
yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/package.json +0ms
yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/package.json +0ms
yang:schema [resolve] module-ext-demo in /Users/package.json +0ms
yang:schema [resolve] checking if /Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/yang-demo/module-ext-demo.yang exists +0ms
yang:schema retrying import(./module-demo.yang) +3ms
yang:schema [match] with extension mdemo:arg-type +2ms
yang:schema [match] check if current module's prefix +0ms
yang:schema [match] checking if submodule's parent +0ms
yang:schema [match] check if one of current module's imports +0ms
yang:expression [module(module-demo)] compile enter... (undefined) +0ms
yang:element [module(module-demo)] found 1 new extension(s) +1ms
yang:expression [module(module-demo)/prefix] compile enter... (undefined) +0ms
yang:expression [module(module-demo)/prefix] compile: ok +0ms
yang:expression [module(module-demo)/include(module-ext-demo)] compile enter... (undefined) +0ms
yang:expression [submodule(module-ext-demo)] compile enter... (undefined) +0ms
yang:expression [submodule(module-ext-demo)/belongs-to(module-demo)] compile enter... (undefined) +0ms
yang:expression [submodule(module-ext-demo)/belongs-to(module-demo)/prefix] compile enter... (undefined) +1ms
yang:expression [submodule(module-ext-demo)/belongs-to(module-demo)/prefix] compile: ok +0ms
yang:expression [submodule(module-ext-demo)/belongs-to(module-demo)] compile: ok +0ms
yang:expression [submodule(module-ext-demo)/extension(arg-type)] compile enter... (undefined) +0ms
yang:expression [submodule(module-ext-demo)/extension(arg-type)/description] compile enter... (undefined) +1ms
yang:expression [submodule(module-ext-demo)/extension(arg-type)/description] compile: ok +0ms
yang:expression [module(module-demo)/extension(info)/argument(text)] compile enter... (undefined) +0ms
yang:expression [module(module-demo)/extension(info)/argument(text)/mdemo:arg-type] compile enter... (undefined) +0ms
yang:schema [match] with extension mdemo:arg-type +0ms
yang:schema [match] check if current module's prefix +0ms
yang:schema [match] with extension mdemo:arg-type +1ms
yang:schema [match] check if current module's prefix +0ms
yang:schema [match] with extension mdemo:arg-type +0ms
yang:schema [match] check if current module's prefix +0ms
yang:schema [match] with extension mdemo:arg-type +0ms
yang:schema [match] check if current module's prefix +0ms
from yang-js.
Thank you for the hard work!
from yang-js.
Thanks!
from yang-js.
Related Issues (20)
- Unable to build:web HOT 3
- Update documentation using ES6 syntax HOT 1
- [Question] Working with Multiple Schemas HOT 1
- yang extension field compilation error HOT 2
- Improve Yang.import to support directory search and extension order
- validation of Read-only data HOT 2
- Validation errors should show "path" to failure and/or name of failing portion. HOT 2
- Mandatory Fields in Read Only Data HOT 1
- Not working on Windows platform? HOT 2
- Schema extension does not work as described in the TUTORIAL.md HOT 2
- Unable to import ietf-ip.yang HOT 2
- Unable to import ietf-netconf-monitoring.yang
- Unable to import o-ran-compression-factors.yang HOT 3
- MaxListenersExceededWarning: Possible EventEmitter memory leak detected.
- Issue with importing Yang file with Extensions HOT 1
- when parse the file '[email protected]' with yang-js, there is 'unable to locate' error HOT 1
- is this plan supportting RFC 7950?
- Error happened during using yang-js in browser
- i'm trying to parse the yang file but it not import the file why ?
- when i'm parsing file it getting error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yang-js.