Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

自動化ツール

概要 このトピックでは、Juniper MistTMで使用できるいくつかの自動化ツールについて説明します。以下で説明するツールについては推奨しません。情報と例は、情報提供のみを目的として提供しています。

自動化ツールの概要

Juniper Mist GUI全体は、堅牢なMist™ API上に構築されています。このアーキテクチャにより、Mist 管理の高度なカスタマイズ性、柔軟性、拡張性を実現しています。自動化ツールを使用して、GUI では使用できないタスクまたはタスクのグループを実行できます。

自動化は、実行するタスクを特定して理解することから始まります。ほとんどの自動化ツールは、マシン間のトランザクション用に設計されています。この設計のため、自動化ツールは、人間が必ずしも直感的に理解して構成できるとは限りません。ありがたいことに、マシンベースのインターフェイスと対話したり、独自の自動化スクリプトを作成したりするのに役立つ多くのツールが存在します。Juniper Mist APIはまさにそのようなツールです。

Postman

Postman is a tool to help you automate Juniper Mist management tasks. Postman can do many things, but you will use it as an API client. According to the Postman web site (www.postman.com), the Postman API client is the foundational tool of Postman. This client enables you to easily explore, debug, and test your APIs while also enabling you to define complex API requests for HTTP, REST, SOAP, GraphQL, and WebSockets.

Postman provides its own API GUI client to interact with a REST API interface, and many others. Postman allows users to set up reusable environments and use variables for consistency and efficiency when testing. You can visually organize each individual request into an order, inspect and store responses for reuse, and even have Postman help generate programmatic code such as Python.

Here is a short video on using variables in Postman to interact with the Juniper Mist API.

Postman is an excellent development tool. You can use it to test individual configuration changes and then put them together into collections. This video is an excellent example of using Postman and a web browser to put together API requests to configure 802.1x in a switching template.

With the popularity of Postman, Juniper developers have published collections in the public Postman workspaces. Collections are a method of organizing API requests and documentation into groups. You can import, export, and share collections.

Here is a short video demonstrating the use of Postman collections and the Juniper Mist API.

The Postman collections incorporate many Juniper Mist capabilities. They also include collections for gathering client information, Mist Edge devices, switching, software-defined WAN (SD-WAN), and many other objects. You can find these collections, which include the Juniper Mist cloud APIs, Mist cloud WebSocket, and Mist Runner Collections, from this link: https://www.postman.com/juniper-mist/workspace/mist-systems-s-public-workspace.

Python

Python is an object-oriented programming language. It’s a popular language for many reasons. One reason is that Python is highly flexible and extensible. Compared to other programming languages, it is easy to learn and work with. Python is used for web development, data sciences, networking, and the Internet of Things (IoT), to name a few uses. It is open source and works on multiple platforms.

For more information about getting started with Python, check out the Python Software Foundation at https://www.python.org/about/gettingstarted/.

Juniper Networks supports Python use in many forms, such as direct script execution and toolkit scripts: https://www.juniper.net/documentation/us/en/software/junos/automation-scripting/topics/concept/junos-script-automation-python-scripts-overview.html

Python Script Examples

Leveraging the robust API library in Juniper Mist, you can automate tasks using Python. In this section, you will see some simple Python scripts that make a series of calls to the Mist API to gather information or make changes to Mist.

These scripts are meant to serve only as examples and may or may not work in your environment due to possible variances in your environment.

Display WLANs on a Specific Site

This is a simple example script that connects to the Mist API and displays all the wireless LANs (WLANs) for a specific site:

Comparing RSSI (Windows)

You execute this Python script on a Windows laptop. The script gathers the current signal quality percentage, not received signal strength indicator (RSSI), from a Windows laptop. The script then gets the RSSI from the access point (AP) to which the laptop is connected by parsing for the wireless adapter’s MAC. The script makes these requests simultaneously and displays the client’s signal quality on the same line as the AP’s RSSI. The script runs until you send a Ctrl+ccommand from your keyboard to break out of the script execution.

The script makes use of the netsh wlan show interface Windows command. This is the command’s output:

This is the script itself:

When you run the python script, the resulting output should look like this:

The Juniper Mist AP reports its statistics approximately every 60 seconds. This is the reason the AP RSSI only changed twice during the time the script was running.

Comparing RSSI (MacOS)

This Python script is executed on a MacBook laptop. It is nearly identical to the previous Windows script. The script simultaneously gathers the RSSI from the MacBook and gets the RSSI from the AP to which the laptop is connected by parsing for the wireless adapter’s MAC address. It makes these requests simultaneously and displays the client’s signal quality on the same line as the AP’s RSSI. The script runs until you send a Ctrl+c command to break out of the script execution. To access the command on the Mac OS, you must include the absolute path to the command: /SystemLibrary/PrivateFrameworks/Apple802111.framework/Versions/A/Resources/airport -I.

This is what the airport -I command displays:

This is the script itself:

When the script runs, it gathers the RSSI information from the MacBook and the connected AP (through a Mist API call) and prints its output on a single line. The script runs until you cancel it by issuing the Ctrl+c command.

The Juniper Mist AP reports its statistics approximately every 60 seconds. This is why the AP RSSI changes only once in the example output.

Random Password Creation for a Guest Portal

When you configure a WLAN for a guest portal, use the Guest Portalconfiguration to define the landing page. This is the page for guests to log on to their wireless network. This configuration page enables you to gather information about guests such as their full names, e-mail addresses, and company details. You can add custom fields if you need users to gather additional types of information.

You can configure the guest portal to use an alphanumeric passphrase for authorization. This is a manual process, but you can automate it to run regularly, such as daily, to create a new random password that you distribute to guests each day.

This image shows the current configured passphrase for the guest portal:

Random Password Creation for a Guest Portal

Below is a Python script to create a new, random password for a guest portal. This script will send a PUTcommand to the API to change the passphrase.

This is the output from the script. It lists the wlan name and the wlan_iduntil it finds the mist_guest WLAN (defined in the script) and resets the passphrase with the newly generated, random passphrase:

You can verify the passphrase change by going back to the WLAN configuration, or WLAN template page, and checking the guest portal configuration. When you click Reveal, you will see the new passphrase.

Random Password Creation for a Guest Portal

自動化に関するその他のリソース

詳細と例については、次のリソースを参照してください。

表1:Juniper Mist自動化リソース
リソース の説明 それを見つける場所

Mist APIの可能性を示すPythonスクリプト。

https://github.com/tmunzer/mist_library

Mist APIを使用したPythonスクリプトの例。これらのスクリプトは、 mistapi 認証プロセスを簡素化するために Python パッケージを使用しています。 スクリプトの例を表示するには、:https://github.com/tmunzer/mist_library に移動してディレクトリを参照します scripts
MISTAPI - Mist APIを使用するためのPythonパッケージ 本パッケージは、Mist OpenAPI仕様に基づいて構築されており、PythonスクリプトでのMist APIの使用を簡素化するように設計されています。

パッケージの詳細については、次のページを参照してください。 https://pypi.org/project/mistapi/

Mist API Labs Juniper-Mist APIの可能性といくつかのユースケースを実証するために作成された概念実証およびプロトタイプアプリケーションとスクリプト。 移動先: Mist-Lab デモアプリ をクリックし、[ 検索 ] ボックスに 「Webhooks」と入力します。
Mist Postman Webhook のサンプル POST ウェブフック構文の構成例を示します。 ブラウズ:https://www.postman.com/juniper-mist/workspace/mist-systems-s-public-workspace