filter on request for pre-rulebase/security/rules

Reply
Highlighted
L1 Bithead

filter on request for pre-rulebase/security/rules

Is it possible to add filter on a request, i want to get pre-rulebase security rules which contains a key word, do this:

type=config&action=get&xpath=/config/devices/entry[\@name='localhost.localdomain']/device-group/entry[\@name='deviceGroupName']/pre-rulebase/security/rules

And in result i only want rules which contain "test" for example

L4 Transporter

Re: filter on request for pre-rulebase/security/rules

 

I'm not sure you can do "like" filtering in the request itself, but you can definitely do it programmatically if you just get all the security rules.

 

Here's how to do this in pandevice:

 

from pandevice import panorama, policies

pano = panorama.Panorama(host, username, password)
myGroup = panorama.DeviceGroup('deviceGroupName')
prb = policies.PreRulebase()

# Build the object tree.
pano.add(myGroup)
myGroup.add(prb)

# Get the answer.
all_rules = policies.SecurityRule.refreshall(prb)
answer = [x for x in all_rules if 'test' in x.name]

 

Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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 Live Community as a whole!

The Live Community thanks you for your participation!