-
Notifications
You must be signed in to change notification settings - Fork 18
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
enable() of Model instance is not working #52
Comments
I think you meant The way the You can bind during var Yang = require('yang-js');
var schema = Yang("module ...", {
'feature(my_feature)': => { this.content = { ...yourFeature }; }
}); You can bind after parsing as follows: var Yang = require('yang-js');
var schema = Yang("module ...");
schema.bind({
'feature(my_feature)': => { this.content = { ...yourFeature }; }
}); You can also specify the feature during x.enable("my_feature", ...yourFeature); Hope this helps. |
BTW, the difference between binding to a schema vs. assigning during |
Thanks for your clear explanation! Yes, I meant x.enable("my_feature") ! So, is the function bound to the feature like a switch of it? |
The key idea here is that you actually bind the implementation of that feature to become accessible from the schema. It's a bit beyond simple The feature is considered available if there is a Now, when you enable a feature, it attempts to retrieve that feature module (either from the binding or via explicit assignment) and attach that feature into the internal You can also take a look at the yang-express module and see how the |
Thank you! This is really a great help! |
@vcshox - sure thing. The feature handling subsystem is a bit experimental and not very well documented so give it a whirl and let me know if any ideas pop up on how we can improve it. |
@saintkepha module example-sports {
namespace "http://example.com/example";
prefix example;
feature my_feature1 {
description "my feature1";
}
feature my_feature2 {
description "my feature2";
}
container feature-test {
if-feature "my_feature1 and my_feature2";
leaf a-leaf {
type string;
}
}
} Both But after eval, the container |
Allowing boolean conditionals in You will need to use multiple
Would be happy to receive a PR to enable this, if interested, take a look at https://github.com/corenova/yang-js/blob/master/src/lang/extensions.coffee#L401 Inside the Should comply with the RFC: https://tools.ietf.org/html/rfc7950#section-7.20.2 |
OK, I will try. But I am not that familiar with the |
I have a yang file with feature statement for example:
When I eval the schema with the data:
a model instance (ex:x) is generated.
I called x.enable("my_feature") and got the following error:
PropertyError: [/example-sports] unable to enable unknown feature 'my_feature'
Is there a any bug or I misunderstand the function?
The text was updated successfully, but these errors were encountered: