07-13-2021 08:30 AM
Hi All,
I am trying to reference an xpath of service A in service B. In service B will first lookup for devicename(key) and prefix id(key)
the third key is static [public='true']:
Service A:
/services/test:test[devicename='ww']/prefixes[prefix='6000'][public='true']/ipv4Address 200.1.1.1
/services/test:test[devicename='ww']/prefixes[prefix='6000'][public='false']/ipv4Address 172.1.1.1
Service B:
Solved! Go to Solution.
07-13-2021 09:02 AM
07-19-2021 01:39 AM
Hello,
Looks like you are trying to get the value of the leaf
root.services.devicename["ww"].prefixes[6000,"true"].ipv4Address
inside the variable for your templates.
Couple of points here:
* As @vleijon mentioned the correct way to reference the leaf should use the python syntax for multi key list (you can look it up there: https://developer.cisco.com/docs/nso/guides/#!python-api-overview/maagic-api - subsection List and List Elements - there is no anchor at this hierarchy level so cannot point you to it directly)
* You actually don't need the f string
From what I understand from your model, a possible resolution in service B would be:
vars.add('ipv4Address', root.services.devicename[service.Service_B_devicename].prefixes[service.prefix,"true"].ipv4Address)
which *SHOULD* put the value of the leaf ipv4Address for (6000, "true") inside the variable you are then using in your template.
07-13-2021 09:02 AM
07-13-2021 09:27 AM
prefixes Is a list with two keys: prefix and public.
prefix is will be selected in service B, while public is always true.
07-19-2021 01:39 AM
Hello,
Looks like you are trying to get the value of the leaf
root.services.devicename["ww"].prefixes[6000,"true"].ipv4Address
inside the variable for your templates.
Couple of points here:
* As @vleijon mentioned the correct way to reference the leaf should use the python syntax for multi key list (you can look it up there: https://developer.cisco.com/docs/nso/guides/#!python-api-overview/maagic-api - subsection List and List Elements - there is no anchor at this hierarchy level so cannot point you to it directly)
* You actually don't need the f string
From what I understand from your model, a possible resolution in service B would be:
vars.add('ipv4Address', root.services.devicename[service.Service_B_devicename].prefixes[service.prefix,"true"].ipv4Address)
which *SHOULD* put the value of the leaf ipv4Address for (6000, "true") inside the variable you are then using in your template.
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: