cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
929
Views
10
Helpful
2
Replies

Automating SSID roleout with a Meraki/python Script

igonda
Level 1
Level 1

Hello community,
I Need your assistance with a Meraki, Python issue,

I’m not a python specialist and I really wonder if the solution is really that simple with Python.

 

Let’s say I have 100 networks and I want to enable SSID interface Nr. 2 with a specific VLAN Nr. (The WLAN configuration is not the issue here).

 

I want to use the below python script to read through a . txt or .CSV file and execute the command below for every network.

Networkid.txt
N_111111111111111111
N_111111111111111112
N_111111111111111113
N_111111111111111114
N_111111111111111115

 

Read a file with networkids, execute the Python - Request  “URL” with the variable Networkid and go for the  next Networkid.

 

url = "https://api.meraki.com/api/v1/networks/{networkId}/wireless/ssids/{number}"

url = "https://n123.meraki.com/api/v1/networks/networkid/appliance/ssids/2"


-------This Script works fine for a single Network-----

import meraki
import requests
dashboard = meraki.DashboardAPI()

url = "https://n123.meraki.com/api/v1/networks/N_111111111111111113/appliance/ssids/2"

payload = '''{
        "number": 2,
        "name": "Test_3333",
        "enabled": true,
        "defaultVlanId": 777,
        "authMode": "psk",
        "psk": "xtesty2022",
        "encryptionMode": "wpa",
        "wpaEncryptionMode": "WPA2 only",
        "visible": false

}'''

 

 

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "X-Cisco-Meraki-API-Key": "xxabcc7ff12344bababababa333334444"
}

response = requests.request('PUT', url, headers=headers, data = payload)
print(response.text.encode('utf8'))

 

Thank you in advance

Ishai

 

 

2 Replies 2

Alexander Stevenson
Cisco Employee
Cisco Employee

Hi @igonda,

Cool stuff.

The first thing I would do is import the network ids. I created a virtual environment and made two files in the same directory: one is 'network_ids.txt' and the other is 'meraki_script.py'

I installed numpy and now I can import from the text file into my Python script.

AlexStevenson_1-1671031563130.png

The same thing can be done with CSV, Excel file, etc. by changing it a little bit.

I looped through every network id by stating 'for network in data', but you can substitute any word for 'network' and Python will know what you mean.

Now, we can use an f-string to construct the URL based on our data:

AlexStevenson_3-1671032293282.png

I hope that helps!

 

igonda
Level 1
Level 1

Hi Alex,
your solution Looks Very interesting, thank you Very much, Ill comeback to you with the results.

I found in the meantime another solution.

I’m using the below API and Postman.

"https://n123.meraki.com/api/v1/networks/networkid/appliance/ssids/2

 

Which Works very good and very straight forward.

I'm still looking forward to implementing your solution. I’m sure it will be handy in the near future

Kind regards

Ishai