07-07-2020 01:32 AM
hello dears how could I Pass the values of my leafref in my template without passing them with python variable.
for example if I have a service called child:
.... leaf id{ type string; } leaf name{ type string; } leaf birth{ type string; } ...
and other service called parent that ref to the child service :
.... leaf id{ type string; } leaf name{ type string; } leaf child{ type leafref{ path "/c:child/c:id"; } ...
In the template file of the service parent I'd like to pass the child values even the id and both name and birth.
I now this could be use by python but in my case it will require a big refactor of my services.
Your advices wil appreciate.
regards.
07-07-2020 02:38 AM
Hello,
I think the most convenient way to do that in your template is to use the deref() function.
So in the parent service templates you will use a xpath like {deref(child)/../birth}.
deref() is moving your xpath context to the leaf that your leafref points to. Then you practically always use /../ to go up to the parent of the leaf, and then you navigate from there.
07-07-2020 08:30 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide