Meraki Action Batcher is a Python-based GUI tool for creating, updating, verifying, deleting, and monitoring Meraki Action Batches. Action Batcher simplifies interaction with the Meraki Action Batch API so that you can focus on individual actions. This project is part of the Meraki ActionBatch Tools parent repo and can be used with the Meraki Action Composer complimentary tool.
In June 2019, Meraki announced Action Batches as a new way for making changes in bulk via the Meraki Dashboard API. The obvious benefit of Action Batches is a way to navigate the Dashboard API rate limit of 5 calls per second (per individual Dashboard Org). Depending on the requirements, authors of a given script or app sometimes had to navigate API with respective code (e.g. exponential backoff).
With Action Batches we now have a way to scale changes to many devices (and/or networks) with fewer API caveats.
From the Action Batch documentation:
Please review the Action Batch API documentation to understand Action Batches.
Meraki ActionBatcher requires Python 3.5 or greater. In addition to modules distributed with ActionBatcher, ActionBatcher depends on the Gooey and JSONMerge external packages. Both can be installed via the included requirements.txt file
Note: For Mac OSX, replace "python" with "python3" and for both platforms, make sure the output of python -v (or python3 -v) is 3.5 or greater.
1. Clone this repository locally
git clone https://github.com/zabrewer/Meraki-ActionBatcher.git
2. Create the virtual environment
python3 -m venv Meraki-ActionBatcher
3. Change to the Meraki-ActionBatcher directory
cd Meraki-ActionBatcher
4. Activate the virtual environment
For Windows
Scripts\activate.bat
For Mac
source bin/activate
5. Satisfy dependencies by installing external packages
pip install -r requirements.txt
6. Launch ActionBatcher while in virtual environment
python actionbatcher.py
To exit, close the ActionBatcher GUI window or cntrl+C at the command prompt. To deactivate the virtual environment:
For Windows
Scripts\deactivate.bat
For Mac
deactivate
(Coming Soon)
After an Action Batch has been confirmed, it CANNOT BE DELETED.
This tool can make mass changes to a production environment. Please make sure you understand the Meraki Dashboard and Meraki Action Batch APIs well before using this application. The license file provided with this software absolves all parties of issues, accidental or otherwise.
If you want to test most functions (except for create and update), you can do so in the Meraki developer sandbox which is Read-Only.
Before working with action batches, you must have an API Key and know the OrgID.
Most of the Action Batcher operations mirror the Action Batch API.
Operation | Description | Screenshot |
---|---|---|
Create Action Batch | Creates a new Action Batch for the given org | ![]() |
Update Action Batch | Updates an existing Action Batch | ![]() |
GetOrg Action Batch | Get all Action Batches for a given Org | ![]() |
Get Action Batch | Get the details of a single action batch | ![]() |
Action Batch Status | Get Action Batches that match a given criteria (Confirmed/Unconfirmed, Complete/Incomplete, Failed) | ![]() |
Delete Action Batches | Deletes an Action Batch (Unconfirmed status only) | ![]() |
Check Until Complete | Keep checking a given Action Batch until it is complete | ![]() |
Creates a new Action Batch for the given org
Back To Index | Back To Operations Overview
Updates an existing Action Batch
Back To Index | Back To Operations Overview
JSON output for all Action Batches for a given Dashboard Organization (Org ID)
Back To Index | Back To Operations Overview
Detailed JSON output for an individual Action Batch
Back To Index | Back To Operations Overview
Print a list of BatchIDs that match a given condition.
Back To Index | Back To Operations Overview
Delete an unconfirmed Action Batch
Back To Index | Back To Operations Overview
Check a confirmed Action Batch until it is complete
Back To Index | Back To Operations Overview
Note: I'm working on a tool to greatly reduce creating Action Batch JSON. I will post to this repo and the parent repo as soon as I have a version ready for testing.
Note 2: There are sample JSON actions that can be customized and used with Action Batcher in the /actions directory of this repo.. See the Actions README file for more details.
Note 3: Action Batcher checks for valid JSON files when creating an Action Batch - In addition to testing and working with JSON in code, there are multiple resources for linting (validating) JSON online including https://jsonviewer.io/tree, https://jsonlint.com/, and https://beautifier.io/.
The basic format for a Meraki Action Batch API request is as follows (where resource is the relative path to the URI resource and the ACTION BODY are the actions to be performed using the resource). Remember you can have multiple actions in a single action batch (up to 100 for asynchronous Action Batches and 20 for synchronous batches).
Note that the following is an example for demonstration and is not valid JSON.
{ "confirmed": true, "synchronous": true, "actions": [{ "resource": "/path/to/resource", "operation": "operation", "body": { ACTION BODY } }] }
The Action Batcher tool only expects the actions themselves. So a basic template JSON file for Action Batcher would be as follows (again, this is an example and not valid JSON):
{ "actions": [{ "resource": "/path/to/resource", "operation": "update", "body": { ACTION BODY } }] }
Let's take a basic example that adds a tag for a basic network device (this is valid JSON and would be accepted by Action Batcher once the {{NetworkID}} and {{DeviceID}} variables were changed to one that exists within the given Org):
{ "actions": [{ "resource": "/networks/{{NetworkID}}/devices/{{DeviceID}}", "operation": "update", "body": { "tags": "CoreSwitch" } }] }
A more complete example - the JSON for the actions used in the actionBatch-VlanUpdate.py example script on Cisco Devnet's documentation for Action Batches.
As per the documentation for the script: This will create a new VLAN on a Meraki MX Security Appliance. It will then update multiple switches with new tags. Finally, several ports will be updated to leverage the new VLAN settings.
You would need to replace the following with values for your vlan#, networkID, switchIDs, etc (the template engine I am working on will simplify this process):
vlan - vlan number
net_id - NetworkID for the network of both switches
switch_a - device ID for switch_a
switch_b - device ID for switch_b
tags - any tags to update the switches with
{ "actions": [{ "resource": "/networks/{{net_id}}/vlans", "operation": "create", "body": { "id": "{{vlan}}", "name": "API-VLAN", "applianceIp": "172.16.{{vlan}}.1", "subnet": "172.16.{{vlan}}.0/24" } }, { "resource": "/networks/{{net_id}}/devices/{{switch_a}}”, "operation": "update", "body": { "tags": "{{tags}}" } }, { "resource": "/networks/{{net_id}}/devices/{{switch_b}}”, "operation": "update", "body": { "tags": "{{tags}}" } }, { "resource": "/devices/{{switch_a}}/switchPorts/1", "operation": "update", "body": { "tags": "{{tags}}", "type": "access", "vlan": "{{vlan}}" } }, { "resource": "/devices/{{switch_b}}/switchPorts/1", "operation": "update", "body": { "tags": "{{tags}}", "type": "access", "vlan": "{{vlan}}" } } ] }
There is an empty config file called "defaults.json" in this repo. Config files take the following form:
{ "common": { "apikey": "", "orgid": "", "batchid": "", "prettyprint": "" }, "other": { "createactionbatch": { "json_actionfile_path": "", "confirm": false, "synchronous": false, "exportfile_path": "" }, "updateactionbatch": { "json_actionfile_path": "", "confirm": false, "synchronous": false, "exportfile_path": "" } } }
The sections should be self explanatory - "common" are common to all Action Batcher operations, while the "other" section is specific to specific operations.
If the config file is present, Action Batcher starts with the values pre-filled as defaults in the respective fields and checkboxes. They can always be overwritten while ActionBatcher is open but any new instances of ActionBatcher will use the defaults.json values when opened.
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community