06-20-2018 07:39 AM
So is there any example to specify xpath when doing get-config Path API ?
I started with a sample as follows;
root_schema = session.get_root_schema()
get = True
sys = root_schema.create_datanode("ietf-interfaces:interfaces/interface", "")
#sys.create_datanode("contact","test")
codec_service = Codec()
xml2 = codec_service.encode(sys, EncodingFormat.XML, True)
get_rpc = root_schema.create_rpc('ietf-netconf:get-config')
get_rpc.get_input_node().create_datanode('source/running')
get_rpc.get_input_node().create_datanode('filter', xml2)
print(codec_service.encode(get_rpc.get_input_node(), EncodingFormat.XML, True))
try:
data_nodes = get_rpc(session)
except Exception as e:
log.error("Failed....: " + str(e))
exit(1)
I can see it generate netconf RPC as follows but I am not sure how to construct the filter tags correctly.
Thanks in advance for any help...
=============Generating payload to send to device=============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><get-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<source>
<running/>
</source>
<filter><interface xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"/>
</filter>
</get-config>
</rpc>
David
06-20-2018 09:36 AM
Currently, only subtree filtering is supported (https://tools.ietf.org/html/rfc6241#section-6). YDK does not support xpath filtering
06-20-2018 10:09 AM
Even with subtree filter, how exactly do you build the get_rpc codes similar to the codes I've shown. Any example?
For example, if I want to select the following equivalent xpath filter for ietf-interfaces module;
"interfaces/interface[name!='ETH1']"
Do I need to add the appropriate namespaces?
Thanks.
David
06-20-2018 10:16 AM
You are on the right track. Please check the example here. Just change the rpc to 'ietf-netconf:get-config' etc after line 38.
Note that "name!='ETH1'" is an xpath expression and it cannot be used in a netconf subtree fillter.
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