Skip to main content

Discover and manage multiple devices using the REST API

The manageDevices.sh script, written in curl, discovers devices in your data center, and then manages all discovered devices using the first hub that discovered each device. This script calls two supportive scripts to illustrate the workflow.

  • portalAuth.sh – This script authenticates and authorizes the script to access your Lenovo XClarity One portal.

    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 user interface by clicking API keys on the context menu from the Settings view, clicking the Add icon (Add icon), and then following instructions in the wizard. For more information, see REST API authentication and authorization.

    This script prompts you for the following information. You can find this information on the API key details page.

    • Portal IP address or FQDN

    • Client ID

    • Client secret

  • discoverAndManage.sh – This script finds the managed hubs in your organization, starts a job to discover devices in your datacenter, and then manages all discovered devices using the first hub that discovered each device.

    This script prompts you for the server credentials (username and password).

This script uses jq for JSON processing. On Linux platform, this can be added from the specific Linux platform repository. For Windows, you run jp using the jplang/jp command line processor (see GitHub - jqlang/jp) or from gitbash (see How to run jq from gitbash in windows ).

The sample script files are available here: RESTScript-ManageDevices.zip.