This script pulls the show run
output from a Cisco Catalyst Switch (using SSH), parses the SVIs, and configures those SVIs on a Meraki MS Switch.
Note:
This script skips any preexisting VLAN IDs configured on the MS.
In order to use the Meraki API, you need to enable the API for your organization first. After enabling API access, you can generate an API key. Follow these instructions to enable API access and generate an API key:
Organization > Settings > Dashboard API access
Enable access to the Cisco Meraki Dashboard API
My Profile > API access
Generate API key
For more information on how to generate an API key, please click here.
Note: You can add your account as Full Organization Admin to your organizations by following the instructions here.
git clone [repository name]
.env_sample
file to .env
. Rename config_sample.py
to config.py
..env
)API_KEY="" MS_SERIAL="XXXX-XXXX-XXXX"
.env
.SWITCH_IP="X.X.X.X" SWITCH_USERNAME="" SWITCH_PASSWORD="" SWITCH_SECRET=""
Note: Please ensure SSH is configured on the Catalyst Switch, as this is required for the Netmiko SSH connection. For more information on Netmiko, consult this guide.
config.py
DEFAULT_GATEWAY = "W.X.Y.Z" DHCP_SERVER = ["X.X.X.X", "Y.Y.Y.Y"]
Note:
Default Gateway
: The Default Gateway for the MS Switch must exist on exactly one imported SVI or be configured on the MS already. The default gateway serves as the destination for traffic if it can't be routed within or between SVI's on the MS Switch.DHCP Server
: A list of one or more DHCP Server IPs can be configured. If an SVI contains a ip helper-address [DHCP IP]
line, the DHCP Server IP will be configured as a relay on the MS SVI. Only DHCP relay is supported at this time.pip3 install -r requirements.txt
To run the program, use the command:
$ python3 create_meraki_svi.py
The script will connect to the Catalyst Switch:
Parse the SVI's from the Show Run
output:
Note: Secondary IPs are ignored!
Create the Default Gateway SVI (must be done first!):
Create the remaining SVIs:
On script completion, the MS > Routing and DHCP
section will now look like:
Provided under Cisco Sample Code License, for details see LICENSE
Our code of conduct is available here
See our contributing guidelines here
Please note: This script is meant for demo purposes only. All tools/ scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use.
You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment.
Owner
Contributors
Categories
Products
MerakiCatalyst SwitchesProgramming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community