async def get_organizations():
async with meraki.aio.AsyncDashboardAPI(
api_key,
output_log = False,
print_console = False,
suppress_logging=True,
wait_on_rate_limit=True, ##### do wait if rate limited
maximum_retries=100 ##### set the retry limit
) as aiomeraki:
organizations= await aiomeraki.organizations.getOrganizations()
return organizations
#################################################################################### FUNCTIONS ####################################
async def get_template_name(org_id,config_template_id😞
async with meraki.aio.AsyncDashboardAPI(
api_key,
output_log = False,
print_console = False,
suppress_logging=True,
wait_on_rate_limit=True, ##### do wait if rate limited
maximum_retries=100 ##### set the retry limit
) as aiomeraki:
template=await aiomeraki.organizations.getOrganizationConfigTemplate(
org_id, config_template_id
)
template_name=template['name']
return template_name
async def append_template(network,org_id😞
template_list=[]
if network['isBoundToConfigTemplate']==True:
template_name= await get_template_name(org_id,network['configTemplateId'])
template= {"id" :network['configTemplateId'], "name" :"Template - "+ template_name }
if template not in template_list:
template_list.append(template)
elif network['isBoundToConfigTemplate']==False:
network={"id":network['id'],"name":"Network - " +network['name']}
if network not in template_list:
template_list.append(network)
# await asyncio.sleep(1)
return template_list
#################################################################################### ROUTES #######################################
@app.route("/")
async def render_organizations():
organizations=await get_organizations()
return render_template("organizations.html",organizations=organizations)
@app.route('/<org_id>')
async def organization_detail(org_id😞
organization_id = org_id
async with meraki.aio.AsyncDashboardAPI(
api_key,
output_log=False,
print_console=False,
suppress_logging=True,
wait_on_rate_limit=True, ##### do wait if rate limited
maximum_retries=100 ##### set the retry limit
) as aiomeraki:
try:
networks = await aiomeraki.organizations.getOrganizationNetworks(
organization_id, total_pages="all"
)
except OSError as e:
print(e)
template_list = []
# create a list of all network template tasks
network_template_tasks = [append_template(net, org_id) for net in networks]
# iterate over the completed tasks as they finish
for coro in asyncio.as_completed(network_template_tasks😞
# await asyncio.sleep(2)
template_list.extend(await coro)
return render_template("templates.html", templates=template_list). I think i am missing something... The page loads correct and quick if it has a small number of networks. If it has a big number of networks, i think it is not even loading, but i am not getting erros . I tried doing a get in postman while waiting to load te response for a specific organizations and i got "errors": [
"API rate limit exceeded for organization"
]