Enhanced Security Measures in Place:   To ensure a safer experience, we’ve implemented additional, temporary security measures for all users.

PANDEVICE in Python to query details of a specific Static Address Group

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

PANDEVICE in Python to query details of a specific Static Address Group

L1 Bithead

I am relatively new to using PANOS/PANDEVICE libraries in Python with Panorama.  I am trying to figure out how to get a list of AddressObjects associated with a specific Static AddressGroup in the "Shared" DeviceGroup. 

 

object_name = "H-i-061d40e4013db52ae"
pano_device_group = panorama.DeviceGroup('shared')
pano.add(pano_device_group)
object_list = pano.add(objects.AddressGroup(name=object_name)).refreshall(pano_device_group) 
 
This just returns a list of all AddressGroups defined in the shared DeviceGroup....
 
Someone rescue me please....
 
 
1 accepted solution

Accepted Solutions

L2 Linker

Greetings,

 

Since doing the refreshall returns a list, you are going to have to iterate through the list to get your result. See example below.

 

import panos
from panos import firewall
from panos import panorama
from panos import network
from panos import device
from panos import updater
from panos import errors
from panos import objects

pano = panorama.Panorama(IP, ADMIN, PASSWORD)
grp = objects.AddressGroup(name='some group name')
pano.add(grp)
ListOfAllGroups = grp.refreshall(pano)
for i in ListOfAllGroups:
if i.name == grp.name:
print(i.static_value)

 

View solution in original post

1 REPLY 1

L2 Linker

Greetings,

 

Since doing the refreshall returns a list, you are going to have to iterate through the list to get your result. See example below.

 

import panos
from panos import firewall
from panos import panorama
from panos import network
from panos import device
from panos import updater
from panos import errors
from panos import objects

pano = panorama.Panorama(IP, ADMIN, PASSWORD)
grp = objects.AddressGroup(name='some group name')
pano.add(grp)
ListOfAllGroups = grp.refreshall(pano)
for i in ListOfAllGroups:
if i.name == grp.name:
print(i.static_value)

 

  • 1 accepted solution
  • 3885 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!