Discover and manage multiple devices using the REST API
This Python script automates the process of discovering and onboarding devices into XClarity One using REST APIs. It authenticates with the portal using client credentials, identifies a specified management hub, and triggers a discovery job for a list of device IP addresses. After discovery completes, it retrieves the discovered devices, securely encrypts server credentials, and initiates a management job to fully onboard and configure those devices. The script also handles token lifecycle management and continuously polls job status to ensure each step completes successfully.
The manage_devices.py script discovers devices in your data center and then manages all discovered devices using the first hub that discovered each device. This main script calls two supportive scripts to illustrate the workflow.
portal_auth.py – This script authenticates and authorizes the script to access your XClarity One portal.
TLS verification can be explicitly configured through command-line options. By default, secure HTTPS communication is enforced, but you can modify this behavior. This flexibility enables the script to operate in both strict security environments and testing scenarios with self-signed or non-standard certificates.- –insecure disables TLS certificate verification and suppresses related warnings.
- –cacert <path> uses the specified custom Certificate Authority file for trusted verification.
Before running this script, ensure that you have an API key, which is needed to generate the access token that is used for authentication. You can create an API key from the web interface by clicking API keys on the context menu from the Settings view, clicking the Add icon (
), and then following instructions in the wizard. For more information, see REST API authentication and authorization.The following parameters are passed as parameters in the main script. You can find this information on the API key details page in the web interface.
Portal IP address or FQDN
Client ID
Client secret
Secret_entity.py – This script securely encrypts device credentials.
The server credentials (username and password) are passed as parameters in the main script.