the interface name is defined as <container_name>-
Ex: sample-1, test-2, value-3
In operational mode, when I do show with interface name say,
show interfaces interface sample-1 => getting leaf nodes of sample-1 interface
show interfaces interface value-1 => getting leaf nodes of value-1 interface
show interfaces interface sample => this list all sample interfaces only (because of the presence statement)
In value container, presence statement is not added.
so when I give “show interfaces interface value” => list all value interfaces along with other interfaces (sample and test)
test container is shared between 2 code.
One code doesn’t want presence statement to be added and other code wants.
Is there a way to deviate/refine presence statement?
It is not standard yang way, but if you can use Java and Groovy in your build environment, you can also generate different versions of the yang file with https://bitbucket.org/novakmi/yangbuilder (note, this is something I have written, so may view is influenced).
This is often useful with larger models, when sometimes yang reuse and condition statements cannot be used (e.g. if-feature cannot be used under import statement), or if you want to bring reuse to another level and mix yang like syntax with the programming language (loops, conditions, functions, etc.)
The output is yang file, which is processed in regular way (confdc, pyang, etc.).
The code would look like (syntax is similar to yang):
// augment defined as closure, so we do not repeat it
def augment = { type, pres = true ->
augment "/if:interfaces/if:interface", {
container type, {
when "../if:type = '${type}'";
description "${type} containter";
if (pres) {
presence '""'
}
}
}
yngbuild '' //for new line
}
augment "test", true // or false for non presence variant
augment "value"
augment "sample"