An application that can configure the hostname of a Meraki device by obtaining neighbor information through CDP/LLDP and it parses output from the neighboring device using Genie/PyATS.
Clone the repository:
$ git clone <link>
(optional) Create a virtual environment and activate it (find instructions here)
Update the env_var.py
file. Note that the config
variable is a Python dictionary:
config = {}config['x_cisco_meraki_api_key'] = "" config['webex_teams_acces_token'] = "" config['webex_room_id'] = "" config['device_name_filter'] = "" config['device_username'] = "" config['device_password'] = "" config['port_number_to_uplink_switch'] = ""
x_cisco_meraki_api_key
is the Meraki API key. In the section below is explained how to generate this key.webex_teams_acces_token
is the Webex Bot token. In the section below is explained how to generate this token.webex_room_id
is the Room ID of the space that you would like to send the messages to. In the section below is explained how to obtain this ID.device_name_filter
is the device name that you would to target. For example, in this PoV, we target the models starting with MS120-8
.device_username
is the username of the uplink switch.device_password
is the password of the uplink switch.port_number_to_uplink_switch
is the port number on the Meraki/downlink device. The port is connected to the uplink switch. In this PoV, the uplink switch is always connected to port number 9 to the downlink switch.In a terminal, install the requirements with pip install -r requirements.txt
.
Run the flask application:
$ python app.py
Go to the following url:
https://localhost:5000/
Replace with appropriate name for below
Note: it is important that you have updated the
env_var.py
file with the right values before building the dockter container. Otherwise, you might encounter an error.
# To build image using docker docker build . -t <image-name># To run dockerized application locally docker run --rm --name gve-devnet-pyats-hostanme-app -p 5000:5000 <image-name>
In order to use the Cisco Meraki API, you have to enable the API for your organization first. After having enabled API access, you can generate an API key. You can follow the following instructions on how to enable API access and how to generate an API key:
Log in to the Cisco Meraki dashboard
In the left-hand menu, go to Organization > Settings > Dasbhoard API access
Click on Enable access to the Cisco Meraki Dashboard API
Go to Profile > API access
Under API access
, click on Generate API key
Save the API key in a safe place. Please note that the API key will be shown only once for security purposes. In case you lose the key, then you have to revoke the key and regenerate a new key. Moreover, there is a limit of only two API keys per profile.
For more information on how to generate an API key, please click here here
Note: Make sure this API key has write access to both the source and target organization. You can add your account as Full Organization Admin to both organizations by following the instructions here.
In order to send notifications to a Webex space, we have created a Webex Bot. Follow the following instructions to create a Webex bot and its token:
Log in to developer.webex.com
Click on your avatar and select My Webex Apps
Click Create a New App
Click Create a Bot
to start the wizard
Following the instructions of the wizard: fill in details such as the bot name, bot username and choose an icon
Click Add Bot
and you will be given access token
Copy the access token and store it safely. Please note that the API key will be shown only once for security purposes. In case you lose the key, then you have to revoke the key and regenerate a new key
For more information about Webex Bots and how to create one, please see the documentation.
You have to specify the Room ID of the Webex space and you have to add the Webex Bot to the room space as well.
In order to obtain the Room ID, you have to make a GET request to the following endpoint:
The response will be a list of JSON objects, which are the spaces that the user is part of. Find the space that you would like to send the notifications to and copy the Room ID.
For more information about how to obtain a Webex Room ID, please consult the following resource here.
In order to use pyATS, we have to create a testbed file, which contains the information on how to connect to the devices. The testbed file will include include the following elements:
An example testbed file has been provided in testbed_example.yaml
. If you want to read more on how to create a testbed file, then consult the documentation in the following link:
In order to parse CLI output, we use a parser called Genie. Genie integrates well with pyATS and it is agnostic by design. You can consult the documentation through the following link:
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.
We created a Flask application that can find all the devices on a certain Meraki network. Through a CDP/LLDP request, we can obtain the information about the neighbors. We connect with the neighboring device in order to obtain the hostname from its configuration and we use this hostname to configure the Meraki device.
Provide links to related white papers:
Provide a link to a related DevNet Sandbox:
Provide links to related Learning Labs or modules on DevNet:
Provide links to related solutions on DevNet Ecosystem Exchange:
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community