I have been tasked with creating a list of every client in an org that has been whitelisted. I think there could be between 200,000 and 300,000 clients.
My plan of attack was to iterate through every network, use getNetworkClients to get every client, and iterate through them calling getNetworkClientPolicy on every client to see if they are whitelisted.
If I drop the concurrency to just 1 the below code snippet works fine (but very slow):
async with meraki.aio.AsyncDashboardAPI(
output_log=False,
print_console=False,
maximum_concurrent_requests=1
) as dashboard:
await searchOrg(dashboard,orgName)
...
clientTasks = [checkPolicy(dashboard,net['id'],client) for client in await dashboard.networks.getNetworkClients(net['id'],total_pages='all',timespan=1*86400)]
for task in asyncio.as_completed(clientTasks):
await task
...
async def checkPolicy(dashboard,netId,client):
policies=await dashboard.networks.getNetworkClientPolicy(netId,client['id'])
if policies['devicePolicy'] == 'Whitelisted':
print(f"{client['mac']},{client['ip']},{client['description']}")
elif policies['devicePolicy'] == 'Different policies by SSID':
print(f"{client['mac']},{client['ip']},{client['description']},{policies['ssids']}")
If I change maximum_concurrent_requests from 1 to 2 I start getting a reasonable number of 429 warnings, but it does run. It I change it to 5 I get a huge number of 429s, and this error gets thrown after a short amount of processing time:
meraki.exceptions.AsyncAPIError: networks, getNetworkClientPolicy - 429 Too Many Requests, Reached retry limit: None
I don't understand with a limit of just 2 why I am hitting any limit and getting 429s. And then, if the rety limit is "none", why is it throwing an exception.
I really want the concurrency at least at 5. Any ideas?