Hi everyone !
Big user of Meraki for a few month, my organization started to become to big to only use the Web Interface.
So after my first API requests with postman, I am trying to add a lot of VLANS with one click ! It will be helpfull as all my new networks have the same IP addresses logic but I change one number as they are interconnected with a site-to-site VPN.
So the idea is to be able to create 100+ Vlans with one command.
I successfully managed to create one. It's quite simple but no way to create more in one shot.
Am I forced to script it ?
Here is my last idea, based on the format of the result from the GET vlans :
[
{
"id":54,
"networkId": "L_xxx",
"name": "testA",
"applianceIp": "10.4.54.254",
"subnet": "10.4.54.0/24",
"dnsNameservers": "upstream_dns"
},
{
"id":55,
"networkId": "L_xxx",
"name": "testB",
"applianceIp": "10.4.55.254",
"subnet": "10.4.55.0/24",
"dnsNameservers": "upstream_dns"
}
]
If anyone could help me or just tell me that there is no way and that I have to make a script, it will be very nice !
Have a nice day,
Solved! Go to solution.
Hi
What you want to do is not difficult if you have a basic understanding of coding. But quite difficult if you are not familiar with how to write code.
Fortunately, there are plenty of examples of programmes that use the desktop API to achieve similar tasks to that which you wish to to do in the situation you describe.
I'd suggest either working through a python 3 or node.js introductory course. As a learning and development environment (IDE) I find VS Code to be a great tool, it is cross platform so it functions on Windows, Macs and Linux machines, it is free and has useful debugging capabilities.
Alternatively, perhaps your organisation has people with appropriate coding/development skills whom you could explain the problem to and to show them where they can find the examples - Meraki Solutions is a good place to start looking.
Hi
What you want to do is not difficult if you have a basic understanding of coding. But quite difficult if you are not familiar with how to write code.
Fortunately, there are plenty of examples of programmes that use the desktop API to achieve similar tasks to that which you wish to to do in the situation you describe.
I'd suggest either working through a python 3 or node.js introductory course. As a learning and development environment (IDE) I find VS Code to be a great tool, it is cross platform so it functions on Windows, Macs and Linux machines, it is free and has useful debugging capabilities.
Alternatively, perhaps your organisation has people with appropriate coding/development skills whom you could explain the problem to and to show them where they can find the examples - Meraki Solutions is a good place to start looking.
@Mathias_Morning wrote:
Thanks for your answer. I wanted to be sure that there is no easiest way before starting to script. Long time not doing it but it's always nice to get back to programming so let's go 🙂
Have a nice day
If you are an old school programmer, you will find Python very "picky" and lacking physical delimiters, but it is worth persevering. Be sure to install python 3 not v2.
There are tools built into VS Code that help you not only create and debug programs, but to conform to the accepted pyhon style standards.
Python also has its own stylistic preferences. I have noticed that the developers at Cisco who write code that access the Dashboard API, and do the location analytics do take the trouble to write code that is what is known as "pythonesque". Such is life.
The same developers also use node.js and NodeRed. NodeRed is a tool I use a lot when working with non-programming engineers as it is graphical in nature and one joins up the data flows. I first used it for autonomous hydrofoil control, so it is powerful.
Thanks, I will have a look at all this. I found some really nice python scripts templates that I just have to modify a little bit.
Hi everyone,
I finally managed this issue by a simple bash script and it worked perfectly.
All you need is a CSV file with this format :
VLAN1,101,10.4.134.0/26,10.4.134.62
VLAN2,102,10.4.134.64/26,10.4.134.126
Which is Vlan_name,vlan_id,subnet,MX_IP
And then create a bash script with this code (admitting that your CSV file is in the same folder and named vlans.scv) :
#/bin/bash!
for enreg in `cat vlans.csv`
do
Vlan_name=`echo $enreg | awk -F"," '{ print $1 }'`
Vlan_id=`echo $enreg | awk -F"," '{ print $2 }'`
Vlan_subnet=`echo $enreg | awk -F"," '{ print $3 }'`
Mx_ip=`echo $enreg | awk -F"," '{ print $4 }'`
echo "Sending POST request for Vlan $Vlan_id : "
curl -L -H 'X-Cisco-Meraki-API-Key: <INSERT_YOUR_KEY_HERE>' -H 'Content-Type: application/json' -X POST --data-binary '{"id":"'$Vlan_id'","name":"'$Vlan_name'","applianceIp":"'$Mx_ip'","subnet":"'$Vlan_subnet'"}' 'https://dashboard.meraki.com/api/v0/networks/<INSERT_YOUR_NETWORK_ID_HERE>/vlans'
done
Then execute !
Hopes it can help someone 🙂