pan-os-python trying to pull list of security polices from panorama using a specific device group

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

pan-os-python trying to pull list of security polices from panorama using a specific device group

L2 Linker
# This defines how we will connect to panorama
mypanorama = panorama.Panorama(device, api_key=auth_key)
# This defines the device group we will be connecting to
palo_device_group = panorama.DeviceGroup(devicegroup)
mypanorama.add(palo_device_group)
rulebase = PreRulebase
palo_device_group.add(rulebase)

existing_policies = SecurityRule.refreshall(palo_device_group)
 
 
the code above resutls in an empty object existing_policies    anyone know what im missing ? im not sure ...
1 accepted solution

Accepted Solutions

L2 Linker

here is the code i got working

 

# This defines how we will connect to panorama
mypanorama = panorama.Panorama(device, api_key=auth_key)
# This defines the device group we will be connecting to
palo_device_group = panorama.DeviceGroup(devicegroup)
mypanorama.add(palo_device_group)
rulebase = PreRulebase()
palo_device_group.add(rulebase)

existing_policies = SecurityRule.refreshall(rulebase)

View solution in original post

3 REPLIES 3

L2 Linker

here is the code i got working

 

# This defines how we will connect to panorama
mypanorama = panorama.Panorama(device, api_key=auth_key)
# This defines the device group we will be connecting to
palo_device_group = panorama.DeviceGroup(devicegroup)
mypanorama.add(palo_device_group)
rulebase = PreRulebase()
palo_device_group.add(rulebase)

existing_policies = SecurityRule.refreshall(rulebase)

L1 Bithead

If anybody interested in working with PanOS Python and Panorama - https://www.packetswitch.co.uk/palo-alto-pan-os-python-sdk-panorama/

 

Hi, 

 

I am new to panorama apis. While I was following your snippet I got this error can you please help?

 

pano = Panorama(panorma_url,api_key=panorma_api_key)
dg = DeviceGroup("Shared")
pano.add(dg)
rulebase = PostRulebase()
dg.add(rulebase)

 

error is:

[ERROR] 2024-01-19T05:21:37.944Z 88d3f5f9-8a4d-445d-86aa-e0dc5f3d8d46 Lambda failed with the error:'URLError: reason: [Errno -2] Name or service not known'
2024-01-19 05:21:37,944 - root - ERROR - Lambda failed with the error:'URLError: reason: [Errno -2] Name or service not known'
END RequestId: 88d3f5f9-8a4d-445d-86aa-e0dc5f3d8d46

  • 1 accepted solution
  • 1367 Views
  • 3 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!