- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
07-24-2023 05:35 AM
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
07-26-2023 01:15 AM - edited 07-26-2023 01:17 AM
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
07-26-2023 01:15 AM - edited 07-26-2023 01:17 AM
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
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!