netmod-wg/yang-next

Support for conditional default values

Reshad-Rahman opened this issue · 4 comments

My suggestion was for the use-case where the default values are static.

typedef def100 {
    type int32;
    default 100;
}


typedef def1000 {
    type int32;
    default 1000;
}

typedef defleaf {
    type union {
        type def100;
        type def1000;
    }
 }

Then a server can set the YANG default to 100 or 1000.
The client needs to use with-defaults=report-all to see what the server picked

I think a optional default value or dynamic default value, and even fixed default value are all data generated by system. Maybe we should provide a rule to describe how system generated data appear or disappear, it can be yang extension written in yang files or be a yang data file.

I don't think that we should have default values where the server can choose which value to use because this could mean that if a client also compiled the schema then it could end up with different default behaviour, and hence different semantics.

This seems to be a duplicate of #93

This is too complicated to specify and to implement.
Interactions between when-stmt and dynamic defaults make it too difficult to implement and also
have all servers be consistent.

Real servers do add data to transactions (not just templates).
Sometimes dynamic defaults are needed based on conditions that are hard or impossible
to express in XPath. Sometimes the server adds data in a completely different data structure.
This is a feature to make configuration simpler for the client.

Close