ConfD User Community

How to write conditional callpoint


#1

Hey,

I have below yang structure and need away to make the call point is triggered for specific items based on value of other field

container root {
          leaf type{
           type string;
         }

container child {
  config false;
 tailf:callpoint my-call-point; // I need this call point to be triggered only when the leaf type equal "XYZ". It shouldn't be triggered when value is other than that

  leaf x{
           type string;
         }

  leaf y{
           type string;
         }

}


}

#2

Unfortunately, for callpoint you cannot use when as sub-statement. You need to check condition inside callpoint code. E.g. check value (through maapi) of leaf type and if it is not equal XYZ, return no elements in the data provider. This will still report “No data” when you try to display child container.
You may also try to put when statement on child container, so it is only visible when leaf type is XYZ.


#3

Hi,

Using when & presence together fixed the issue. Here the working code

container root {
          leaf type{
           type string;
         }

container child {
presence "child";
                                when "../type[text()=='xyz']" {
                                    tailf:dependency "../type";
                                }
  config false;
 tailf:callpoint my-call-point; // I need this call point to be triggered only when the leaf type equal "XYZ". It shouldn't be triggered when value is other than that

  leaf x{
           type string;
         }

  leaf y{
           type string;
         }

}
}

But this will not work if callpoint is added under list as shown below:

container root {
          leaf type{
           type string;
         }

list child {
                                when "../type[text()=='xyz']" {
                                    tailf:dependency "../type";
                                }
  config false;
 tailf:callpoint my-call-point; 

  leaf x{
           type string;
         }

  leaf y{
           type string;
         }

}
}

I didn’t find a solution for conditional call-point when it is added to list and not a container

Any help appreciated

Thanks,