Home > Storage > PowerStore > Databases and Data Analytics > Dell PowerStore: Oracle Best Practices > PowerStore REST API and CLI
PowerStore provides both a REST API and CLI interface which can be used for ad hoc and batched transactions or reporting in PowerStore. Batched processes provide a method that can be performed multiple times without introducing typographical errors between multiple executions. A use case for batched processes is the creation of a particular volume layout that needs to be the same between environments. Another use case is a batch process that generates a particular report across multiple environments.
The remainder of this section provides examples of using the REST API and PowerStore CLI interfaces.
PowerStore REST API can be accessed using several different methods:
PowerStore Swagger UI provides a quick way to process a transaction or query in PowerStore without navigating through PowerStore Manager and its wizards. SwaggerUI also generates and displays the equivalent curl command and URL that can be used to process the request outside of SwaggerUI. Swagger UI also has a feature called Try It Out which provides you with a way to test the request.
To access the REST API through Swagger UI, open a supported web browser and enter the PowerStore management IP address followed by /swaggerui. For example:
https://<mgmt_IP_address>/swaggerui
Note: DNS names can be used when logging into swaggerui, but using the management IP address is preferred and recommended. If you use DNS names, swaggerui’s feature Try It Out will return an error. Try It Out requires swaggerui to be called with the management IP address.
After calling swaggerui, PowerStore prompts for the credentials of a PowerStore user.
After login, SwaggerUI displays a list of PowerStore resources (alert, appliance, audit_event, bond, chap_config, and so on) and associated REST API verbs (POST, GET, PATCH, and DELETE).
The remainder of this section shows the processing of a REST API GET against the PowerStore resource host.
Locate and click the PowerStore resource host. Optionally, use the query field Filter by tag field to help locate the resource (see Figure 16). Expand the resource and click GET that is associated with the resource (see Figure 17).
Click Try It Out to process the request.
Click Execute.
Swagger UI returns the collection of data for the request and places that data in the section Server Response (see Figure 21).
Swagger UI also returns the equivalent http URL and curl command to repeat this REST call from either a browser window or Linux session. See the information returned under the Curl and Request URL headers in Figure 21. You can also use these values as a template to enhance or expand the original REST call. For additional information about curl and direct URL web address, see the remainder of this section.
For additional information, see Dell PowerStore REST API Developers Guide and Dell PowerStore REST API Reference Guide.
Direct http URLs can be constructed for ad hoc transactions and saved as bookmarks. The URL for the direct https calls can either be created manually or generated by Swagger UI and then enhanced if needed. Swagger UI places the autogenerated URI in field Request URL (see Figure 22).
The following two examples show how to modify and run the Request URL value.
In the first example, the {id} value of a host must be known. See the field Request URL in Figure 22. The Request URL is then manually enhanced with the parameter select to return only the id, name, and os_type attributes of the host having the specified ID (Figure 23).
The second example enhances the original URL with the parameters select and order to display the id, name, and os_type attributes of all hosts. Then it sorts the output by host name (Figure 24).
In the above examples, additional attributes are in the select and order request parameters. Available attributes for use in the URL are found in Swagger UI or from the attributes shown by a call to PowerStore’s openapidev.json URL.
For a list of valid request parameters and additional syntax, see Dell PowerStore REST API Developers Guide and Dell PowerStore REST API Reference Guide. You can also use Swagger UI and openapi.json to determine this information.
To show the available attributes in Swagger UI, expand the resources in the Responses section (see Figure 25):
To show the available attributes reported by openapi.json, enter the following in a browser address:
https://<management-ip>/api/rest/openapi.json
Expand definitions: then search for the resource shown in Swagger UI (Figure 25). When the resource is located, expand it. Then, expand properties: to display the attributes of the resource.
The resource attributes appear (Figure 27).
For additional information about PowerStore REST API URLs or openapi.json, see Dell PowerStore REST API Developers Guide and Dell PowerStore REST API Reference Guide.
The curl command can be used in Linux to perform transactions against PowerStore without the use of PowerStore Manager. A good use case for curl or PowerStore CLI is for batch processing on repetitive tasks or reporting on PowerStore configuration.
To use curl, the Linux curl package must be installed.
Make sure the following three required http headers are defined on the call to curl:
Headers Accept: and Content-type: have the value application/json.
Accept: application/json
Content-type: application/json
The value of the third header (DELL-EMC-TOKEN) is generated by PowerStore when making the initial login_session request to PowerStore (note the red box in Figure 29).
When making the login request, specify the first two headers in the curl command and use switches -k and -s. For the URL address, use the Management IP and port 443 of PowerStore. For example:
curl -k -s -X GET \
-H "Accept: application/json" \
-H "Content-type: application/json" \
-u admin -verbose \
-L https://xxx.xxx.xxx.xxx:443/api/rest/login_session
Note: Headers and header values are case-sensitive.
After generating the DELL-EMC-TOKEN value, use curl to process a REST API request. Include the switches, three headers, the REST verb, and the PowerStore resource in the request.
The following example displays information about the PowerStore nodes.
If curl will be used multiple times in a Linux session or in a batch file, consider making some improvements in how curl calls the PowerStore REST API.
Every time curl calls the PowerStore REST API, PowerStore prompts for the password of the user specified with the -u switch. To eliminate this password prompt, consider parameterizing the password with an environment variable. Also, every call to the REST API from curl must include the http headers. To eliminate the possibility of introducing mistakes when specifying the http headers, define a Linux alias for curl and specify the headers in the alias. Then use the alias to call curl.
Note: Do not delineate the password with apostrophes or double quotes even if it contains special characters. Specify only the password value. For example: export PSTPASS=yourpassword123!
If the output from curl must be in json format, pipe the output to json_reformat.
For additional information about SwaggerUI, openapi.json, curl, and PowerStore REST API, see:
PowerStore Manager CLI provides a way to automate transactions interactively in Linux without the use of PowerStore Manager. Several use cases for using the CLI interface are:
The remainder of this section provides a simple example of how the PowerStore Manager CLI can be used to provision and unprovision storage for Oracle.
To use PowerStore Manager CLI, download the pstcli package from Dell’s support web site and install it. This example shows pstcli being installed in Linux.
After pstcli is installed, run it, and optionally accept the certificate received from PowerStore. The following example returns the id of host r730xd-2. Switch -d specifies the Management IP of the PowerStore array that will process the request. Switches -u and -p specify the credentials of the PowerStore user that will process the request. Also, because no certificate exists for pstcli on the host r730xd-2, an option is displayed to accept and install the certificate.
If the certificate is accepted with option 3 (see Figure 34), the certificate prompt will not be displayed on future pstcli calls (see Figure 35).
The following example shows:
For additional information about the PowerStore Manager CLI, including command options, see: