filter on request for pre-rulebase/security/rules

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Please sign in to see details of an important advisory in our Customer Advisories area.

filter on request for pre-rulebase/security/rules

L1 Bithead

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

1 accepted solution

Accepted Solutions

L5 Sessionator

 

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]

 

View solution in original post

1 REPLY 1

L5 Sessionator

 

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]

 

  • 1 accepted solution
  • 1976 Views
  • 1 replies
  • 0 Likes
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 LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!