07-06-2020 05:55 AM - edited 07-06-2020 05:58 AM
hello guys,
somehow I couldn't figure out the way to remove existing configuration with netconf. I created xml template based on yang file static for xr 6.5.3 as follows:
sr_config = ''' <config> <router-static xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ip-static-cfg"> <default-vrf> <address-family> <vrfipv4> <vrf-unicast> <vrf-prefixes> <vrf-prefix> <prefix>13.13.13.13</prefix> <prefix-length>32</prefix-length> <vrf-route> <vrf-next-hop-table> <vrf-next-hop-interface-name> <interface-name>Null0</interface-name> <tag>710</tag> <description>test_netconf</description> </vrf-next-hop-interface-name> </vrf-next-hop-table> </vrf-route> </vrf-prefix> </vrf-prefixes> </vrf-unicast> </vrfipv4> </address-family> </default-vrf> </router-static> </config> '''
device_h.edit_config(target="candidate", config=sr_config)
I can filter it out too, but how I am supposed to delete this config?
01-10-2022 02:31 AM
Hi Ugur,
Basically all you need is to add the XML namespace to the config tag and a delete operation on the 'vrf-prefix' element in addition to leafs identifying the particular route object to be deleted:
sr_config = '''<config xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<router-static xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ip-static-cfg">
<default-vrf>
<address-family>
<vrfipv4>
<vrf-unicast>
<vrf-prefixes>
<vrf-prefix nc:operation="delete">
<prefix>13.13.13.13</prefix>
<prefix-length>32</prefix-length>
</vrf-prefix>
</vrf-prefixes>
</vrf-unicast>
</vrfipv4>
</address-family>
</default-vrf>
</router-static>
</config>'''
resp = device_h.edit_config(target="candidate", config=sr_config)
print(resp)
device_h.commit()
- Johnny
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