- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Update multiple devices in different networks
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.
- Labels:
-
Dashboard API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I utilise the API in this maner and have been utilising it for a while making updates accross orgs and networks. IT might not be the cleanest way to acheive and i use Powershell to get and post information but the premise would be the same.
I extract all information against the Org using the networks url. Placing the results into a CSV.
https://api.meraki.com/api/v0/organizations/[organizationId]/networks
Using this list i then i extract device information into another csv looping the results in the network list to create a new one with devices
https://api.meraki.com/api/v0/networks/[networkId]/devices
You can then update this CV with information Tags/Address's/Address details/Notes (this is not shown on the doc but you get notes).
Then i would use this updated csv looping through posting the details and setting the url with varibles from that https://api.meraki.com/api/v0/networks/[networkId]/devices/[serial]
Let me know if you need more information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
think i'm good, thanks for your help. just playing around with the looping now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, would you be able to explain how you accomplished this? I am trying to update SSID settings (name, psk) across multiple networks (same settings everywhere) but not understanding how to build a collection for multiple updates to multiple networks. I have Postman installed and have successfully sent single PUT requests.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You will need to use the postman collection runner which will allow you to loop one of your single instances that you have tested already.
your case sounds similar where you want the same setting across multiple networks so should be pretty easy once you understand how postman wants you to set this up. It took me a while as the documentation wasn’t very good at the time, but seems a bit better now.
https://blog.getpostman.com/2018/04/11/looping-through-a-data-file-in-the-postman-collection-runner/
let me know if this link helps you or not, and if you need some more detail I can put something together to help.
also if you have google sheets access you can use the built in Meraki tools add on to help with API queries. Worth a look to see if there is anything useful in there too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, yes some extra detail would be great. I'm trying to use the PUT below to simply change the first SSID name across 2 different networks in a .csv. Am I correct that the csv should only include the 2 variables in the 1st image (networkId, number) and the body of the saved request called in the runner should have the static settings I want (ssid name)?
My .csv:
networkId | number |
L_XXXXXXXXXXXXXXX | 0 |
L_YYYYYYYYYYYYYYY | 0 |
This is what I get when I try to run the collection:
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
You csv if you open in notepad should read like this;
networkid,number
Nxxxxxxxx,0
Nxxxxxxxx,0
If you are sure that the SSID is always ID 0 then you could just hard-code this in the command, so you would only need to have the list of network ids in your csv.
the reason it's failing is because the put statement requires the variables, whereas you have them in the path variables section. it should read:
https://api.meraki.com/api/v0/networks/{{networkId}}/ssids/{{number}}
if you delete where it says :networkid and type {{networkid}} you'll see the path variable disappear from the params section. then either repeat for the :number or set this value to 0 if your ssid is always 0.
hope this helps.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That makes sense, but somehow still cant get it to work. I have statically set 0 as the ssid number, so I only have the networkId to deal with in the csv. When I run the collection, I get a 404 error (I am selecting the same Env that I use for individual requests)
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would delete the path variable ’number’ completely, and either have this
https://api.meraki.com/api/v0/networks/{{networkId}}/ssids/{{number}}
with your csv having the ssid number, or use this
https://api.meraki.com/api/v0/networks/{{networkId}}/ssids/0
404 is page not found so it’s the syntax of the command not enumerating to a valid page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Strange, still getting the 404 error, I've gone with https://api.meraki.com/api/v0/networks/{{networkId}}/ssids/0 , but no luck (I tried the other method with {{number}} as well).
It looks like the csv data is not getting passed through to the variable.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Success! Not sure why exactly, but my computer crashed and when I reopened excel and imported/resaved the csv, my collection ran successfully. Thank you very much @5ghz!
