[MDSAL-102] YANG 'default' statements is not being enforced Created: 16/Sep/15  Updated: 09/Mar/18  Resolved: 17/Nov/15

Status: Resolved
Project: mdsal
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: Jan Medved Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All



 Description   

These statements need to be enforced.



 Comments   
Comment by Robert Varga [ 24/Sep/15 ]

I split off BUG-4355 to track mandatory statement enforcement.

https://tools.ietf.org/html/rfc6020#section-7.6.4 does not define any enforcement rules. There is a definition of system behavior in https://tools.ietf.org/html/rfc6020#section-7.6.1, but that behavior can be realized in multiple ways, which achieve slightly different results.

One would be instantiating nodes as they are written into the data store, but that has the unfortunate effect of those nodes being actually there – e.g. RESTCONF would see those nodes present even when they have not been actually provisioned.

Another approach would be to instantiate default-valued nodes when they are explictly queried for via NormalizedNodeContainer.getChild(), but not through NormalizedNodeContainer.getValue().iterator(), but that would require normalized nodes to have the underlying SchemaNode available or carry an optional map of default values.

Yet another approach would be realized when the nodes is accessed in the context of a Data Tree instance via DataTreeSnapshot.read() or within implementation internal access (such as 'when' statement enforcement).

If this functionality is needed only in the BA world, this behavior can be implemented in generated code without affecting BI at all.

Comment by Jan Medved [ 26/Sep/15 ]

A default statement determines a value that should be filled into an optional attribute if the user does not specify the attribute. (Note that default does not make a lot of sense for mandatory attributes, but we're not enforcing those either - so by implementing 'default' we need to implement 'mandatory' as well)

This allows simplified processing, because the implementor can assume that the attribute is never null and/or does not have to write code to fill the default value.

Comment by Robert Varga [ 01/Oct/15 ]

The best option here would be change the behavior of LazyDataObject to return default value when asked for it.

This will result in any data reported to Binding Aware users as being set to the default value, while not storing it in the Binding Independent part of the world.

This behavior should be OK for BI users, as they usually have access to SchemaContext, where they acquire the default value (just as LazyDataObject, which is a BI component).

Comment by Robert Varga [ 10/Oct/15 ]

https://git.opendaylight.org/gerrit/28251

Generated at Wed Feb 07 20:08:38 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.