It is possible in YANG to “tag” certain nodes with an “if-feature” statement.
The syntax is: if-feature ;
The goal of features in YANG is to achieve a conditional support of data trees based on the hardware capabilities. This is specified during the compilation time of YANG modules.
In order to make use of the “if-feature” capability, developers needs to define the associated feature in YANG.
Example: feature.yang
feature featureA {
}
feature featureB {
}
container foo {
if-feature featureA;
}
container bar {
if-feature featureB;
}
During compilation, if we want to enable feature A and not feature B, we need to specify -F featureA to confdc. “man confdc” has more details on this.
confdc -c -o feature.fxs -F feature:featureA feature.yang
If the -F option is not specified, all of the features defined in the YANG file will be enabled by default.