You cannot restrict a leafref.
But you can protect against non wanted values using a must statement.
Example:
must “false() = starts-with(current(), ‘bond’)” {
error-message “cannot start with ‘test’”;
}
If you want to control the tab complition you can use the completion callback:
Check: 16.12.1. Customizing CLI completion.
I have one question here if I use the completion and specify the possible completion. If my keyword has a dependency of another configuration. Like for example in above…
i.e if a gig card config loaded then only these gig interfaces are valid.
in my config if above config gets loaded first before gig card config gets loaded when loading my config, will it fail or will it still take as a string ? (assuming if its not a leafref and just a leaf string).
If the config is loaded / entered into CDB in one transaction, CDB will handle the ordering in the transaction and so there is no issue for ConfD CDB handling your scenario.
If you are using an external datastore, e.g. through a tailf:callpoint in your YANG model covering that part of the configuration, your external datastore need to be able to handle transactions and ordering in transactions, such as leafs referencing list keys set later in same transaction.
Thanks a lot, that clarifies… Mine is external datastore is their any example which I can take a look to understand. As of now I am doing a delayed response in the call point. But its very much possible my desired config is not loaded before this current cli.
Take a look at CONFD_ACCUMULATE in the confd_lib_dp(3) man page, the examples examples.confd/intro/6-c_config
and examples.confd/user_guide_examples/simple_trans/simple_withtrans.c
and the ConfD 6.3 UG chapter “External configuration data with transactions” and chapter “Discussion - CDB versus external DB”
Preferably if you are working with a project at your company that has access to ConfD Premium, you go through your contacts at your company.
If not, you need to register for a Cisco account to download ConfD Basic.