03-03-2023 01:29 PM
I have a service template that attempts to set max-reauth-req using an XPath:
<max-reauth-req>{/etc/service/wired-nac/interface/dot1x/max-reauth-req}</max-reauth-req>
which is not getting the value:
3-Mar-2023::20:35:30.972 template ios-interface-template: evaluating: /etc/service/wired-nac/interface/dot1x/max-reauth-req
3-Mar-2023::20:35:30.972 template ios-interface-template: result: no nodes
despite the nodes existing:
admin@7ccbd23a9e56# devtools true
admin@7ccbd23a9e56# config
Entering configuration mode terminal
admin@7ccbd23a9e56(config)# xpath eval /etc/service/wired-nac/*
/etc/service/wired-nac/interface
/etc/service/wired-nac/acls
admin@7ccbd23a9e56(config)# xpath eval /etc/service/wired-nac/interface/*
/etc/service/wired-nac/interface/dot1x
admin@7ccbd23a9e56(config)# xpath eval /etc/service/wired-nac/interface/dot1x/*
/etc/service/wired-nac/interface/dot1x/timeout
/etc/service/wired-nac/interface/dot1x/max-reauth-req :: 3
I have confirmed that the value is actual (not a YANG default):
(admin@7ccbd23a9e56(config)# commit dry-run
cli {
local-node {
data etc {
service {
wired-nac {
interface {
dot1x {
- max-reauth-req 3;
+ max-reauth-req 6;
}
}
}
}
}
}
}
What am I doing wrong?
Solved! Go to Solution.
03-06-2023 10:44 AM
Thank you gentlemen! Your assistance regarding context helped me understand what was causing my problem: the XPath '/' represented the service root. I thought starting my XPath with '/' always represented the NSO CDB root.
Adding:
<?set-root-node {/}?>
to the template before the XPaths allowed them to behave as I expected (the '/' in the XPath represented the NSO CDB root).
03-06-2023 12:22 AM
Which context are you in? A good tip is to use the "| debug template" command to see whats going on.
Lets say you have a template and on line 33 you have your xpath. You can do this
commit dry-run | debug template | match -a 10 line\ 33
And it will show you line 33 and then the ten following lines. There you can see which context that xpath query has.
admin@ncs% commit dry-run | debug template | match -a 10 line\ 33
227:Operation 'merge' on non-existing node: /devices/device[name='ce1']/config/ios:interface/GigabitEthernet[name='0/11']/description (from file "l3vpn-ce.xml", line 33)
228:Evaluating "/name" (from file "l3vpn-ce.xml", line 33)
229-Context node: /vpn/l3vpn[name='volvo']
230-Result:
231-For /vpn/l3vpn[name='volvo'], it evaluates to "volvo"
232:Fetching literal " local network" (from file "l3vpn-ce.xml", line 33)
233-Setting /devices/device[name='ce1']/config/ios:interface/GigabitEthernet[name='0/11']/description to "volvo local network"
234-Operation 'merge' on existing node: /devices/device[name='ce1']/config/ios:interface/GigabitEthernet[name='0/11']/ip/address/primary/address (from file "l3vpn-ce.xml", line 37)
235-Evaluating "$LOCAL_CE_ADR" (from file "l3vpn-ce.xml", line 37)
236-Context node: /vpn/l3vpn[name='volvo']
237-Result: "10.7.7.1"
238-Setting /devices/device[name='ce1']/config/ios:interface/GigabitEthernet[name='0/11']/ip/address/primary/address to "10.7.7.1"
239-Operation 'merge' on existing node: /devices/device[name='ce1']/config/ios:interface/GigabitEthernet[name='0/11']/ip/address/primary/mask (from file "l3vpn-ce.xml", line 38)
240-Evaluating "$CE_MASK" (from file "l3vpn-ce.xml", line 38)
241-Context node: /vpn/l3vpn[name='volvo']
242-Result: "255.255.255.0"
03-06-2023 01:30 AM
Just to add to the previous reply, you can set the context when using the xpath tool to do the eval:
admin@ncs% xpath ctx devices eval device/name
/devices/device[name='ASR9K1']/name :: ASR9K1
/devices/device[name='ASR9K2']/name :: ASR9K2
/devices/device[name='IOS-XRv']/name :: IOS-XRv
/devices/device[name='MX960']/name :: MX960
/devices/device[name='MX961']/name :: MX961
/devices/device[name='MX962']/name :: MX962
/devices/device[name='MX963']/name :: MX963
/devices/device[name='PTX1']/name :: PTX1
/devices/device[name='vMX1']/name :: vMX1
/devices/device[name='vMX2']/name :: vMX2
/devices/device[name='vMX6']/name :: vMX6
[ok][2023-03-06 09:35:02]
[edit]
admin@ncs%
03-06-2023 10:44 AM
Thank you gentlemen! Your assistance regarding context helped me understand what was causing my problem: the XPath '/' represented the service root. I thought starting my XPath with '/' always represented the NSO CDB root.
Adding:
<?set-root-node {/}?>
to the template before the XPaths allowed them to behave as I expected (the '/' in the XPath represented the NSO CDB root).
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: