netmod-wg / yang-next

Feature requests for future versions of YANG
6 stars 0 forks source link

Support for conditional default values #112

Open Reshad-Rahman opened 2 years ago

Reshad-Rahman commented 2 years ago

https://mailarchive.ietf.org/arch/msg/netmod/H1n_eARPuYz2D-Gu9IgzV86rQIg/

abierman commented 2 years ago

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

lllyfeng commented 2 years ago

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.

rgwilton commented 1 month ago

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.

abierman commented 1 week ago

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