cancel
Showing results for 
Search instead for 
Did you mean: 

Update multiple devices in different networks

SOLVED
Highlighted
Conversationalist

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Building a reputation

Re: Update multiple devices in different networks

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.

11 REPLIES 11
Here to help

Re: Update multiple devices in different networks

so digging into the that call, it looks like you can. the help(meraki) shows ``` updatedevice(apikey, networkid, serial, name=None, tags=None, lat=None, lng=None, address=None, move=None, suppressprint=False) # Update the attributes of a device # https://api.meraki.com/api_docs#update-the-attributes-of-a-device ``` if you click on the link to the API documentation, you can see what the call looks like to update the tags. keep in mind that you are updating per device, per network ``` updatedevice(apikey, networkid, serial, name=None, tags=None, lat=None, lng=None, address=None, move=None, suppressprint=False) ```
Building a reputation

Re: Update multiple devices in different networks

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.

Getting noticed

Re: Update multiple devices in different networks

Hey Conway,
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.
Conversationalist

Re: Update multiple devices in different networks

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

Getting noticed

Re: Update multiple devices in different networks

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.

 

 

Conversationalist

Re: Update multiple devices in different networks

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. 

Conversationalist

Re: Update multiple devices in different networks

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.

Getting noticed

Re: Update multiple devices in different networks

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]:Smiley FrustratedecurityProtocol = [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

 

Conversationalist

Re: Update multiple devices in different networks

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.

Getting noticed

Re: Update multiple devices in different networks

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.

Conversationalist

Re: Update multiple devices in different networks

think i'm good, thanks for your help. just playing around with the looping now.

Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.