05-03-2018 01:54 PM
I'm attempting to update multiple access point's tags in multiple networks at the same time. I know you can do this in the dashboard as long as they are in the same network. But I'm trying to update the tags of multiple access points in different networks. I might be missing a way to do this via the dashboard but after looking through it and the documentation I can't seem to find a way.
I'm now trying to complete this using python and meraki's dashboard API. Would it be possible to get the inventory of an organization, then using that list to update the devices with new information? For example I'd use “meraki.getorginventory” to provide a list of AP’s to update when doing a “meraki.updatedevice”. Any and all assistance on this is greatly appreciated!
Solved! Go to Solution.
05-03-2018 04:07 PM
If you're trying to add a tag or modify the tag list, note that the inventory API does not include the current set of tags for each device.
If you update the device attributes (/networks/[networkId]/devices/[serial]), you will overwrite any existing tags. If that's okay with you, go for it. Otherwise, you will need to do a bit more work. Note that the tags parameter is a space-delimited set of tags.
Instead, you can call the inventory API to get the list of devices, then get the device attributes for each device, parse the tag list and make any necessary changes, and then update the device attributes. It's really not that bad, but does require a little more code.
One more thing, Meraki's APIs limit how quickly you can call them. If you're updating a lot of devices, make sure you throttle the requests. I think the official limit is 5 per second, although if I configure any higher than 3 per second, I get occasional failures.
05-03-2018 02:14 PM
05-03-2018 04:07 PM
If you're trying to add a tag or modify the tag list, note that the inventory API does not include the current set of tags for each device.
If you update the device attributes (/networks/[networkId]/devices/[serial]), you will overwrite any existing tags. If that's okay with you, go for it. Otherwise, you will need to do a bit more work. Note that the tags parameter is a space-delimited set of tags.
Instead, you can call the inventory API to get the list of devices, then get the device attributes for each device, parse the tag list and make any necessary changes, and then update the device attributes. It's really not that bad, but does require a little more code.
One more thing, Meraki's APIs limit how quickly you can call them. If you're updating a lot of devices, make sure you throttle the requests. I think the official limit is 5 per second, although if I configure any higher than 3 per second, I get occasional failures.
05-14-2018 05:20 AM
09-11-2019 04:19 AM
hi, could you provide some tech info on how to process these loops. i'm quite new to API and the programming and could use some pointers. i've use POSTMAN with some success on single queries but it's not clear on how to process mutliple /looped updates.
I need to update SNMP settings on over 400 networks
09-11-2019 04:43 AM
Hi 5ghz,
I don't think postman allow for multiple queries at the same time so your going to have to look at some programing language to achieve this. I perform it using windows powershell as it was available on my works machine and not locked down from use or needing any other software installing. My loops are ForEach statements to look at each org/network/device in an array.
get orgs > foreach org > get network > foreach network > get devices (or what ever information you are after)
Are your snmp settings going to be the same against all your networks or is there individual credentials for them. Also is this going to be published to every network you can see or only certain ones. As you could tackle them slightly different depending on that. Depending if you have to filter on certain sites and or have different information to publish to that list.
09-11-2019 05:13 AM
Meraki has some pretty detailed python scripts on their Github page. (https://github.com/meraki). Just like how MarkD_BT stated, you will need a loop statement to go through each network. If you need a further example, Meraki's script on this page (https://github.com/meraki/provisioning-lib/blob/master/python-3.5-api-module/sample-tagdevices.py) is how I solved my original problem. I was able to edit it to fit my needs and update all APs in my organization that contained a certain naming scheme.
09-11-2019 08:07 AM
thanks for this. I started looking at the powershell options and it does look like for my example it's probably the best path to follow. I'm not a programmer so there is a fair bit to digest.
09-11-2019 08:37 AM
Hey 5ghz,
Is it the same details against every network you use. I'm not a native programmer either but like tinkering happy to snap something together that will allow you to do your updates.
quick one just to show how to get all your networks against all your orgs
These utilise GET commands so only reading data not writing.
#### make sure powershell runs script as tls1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$apikey = "ENTER YOUR API KEY IN HERE"
$header = @{
"X-Cisco-Meraki-API-Key" = $apikey
"Content-Type" = 'application/json' }
## Define the tables for storing devices used later ##
$networklist_all = @()
$resourceOrgs = "https://api.meraki.com/api/v0/organizations"
$resultOrgs = Invoke-RestMethod -Uri $resourceOrgs -Method GET -Header $header
ForEach ($Org_Meraki in $resultOrgs) {
$FindOrgid = $Org_Meraki.id
$FindOrgName = $Org_Meraki.name
$GetNetworks = "https://api.meraki.com/api/v0/organizations/$FindOrgid/networks/"
Try {
$resultGetNetworks = Invoke-RestMethod -Uri $GetNetworks -Method GET -Headers $header
}
catch [System.Net.WebException] {
$Request = $_.Exception
Write-Warning "No Networks In This Organisation '$FindOrgName'"
Continue
}
$resultGetNetworksSorted = $resultGetNetworks | Sort-Object name
ForEach ($Network_Meraki in $resultGetNetworksSorted) {
$Selected_network = New-Object psobject
$Selected_network | Add-Member -MemberType NoteProperty -Name id -Value $Network_Meraki.id
$Selected_network | Add-Member -MemberType NoteProperty -Name name -Value $Network_Meraki.name
$Selected_network | Add-Member -MemberType NoteProperty -Name timeZone -Value $Network_Meraki.timeZone
$Selected_network | Add-Member -MemberType NoteProperty -Name tags -Value $Network_Meraki.tags
$Selected_network | Add-Member -MemberType NoteProperty -Name type -Value $Network_Meraki.type
$Selected_network | Add-Member -MemberType NoteProperty -Name disableMyMerakiCom -Value $Network_Meraki.disableMyMerakiCom
$Selected_network | Add-Member -MemberType NoteProperty -Name disableRemoteStatusPage -Value $Network_Meraki.disableRemoteStatusPage
$Selected_network | Add-Member -MemberType NoteProperty -Name OrgName -Value $FindOrgName
$networklist_all+=$Selected_network
}
}
$networklist_all
09-11-2019 02:45 PM
Hi MarkD_BT,
Yes settings will be the same across all networks. I had a go today and managed to get a list of all network ids into a variable, ready to be used in a for loop. I'll look at your code example too as it looks like I can learn a lot from this. Thanks so much for your help.
09-13-2019 01:58 AM
Hey 5ghz,
how you getting on with this any joy was busy most of yesterday but might be able to cobble something together quickly if it helps.
09-13-2019 06:26 AM
think i'm good, thanks for your help. just playing around with the looping now.
11-14-2019 03:30 AM
Hi,
are you able to still help with this request? i need to pull the network IDs out of the original script and then feed to an update / put script to update the same SNMP settings to every network.
11-27-2019 06:57 AM
Hi,
You still needing help with this i've not been online for a while and been busy but will have a bit time soon if your still needing some pointers.
12-03-2019 08:09 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide