- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
03-02-2020 01:26 PM
Hi,
I have this little script, the idea is show in the console all address that I have in the running config.
But, when I work with the xml element. the print not show the addresses.
This is the result or rest api. to operation command "show config running"
I need to extract from xml the name object and ip-netmask.
03-03-2020 09:42 AM
Seems like you're using pandevice to do the op() call? If so, this is better since there is an object for address objects:
from pandevice.objects import AddressObject
listing = AddressObject.refreshall(fw)
for obj in listing:
if obj.type != 'ip-netmask':
continue
print('Name: {0}) | ip-netmask: {1}'.format(obj.name, obj.value))
If you really wanted to do "'show config running" to get the answer, your xpath search is wrong. It should be ./result/config/devices/entry[@name='vsys1']/address/entry
. At that location, the name is an attribute, and ip-netmask
may or may not be there, so using find() is ok.
03-03-2020 09:42 AM
Seems like you're using pandevice to do the op() call? If so, this is better since there is an object for address objects:
from pandevice.objects import AddressObject
listing = AddressObject.refreshall(fw)
for obj in listing:
if obj.type != 'ip-netmask':
continue
print('Name: {0}) | ip-netmask: {1}'.format(obj.name, obj.value))
If you really wanted to do "'show config running" to get the answer, your xpath search is wrong. It should be ./result/config/devices/entry[@name='vsys1']/address/entry
. At that location, the name is an attribute, and ip-netmask
may or may not be there, so using find() is ok.
03-03-2020 12:43 PM
Thank you so much!!!. I'm creating a script to get all object and compare to see the duplicates and take that info to perform a clean up in the firewall.
Again thanks a lot!!!
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!