-
Notifications
You must be signed in to change notification settings - Fork 301
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
Invalid parser for YANG enumeration type #1415
Comments
Looking a bit at the code it seems to me that the semantics of
The value from the configuration is then used as a key into this array, which is completely bogus. What should happen is that the missing values are assigned according to 9.6.4.2 of RFC6020 (in this example they are set explicitely but that's optional) and the value from the configuration needs to be compared with the |
Good investigation. Definitely this is a bug, |
I have implemented this here https://github.com/alexandergall/snabbswitch/tree/yang-enumeration. I tried to guess where the code should go :) Can you please have a look (I'm also unsure about the style of error messages this should generate)? I'm not sure whether it's actually useful to set the numeric value in the final Lua table or the name of the selected
This seems more useful since otherwise the Lua code processing this table needs to define the same name-to-value mapping as the schema. |
Implement semantics according to RFC6020, 9.6. When validating a configuration against a schema which contains leaf foo { type enumeratoion { enum bar; enum baz; } } the resulting Lua table will contain the key "foo" whose value is the string of the chosen enum in the configuration, e.g. { foo = "baz" } It is debatable whether this should actually result in the numerical value assigned to the name in the schema.
Proposed fix: #1416 |
Consider the schema
In my understanding, the following should be a valid configuration
and the parser should produce the Lua table
Instead, I get an error
The error originates from
lib.yang.data
The
enums
table is keyed by the enumeration values, rather than the names of theenum
objects. This seems backwards to me unless I completely misunderstand the semantics ofenumeration
.The text was updated successfully, but these errors were encountered: