10.6 Running Commands Remotely Using REST
In addition to running commands on a remote node through
exacli
, you can also run them using a URL to access a REST
endpoint.
Before using a URL to run commands on the remote node, you must create users, roles, and privileges, as described in Creating Users for Use with ExaCLI.
The format of the URL to run a command is:
https://remotenode:port/MS/RESTService/?cmd=command_to_run
If the remote node is a cell node, the port is 443. If the remote node is a database node, the port is 7879.
By default, the command results are formatted using plain text. To format
the results using XML, append &xml=true
to the URL. To format
the results using JSON, use &json=true
. For example:
https://remotenode:port/MS/RESTService/?cmd=command_to_run&json=true
When you submit the URL in a browser, the browser displays a warning about the certificate. If the warning is about a new certificate, the warning is usually acceptable. If the warning is about a changed certificate, you should make sure that the certificate is acceptable.
The browser then prompts for the user name and password. If you do not enter the correct password 5 times in succession, then the account is locked. You have to wait 30 minutes until you can try to log in again to the same account.
If you submit further requests in the same session, the browser will not display warnings about the certificate and will not prompt for user name and password, unless the session cookie has expired.
The following example runs the list dbserver detail
command:
https://dbnode:7879/MS/RESTService/?cmd=list+dbserver+detail
The following example runs the list cell detail
command:
https://cellnode:443/MS/RESTService/?cmd=list+cell+detail
You can also specify the URL in a RESTful format. For example:
https://cellnode:443/MS/RESTService/celldisk/list?where=size>1g
You can also run the URL using curl
. The steps are:
-
Download and store the server certificate.
( openssl s_client -showcerts -connect remote_node:port < /dev/null | openssl x509 -outform PEM > mycertfile.pem ) >& /dev/null
You need to do this only once.
curl
will not proceed unless you provide a valid certificate. -
Provide a user name and password.
curl -u username:password -c cookiejar --cacert mycertfile.pem 'https://remote_node:port /MS/RESTService/login'
-
Run the command.
Database node example:
curl -b cookiejar --cacert mycertfile.pem 'https://remote_node:port/MS/RESTService/?cmd=list+dbserver+detail'
Cell node example:
curl -b cookiejar --cacert mycertfile.pem 'https://remote_node:port/MS/RESTService/?cmd=list+cell+detail'
Parent topic: Using the ExaCLI Utility