Also using an xml format is it possible to delete existing configuration on the device?
You can follow below example to use delete action in xml config file.
xml = """<policy-options>
<policy-statement action="delete">
<name>F5-in</name>
<term>
<name>testing</name>
<then>
<accept/>
</then>
</term>
<from>
<protocol>mpls</protocol>
</from>
</policy-statement>
</policy-options>"""
cu = Config(dev)
cu.load(xml, format='xml')
cu.commit()
Sotiris Ioannou
unread,
Aug 21, 2015, 7:23:12 AM8/21/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Junos Python EZ, sotiris...@gmail.com, nit...@juniper.net
Hi Nitin,
I have tried the delete option and it doesn't work. The netconf module in the log shows replace (the configuration commits no errors is not removed from the configuration though). UI_NETCONF_CMD: User 'root' used NETCONF client to run command 'load-configuration action="replace" format="xml"'
Is this only supported on certain type of platforms I'm using a vSRX for the testing. Also is there a document that describes at what level of the xml you can apply an action?
Thanks,
Sotiris
Sotiris Ioannou
unread,
Aug 21, 2015, 8:25:02 AM8/21/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Junos Python EZ, sotiris...@gmail.com, nit...@juniper.net
Hi Nitin,
And anyone reaching this post, in my search for an answer I came across the following information:
Deleting Configuration Elements Using NETCONF (Juniper Doc):
So to delete the configuration under the inet stanza of an interface do the following: <python code> from jnpr.junos import Device from pprint import pprint from jnpr.junos.utils.config import Config from jnpr.junos.exception import * import paramiko cpe = Device (host="IP-ADDRESS", user="root", password="pass") cpe.bind( cu=Config ) xml= """ <configuration> <interfaces> <interface> <name>ge-0/0/1</name> <unit> <name>0</name> <family> <inet operation="delete"> </inet> </family> </unit> </interface> </interfaces> </configuration>""" cu.load(xml,format='xml') cu.commit <python code>
Pay attention to the operation keyword that is the one you need to delete the configuration.
To find the xml structure run the command show configuration | display xml on you router to get the details and just reference the part you are interested in.