03-28-2017 12:11 AM
Hi,
I'm trying to write a reporting tool that will go throguh various device groups and identify rules that have certain keywords (change numbers in my case) in the description.
I'm querying panorama configuration and using rest api directly from python (e.g. requests module or pan.xapi)
For example, this query works perfectly for me and as a result I get two rules returned back, if description contains only one string CHG99646:
/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='Perth']/pre-rulebase/security/rules/entry[description="CHG99646"]
03-28-2017 12:50 AM
What I mean is that PAN is using Xpath, so you can use what Xpath has available:
In your case, something like that should work :
[contains(text(),'whatYouWantHere')]
concerning your other question about Global Find and such : it's not exposed to through API unfortunatly. But it's somethign available on my project if you dont mind using it and/or developping in PHP 😉
03-28-2017 12:20 AM
Hi,
The API is not designed for that. It has limited support for XPath and pulling data locally is probably the only way.
There are as well exisiting utilities which can do what you are looking for already, like one of mine here: https://live.paloaltonetworks.com/t5/API-Articles/rules-edit-php-to-manage-edit-export-rules-from-CL...
03-28-2017 12:46 AM
OK, so Palo Alto decided not to implement %like% in their rest api. Understood.
Do you know if there is an op command that I could incorporate instead of using wildcards in the xpath matching? Something similar to global find in panorama gui or a | match when I am running show configuration? I mean, anything that will return a security rule name(s) based on text I want to find in description.
Cheers,
Milos
03-28-2017 12:50 AM
What I mean is that PAN is using Xpath, so you can use what Xpath has available:
In your case, something like that should work :
[contains(text(),'whatYouWantHere')]
concerning your other question about Global Find and such : it's not exposed to through API unfortunatly. But it's somethign available on my project if you dont mind using it and/or developping in PHP 😉
03-28-2017 12:56 AM
I'm trying to use your suggestion with contains text but I am not able to match anything
Could you give a full xpath example for matching description field with [contains(text(),'whatYouWantHere')]? I'm missing something when trying to use your suggestion.
For the PHP I have minimal knowledge there 🙂
Milos
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!