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

Announcements

Changes to the LIVEcommunity experience are coming soon... Here's what you need to know.

Reply
BobbyWilloughby
L1 Bithead

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

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....
 
 

Accepted Solutions
mrzepa2
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


All Replies
mrzepa2
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

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!