can anyone assist with the addition of rate limiting and re-tries so i can get some "fault tolerance" in my scripting.
here is the script i am using in Visual Studio to update / create VLANs, i keep getting kicked out due to 429 - too many requests, due to other applications and services also running API calls and scripts. it may be successful for the first 1-3 vlans but gets kicked out as failure for the rest.
import csv
import meraki
import os
# Replace this with your Meraki API key
API_KEY = os.environ.get('X-Cisco-Meraki-API-Key')
dashboard = meraki.DashboardAPI(API_KEY,caller='callerTAG')
# Get the organization ID
org_id = 'ORG#'
# Get the networks in the organization
networks = dashboard.organizations.getOrganizationNetworks(org_id, tags='ADD Unique Identifier')
#copy the commands from the Consolidated VLAN Config.xlsx document and past in the next line (23)
#Residential Networks
#loop through networks
for network in networks:
network_id = network['id']
id_21 = '21'
id_22 = '22'
id_41 = '41'
id_42 = '42'
id_47 = '47'
id_48 = '48'
id_61 = '61'
id_111 = '111'
id_333 = '333'
try:
PutNewVLAN= dashboard.appliance.createNetworkApplianceVlan(
network_id, id_21,
name='Access Control',
subnet='10.10.10.0/26',
applianceIp='10.10.10.1',
cidr='10.10.10.0/26',
mask=28,
ipv6={'enabled': False},
mandatoryDhcp={'enabled': False}
)
except Exception as e:
print(e)
continue
try:
PutNewVLAN= dashboard.appliance.createNetworkApplianceVlan(
network_id, id_22,
name='Critical Devices',
subnet='10.10.10.64/26',
applianceIp='10.10.10.65',
cidr='10.10.10.64/26',
mask=28,
ipv6={'enabled': False},
mandatoryDhcp={'enabled': False}
)
except Exception as e:
print(e)
continue
try:
PutNewVLAN= dashboard.appliance.createNetworkApplianceVlan(
network_id, id_41,
name='Limited Access',
subnet='10.10.10.128/26',
applianceIp='10.10.10.129',
cidr='10.10.10.128/26',
mask=28,
ipv6={'enabled': False},
mandatoryDhcp={'enabled': False}
)
except Exception as e:
print(e)
continue
try:
PutNewVLAN= dashboard.appliance.createNetworkApplianceVlan(
network_id, id_42,
name='Public Accessible',
subnet='10.10.10.192/26',
applianceIp='10.10.10.193',
cidr='10.10.10.192/26',
mask=28,
ipv6={'enabled': False},
mandatoryDhcp={'enabled': False}
)
except Exception as e:
print(e)
continue
try:
PutNewVLAN= dashboard.appliance.createNetworkApplianceVlan(
network_id, id_47,
name='Time Clock',
subnet='10.10.11.96/29',
applianceIp='10.10.11.97',
cidr='10.10.11.96/29',
mask=28,
ipv6={'enabled': False},
mandatoryDhcp={'enabled': False}
)
except Exception as e:
print(e)
continue
try:
PutNewVLAN= dashboard.appliance.createNetworkApplianceVlan(
network_id, id_48,
name='Public Printer',
subnet='10.10.11.104/29',
applianceIp='10.10.11.105',
cidr='10.10.11.104/29',
mask=28,
ipv6={'enabled': False},
mandatoryDhcp={'enabled': False}
)
except Exception as e:
print(e)
continue
try:
PutNewVLAN= dashboard.appliance.createNetworkApplianceVlan(
network_id, id_61,
name='NVR DVR',
subnet='10.10.11.112/28',
applianceIp='10.10.11.113',
cidr='10.10.11.112/28',
mask=28,
ipv6={'enabled': False},
mandatoryDhcp={'enabled': False}
)
except Exception as e:
print(e)
continue
try:
PutNewVLAN= dashboard.appliance.createNetworkApplianceVlan(
network_id, id_111,
name='Public DIA',
subnet='172.16.0.0/21',
applianceIp='172.16.0.1',
cidr='172.16.0.0/21',
mask=28,
ipv6={'enabled': False},
mandatoryDhcp={'enabled': False}
)
except Exception as e:
print(e)
continue
try:
PutNewVLAN= dashboard.appliance.createNetworkApplianceVlan(
network_id, id_333,
name='Management',
subnet='10.110.13.0/25',
applianceIp='10.110.13.1',
cidr='10.110.13.0/25',
mask=28,
ipv6={'enabled': False},
mandatoryDhcp={'enabled': False}
)
except Exception as e:
print(e)
continue
print(networkvlans)