Script to automate Meraki AP reboots on a schedule using an automation tool like CRON that can do multiple networks supplied in a networks.json file. The script expects the JSON configuration file path as the last command-line argument.
This script is based off the Meraki API documentation and the Script of DBMandrake on the MerakiTech Forums.
DBMandrake wrote a stand alone python script to do bulk AP reboots based on device tags, so that we can reboot either all AP's in the network, or AP's with a specific tag. It works with the current V1 API and current Meraki python module.
All the api calls were created using the Meraki API V1 Index at https://developer.cisco.com/meraki/api-v1/api-index/
- Meraki Dashboard access
- Meraki API key
- Meraki Network ID
- Meraki Organization ID
- Clone or download this repo
https://github.com/deawar/APReboot.git
- Install required packages
python3 -m pip install -r requirements.txt
- Rename sample_config.env and edit
.env
file as follow:
└── APReboot/
+ ├── .env
├── requirements.txt
├── sample.json
└── AutoAPReboot.py
- Edit the
sample_config.env
file and rename to.env
file, add the following variable:
#.env
---
apiKey = "Your_API_Key"
- Edit the
sample.json
file or thenetworks.json
file and add your network info:
[
{
"networkId": "L_networkId",
"organizationId": "organizationId1",
"orgName": "Name_of_Org_Houseing_APs_to_be_Rebooted",
"tags": ["<tag-name>"]
},
{
"networkId": "L_networkId2",
"organizationId": "organizationId2",
"orgName": "Name_of_Org_Houseing_APs_to_be_Rebooted",
"tags": ["<tag-name>"]
},
{
"networkId": "L_networkId3",
"organizationId": "organizationId3",
"orgName": "Name_of_Org_Houseing_APs_to_be_Rebooted",
"tags": ["<tag-name>"]
}
]
- If no JSON file is provided, or if it fails to load, an error is printed, and the script exits. Now you can run the code by using the following command:
python3 AutoAPReboot.py -ALL config.json
or
python AutoAPReboot.py networks.json
If you have added Tags to your AccessPoints then this will find them and report them in the inital output. Suggested format , where orgName is the name of the organization of the AP's you want to reboot. The output should be as followed:
$ python AutoAPReboot.py networks.json
Processing network '<orgName>' (Network ID: <networkId>)...
This script was written/copied by Dean Warren from DBMandrake. ChatGPT was used to make modifications but the original script was DBMandrake's.