Below should get you what you want for updating address, tags, etc. This scrip assumes you don't know your org Id and the network Id associated with each serial number. If you know that information, you can modify the script to suit your needs. To get your serial numbers into a list, you could read through a file and populate it that way also. The firewall rules would follow the same concept. import meraki apiKey = '123YourAPI_Key' # You could also use an environmental variable for this dashboard = meraki.DashboardAPI(api_key=apiKey) # You will have to get the serial numbers you want to modify into a list. devicesToModifyList = ['XXXX-XXXX-XXXX', 'XXXX-XXXX-XXXX'] # The address you want to update on the devices newAddress = '123 Any Street, Small Town USA' # The tags you want to update on the devices. They must be separated by a space. newTags = ' tag1 tag2 ' # This list will be populated with dictionaries of the network ID and serial number of the devices. serialAndNetworkIdList = list() print('Finding Org ID...') # You first have to find your Org ID. Replace 'Your Org Name' with whatever your org name is in the dashboard. # If you know your org Id, you can skip this part and set the orgId variable to it. try: myOrgs = dashboard.organizations.getOrganizations() except meraki.APIError as e: print( f'Meraki API error: {e}') except Exception as e: print(f'some other error: {e}') for orgs in myOrgs: if orgs['name'] == 'Your Org Name': orgId = orgs['id'] print('DONE!') # Pulls back all the devices that are assigned to a network in your org. This can take some time if you have many devices. # If you have many devices, it's recommended you use pagination. devices = dashboard.devices.getOrganizationDevices(orgId, total_pages = 'all') # This loops through all of the devices in your dashboard. If the serial number is in your devicesToModifyList, # it adds the network Id and serial number to the devicesToModifyDict. The devicesToModifyDict is then appended # to the serialAndNetworkIdList. for device in devices: devicesToModifyDict = dict() if device['serial'] in devicesToModifyList: devicesToModifyDict['networkId'] = device['networkId'] devicesToModifyDict['serial'] = device['serial'] serialAndNetworkIdList.append(devicesToModifyDict) # This loops through serialAndNetworkIdList to update the devices. You can add and remove things to the kwargs dictionary as needed. Check the API docs # for what you can add. for device in serialAndNetworkIdList: networkId = device['networkId'] serial = device['serial'] kwargs = { 'address': newAddress, 'moveMapMarker': True, 'tags': newTags } try: updateDevices = dashboard.devices.updateNetworkDevice(networkId, serial, **kwargs) print(updateDevices) except meraki.APIError as e: print( f'Meraki API error: {e}') continue except Exception as e: print(f'some other error: {e}') continue
... View more