Usage examples in CURL

Several usage examples that are generated by using curl are provided for reference.

For usage examples made using the Python 3 language, see Getting started. For examples that use the Perl programming language, see RESTful API usage examples in Perl. The following usage examples do not include all actions that might be taken on system objects.

Each curl example takes the following form:
curl -k -X POST -H header_1 -H header_2... -d 
'JSON' https://system_ip:7443/rest/command/target

Where the following definitions apply:

  • POST is the only HTTPS method that the Spectrum Virtualize RESTful API supports.
  • Headers (header_1 ) are individually-specified HTTP headers (for example, Content-Type and X-Auth­Username).
  • -d is followed by JSON input (for example, '{"raid_level": "raid5"}').
  • system_ip is the IP address to which you are sending requests.
  • command is the RESTful API command to execute, equivalent to the CLI command.
  • target is the target object of commands, which includes any object IDs, names, and parameters.

Authentication

The following is an example of the correct procedure for authenticating. You authenticate by first producing an authentication token and then using that token in all future commands until the session ends. For more information on authentication, see Authentication overview and API management.
curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Username: 
superuser' -H 'X-Auth-Password: passw0rd' 
https://192.168.10.109:7443/rest/auth
This yields an authentication token that you use for all other commands.
{"token": "38823f60c758dca26f3eaa17dc4664964905a6f058ae2ec92e0f0b63fcf08a3e"}

Making an array

You can use commands only after authentication, including the command to make an array on the system. The following example demonstrates the use of the token in place of the authentication headers used in the authentication process.
curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: 
38823f60c758dca26f3eaa17dc4664964905a6f058ae2ec92e0f0b63fcf08a3e'
-d '{"level": "draid6", "drive": "6:7:8:9:10"}'
           https://192.168.10.109:7443/rest/mkarray/draid6grp

Changing array settings

The next example shows how to modify an array member's attributes to change member 24 for new drive 15 by using a distributed rebuild to a rebuild area:
curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: 
38823f60c758dca26f3eaa17dc4664964905a6f058ae2ec92e0f0b63fcf08a3e'
-d '{"member": "24", "newdrive": "15",
     "immediate": "0"}' https://192.168.10.109:7443/rest/charraymember

Removing the array

The final example shows how to remove an array MDisk from the storage pool. For more information on managing the array, see rmarray.

curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token:
 8b5de3ba52c19cc1b213c84a95213bc92733eb006d1f55a7351f3e36b6a2e2a0'
 -d '{"force": true, "mdisk" : 0}' https://mcr-fab3-cluster-21.stglab.manchester.uk.ibm.com:7443/rest/rmarray/0
CMMVC5860E The action failed because there were not enough extents in the storage pool.