I couldn't really wrap my head around mapping New Objects to the New Groups, but here's the gist of it.
Unless you modify it yourself to map them, you'll have to do so manually in the dashboard.
I have only just written this. I have not tested it.
#! /usr/bin/env python3
import meraki
SRC_ORG_ID = ""
DEST_ORG_ID = ""
def GetObjectsAndGroups(p_dashboard,p_OrgId):
print(f"Retrieving Policy Objects for {p_OrgId}..")
PolicyObjects = p_dashboard.organizations.getOrganizationPolicyObjects(
p_OrgId, total_pages='all'
)
print("Done!")
print(f"Retrieving Policy Objects Groups for {p_OrgId}..")
PolicyObjectGroups = p_dashboard.organizations.getOrganizationPolicyObjectsGroups(
p_OrgId, total_pages='all'
)
print("Done!")
result = {
"objects": PolicyObjects,
"groups": PolicyObjectGroups
}
return result
def PostObject(p_dashboard,p_OrgId,p_Objects):
NewPolicyObjects = []
print("Creating new object, one-by-one..")
for item in p_Objects:
print(f"Pushing Obj: {item['name']}...")
response = p_dashboard.organizations.createOrganizationPolicyObject(
p_OrgId, item['name'], item['category'], item['type'],
groupIds=[]
)
print(f"Done! New object id is {response['id']}")
NewPolicyObjects.append(response)
return NewPolicyObjects
def PostObjGroup(p_dashboard,p_OrgId,p_Groups):
NewPolicyObjGroups = []
print("Creating new group, one-by-one..")
for item in p_Groups:
print(f"Pushing Group: {item['name']}...")
response = p_dashboard.organizations.createOrganizationPolicyObjectsGroup(
p_OrgId, item['name'],
objectIds=[]
)
print(f"Done! New group id is {response['id']}")
NewPolicyObjGroups.append(response)
return NewPolicyObjGroups
def main():
dashboard = meraki.DashboardAPI(
suppress_logging=True,
simulate=False
)
# Pull objects from source Organisatiion
Src_PolicyObjects = GetObjectsAndGroups(dashboard,SRC_ORG_ID)
# Push object to destination Organization
NewPolicyObjects = PostObject(dashboard,DEST_ORG_ID,Src_PolicyObjects['objects'])
#Push object groups
NewPolicyObjectGroups = PostObjGroup(dashboard,DEST_ORG_ID,Src_PolicyObjects['groups'])
### TODO: Map Objects to Groups
if __name__ == "__main__":
main()
Edit: Remove simulate param, and added missing colon to method definition.
LinkedIn :::
https://blog.rhbirkelund.dk/Like what you see? - Give a Kudo ## Did it answer your question? - Mark it as a Solution
🙂All code examples are provided as is. Responsibility for Code execution lies solely your own.