Filter the type from leafref

For the leafref , how to filter when I only want to reference some of name from original leaf node?

From example:
leaf port{
type leafref {
path “/exa:config/exa:interface/eth:ethernet/eth:port”;
}
}

The path “/exa:config/exa:interface/eth:ethernet/eth:port” includes below port name string:
g1/g2/g3/bond1/bond2/bond3.

But I only want to reference g1/g2/g3 by the leaf port, while the bond1/bond2/bond3 should be sightless in the leaf node. How could i implement?

Not sure if you have tried the callpoint, secondly it isn’t clear wether its for config or operdata …

It is a data getting operation.
How to define the callpoint? The leaf don’t leafref another leaf node, and only change to callpoint, right?

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).

Hi,

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”

How could I find the chapter? Could you give me a link?

See ConfD 6.3 UG 16.12.1. Customizing CLI completion

Could you give me a download link? I couldn’t find it just now.

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.

1 Like