Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Renaming Access Points Use Case

At times, you and other wireless administrators need to rename Juniper Mist network access points (APs) at a specific site. Consistent naming helps provide order and consistency in network inventory documentation. For example, a site may physically move to a new location and take on a new naming convention.

To perform this renaming task, in the Juniper Mist portal you can perform a bulk renaming action using a regular expression. This option is easy and readily available, but it can become complex if you have many devices to rename.

Another option is to create a Python script to rename the APs. This option simplifies the task of renaming many devices. The example script below illustrates the Python script renaming sequence. The script renames specific APs that have already been claimed to a site. The script uses three files, as follows:

  • The first file (config.json) contains the configuration variables.

  • The second file (ap-names.csv) is a CSV file that contains the MAC address of the AP to be renamed as well as the AP’s new name.

  • The third file (main-rename-ap.py) is the Python script itself, which takes information from the other two files.

To use the script, you place all three files in the same working directory.

The first file, which contains the JavaScript Object Notation (JSON) formatted configuration, includes variables needed to connect to the API to make the required calls to find and rename the specified APs.

Note:

In place of <api-endpoint>, use the API endpoint for your global region. See API Endpoints and Global Regions.

The Python script uses the contents of the CSV file to identify the AP (by the MAC address) and then rename it to the new name ap-names.csv.

By default, when you initially claim an AP, the AP takes the name of its own MAC address. The main Python script does the actual work of finding and renaming of the AP, which consists of the following functions:

  1. (def)—Get the MAC address of the AP to rename.

  2. Find the AP on the site.

  3. Rename the AP.

The main function (def) uses the other functions to complete the task and loops, as necessary.

This is what the main-rename-ap.py script looks like:

To run the script, call the main-rename-ap.py script and provide the config.json filename and the ap-names.csv filename as arguments. For example:

After you run the script, the output should look something like this:

You can also check the Juniper Mist portal and verify the changes by checking the device’s inventory. Automation is not limited to RESTful APIs and Python. You can find other automation options such as WebSocket and webhook API usage and tools to help in the development process.