- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
09-09-2022 08:49 AM
Is there a way to create device under a parent or move a device group using the sdk.
Similar to Operational command:
> request move-dg dg1 new-parent-dg dg1_parent create-dg yes
I am aware of the dg_hierarchy opstate, which helps finding the device group, but how can I set the parent when creating a new group?
DeviceGroup.create() method just places the new group under shared and this fails in cases of having depended objects on the parent device group.
In the fist case I need to create a new group as member of parent device group.
In the second case I want to "clone" device group with a new name under new parent. Any help how to do that?
04-14-2023 02:55 AM
Hi
You might already have found the answer but for any future searches.
Instead of using opcommands you can use the following code
newsite = DeviceGroup(site.SiteName)
pano.add(newsite)
newsite.create()
newsite.opstate.dg_hierarchy.__setattr__('parent', site.Region)
newsite.opstate.dg_hierarchy.update()
10-03-2022 06:44 AM
Hi @batd2, you can perform lots of operational tasks like this with op(), for example:
resp = panorama.op('<request><move-dg><entry name="new-dg"><new-parent-dg>home-dg</new-parent-dg></entry></move-dg></request>', xml=True, cmd_xml=False)
print(resp)
Ref: https://pan-os-python.readthedocs.io/en/latest/getting-started.html#operational-commands and https://pan-os-python.readthedocs.io/en/latest/module-base.html#panos.base.PanDevice.op
Hope that helps!
10-12-2022 03:36 PM
The GUI hides that creating a device group then moving it under the specified device group instead of "Shared" is a two-step process, but it is in fact a two step process. There is device group hierarchy opstate stuff in place, just use the opstate
namespace hanging off of your instance of the panos.panorama.DeviceGroup
object along with the docs:
https://pan-os-python.readthedocs.io/en/latest/getting-started.html#the-opstate-namespace
04-14-2023 02:55 AM
Hi
You might already have found the answer but for any future searches.
Instead of using opcommands you can use the following code
newsite = DeviceGroup(site.SiteName)
pano.add(newsite)
newsite.create()
newsite.opstate.dg_hierarchy.__setattr__('parent', site.Region)
newsite.opstate.dg_hierarchy.update()
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!