Devicegroup hierarchy dump

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

Devicegroup hierarchy dump

 

Hello,

 

 

im trying to come with a way to being provided with a devicegroup name, be able to get the objects from the current devidegroup, but

also form each parent devicegroup. With the idea ti try to clean duplicated objects, the issue here is that no matter how i try to get to that i find no method or property to be able to identify parent info.

 

I have few dgs on my lab, but i have tried the following based on the following 2.

- device-groupA

     - device-groupB

 

   ...: dg=panorama.DeviceGroup('device-groupA')
   ...: pano.add(dg)
   ...:
Out[1]: <DeviceGroup device-groupA 0x7f9a0e73c278>

In [3]: print(dg.parent)
172.18.0.14
In [4]:
In [4]: pano.remove(dg)
In [5]: dg=panorama.DeviceGroup('device-groupB')
In [6]: print(dg.about())
{'tag': None, 'name': 'device-groupB'}
In [7]: print(dg.parent)
None

 

 

No matter what i try im not able to get any attribute do show the parent devicegroup, any ideas or tips please ?

 

Regards

 

1 accepted solution

Accepted Solutions

 

Hi,

 

finally found, based my testing on the article pan-os-sdk-device-group-hierarchy  So digging deep in the options under __ inside the dg_hierachy properties i got the getattriute and after some testing i got a way to go form the lowest dg to the upper one.

 

This time starting from device-groupB that is the lower prio one in the tree.

 

In [3]: dg=panorama.DeviceGroup('device-groupB')
In [4]: pano.add(dg)
Out[4]: <DeviceGroup device-groupB 0x7fa910a4e588>
In [5]: scope.opstate.dg_hierarchy.refresh()
In [6]: dg.opstate.dg_hierarchy.refresh()
In [8]: print(dg.opstate.dg_hierarchy.__getattribute__('parent'))
device-groupA

In [9]: dg=panorama.DeviceGroup('device-groupA')
In [10]: pano.add(dg)
Out[10]: <DeviceGroup device-groupA 0x7fa9109f49b0>
In [11]: dg.opstate.dg_hierarchy.refresh()
In [12]: print(dg.opstate.dg_hierarchy.__getattribute__('parent'))
None

 

 

 

Regards

View solution in original post

1 REPLY 1

 

Hi,

 

finally found, based my testing on the article pan-os-sdk-device-group-hierarchy  So digging deep in the options under __ inside the dg_hierachy properties i got the getattriute and after some testing i got a way to go form the lowest dg to the upper one.

 

This time starting from device-groupB that is the lower prio one in the tree.

 

In [3]: dg=panorama.DeviceGroup('device-groupB')
In [4]: pano.add(dg)
Out[4]: <DeviceGroup device-groupB 0x7fa910a4e588>
In [5]: scope.opstate.dg_hierarchy.refresh()
In [6]: dg.opstate.dg_hierarchy.refresh()
In [8]: print(dg.opstate.dg_hierarchy.__getattribute__('parent'))
device-groupA

In [9]: dg=panorama.DeviceGroup('device-groupA')
In [10]: pano.add(dg)
Out[10]: <DeviceGroup device-groupA 0x7fa9109f49b0>
In [11]: dg.opstate.dg_hierarchy.refresh()
In [12]: print(dg.opstate.dg_hierarchy.__getattribute__('parent'))
None

 

 

 

Regards

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