cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1939
Views
0
Helpful
3
Replies

How to specify xpath filter for get-config

twinstiger2
Level 1
Level 1

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

3 Replies 3

abhirame
Cisco Employee
Cisco Employee

Currently, only subtree filtering is supported (https://tools.ietf.org/html/rfc6241#section-6). YDK does not support xpath filtering

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

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.