Difference between revisions of "+ Developer Guide Overview"

From OSNEXUS Online Documentation Site
Jump to: navigation, search
m (Python Integration)
m (Archived Versions)
 
(127 intermediate revisions by the same user not shown)
Line 1: Line 1:
QuantaStor was designed from the ground up so that you can develop your own applications to remotely manage your storage systemsThat said, if all you need is a simple script to do some provisioning then you should be able to do everything you need just with the QuantaStor Remote Management CLI.  The CLI is completely scriptable and has an xml output mode (--xml) so the output is easy to parse with any scripting language. 
+
[[Category:dev_guide]]
For more advanced integrations we recommend using the QuantaStor WebServices interface directlyThis interface allows you to communicate with the storage system using .NET on Windows and via various SOAP implementations on all platforms.
+
== Overview ==
 +
QuantaStor was designed from the start with a service oriented architecture so that all aspects of system, cluster, and storage grid configuration may be automatedThere are multiple ways to automate QuantaStor management operations including the REST API, CLI, Ansible modules, and SOAP.  The Developer Guide focuses on integration with QuantaStor via the REST APIs.   
  
The QuantaStor Manager web interface and QuantaStor Remote Management CLI both manage the QuantaStor storage system via the QuantaStor WebServices / SOAP interface.  A copy of the WebServices interface for QuantaStor is included with the SDK and is also included with every QuantaStor system and can be accessed via your web browser by simply entering this URL:
+
== Supported Languages ==
<pre>
+
You can use just about any programming language you like to communicate with QuantaStor via our RESTful API. Recommended tools:
https://<QuantaStor-system-IP-address>:5151/osn.wsdl
+
</pre>
+
For example, if your QuantaStor storage system has an IP address of 192.168.0.88, then you can access the WSDL [[http://www.w3.org/TR/wsdl|(Web Services Definition Language)]] file using this URL:
+
<pre>
+
https://192.168.0.88:5151/osn.wsdl
+
</pre>
+
  
In case you don't have a system handy, you can browse this [[osn_wsdl|copy]] but note you'll want to use the most recent version included with the [[http://www.osnexus.com/downloads SDK]] which is available from the downloads page.
+
* C/C++ - [http://curl.haxx.se/libcurl/ libcurl]
 +
* Python - [http://pypi.python.org/pypi/pycurl PyCurl]
 +
* Unix/Linux/VMware/XenServer scripting - [http://curl.haxx.se/docs/httpscripting.html curl]
 +
* PHP - [http://php.net/manual/en/book.curl.php curl]
  
== What's in the SDK ==
+
== Browser Tools ==
  
The SDK includes a sample C# application that allows you to list and provision volumes in a storage system, some getting started documentation, the QuantaStor API/WSDL file, and a storage system simulator.
+
We highly recommend installing a tool like [http://jsonview.com/ JSONView] or other similar browser tool so that you can view the JSON output from the various API calls in an easy to read format.  When experimenting with various APIs you can then use your browser to call the API, see the results, and plan for how to integrate it into your script or application.
  
The QuantaStor Storage System Simulator runs on any Windows box and is installed automatically when you install the SDK package.  You can run it from the Start menu in windows or you can run it on the command line with these arguments ''qs_service.exe --debug'' and it's up and running.  From there you can manage the simulated storage system using the ''qs'' CLI or via your custom WebServices client application.
+
== Examples ==
  
== Supported Language / WebServices Compiler ==
+
Here's are some examples of how to enumerate various objects using the RESTful API and the curl utility:
  
* C++ (all platforms) / gSOAP 2.7.x
+
<pre>
* Java (all platforms) / Apache Axis 1.4
+
curl -u admin:password https://192.168.0.116:8153/qstorapi/hostEnum -k
* Microsoft C# (Windows) / Microsoft VS WSDL Compiler
+
curl -u admin:password https://192.168.0.116:8153/qstorapi/storageVolumeEnum -k
* Microsoft VB (Windows) / Microsoft VS WSDL Compiler
+
curl -u admin:password https://192.168.0.116:8153/qstorapi/storageSystemGet -k
 +
curl -u admin:password https://192.168.0.116:8153/qstorapi/storagePoolEnum -k
 +
curl -u admin:password https://192.168.0.116:8153/qstorapi/userEnum -k
 +
curl -u admin:password https://192.168.0.116:8153/qstorapi/networkShareEnum -k
 +
</pre>
  
There are other languages such as Python, Perl, PHP, and others that all have WebServices/SOAP implementations and should work fine with QuantaStor but we have as of yet not tested these out.
+
One quick way to test is to just enter one of these URLs (https://192.168.0.116:8153/qstorapi/hostEnum) into your web browser which will work as long as your system admin account is still using the default password.  Pretty much every known language has a curl type library/module for it so the above technique will work everywhere, you just need to get up to speed with your preferred language's curl API mechanism.
(Note: QuantaStor storage systems utilize gSOAP and Axis internally)
+
  
== Python Integration ==
+
Note you can even access APIs using wget which in this example will store the results into a file called hostEnum:
 +
<pre>
 +
wget --no-check-certificate https://192.168.0.135:8153/qstorapi/hostEnum
 +
</pre>
  
Python support is provided via the ZSI WebServices compiler.  You can install and build the QuantaStor WSDL file for Python like so:
+
=== Passing Args as a File ===
 +
 
 +
You can also call one of our RESTful APIs by passing a file instead of command line arguments. To do this your command will look something like this:
  
 
<pre>
 
<pre>
sudo -i
+
curl -k -u admin:password -d @file.json  https://192.168.0.116:8153/qstorapi/jsonrpc
apt-get update
+
apt-get install python-dev
+
wget http://iweb.dl.sourceforge.net/project/pywebsvcs/ZSI/ZSI-2.1_a1/ZSI-2.1-a1.tar.gz
+
cd ZSI-2.0
+
./setup.py build
+
./setup.py install
+
wget http://www.osnexus.com/storage/sdk/osn.wsdl
+
wsdl2py.py osn.wsdl
+
 
</pre>
 
</pre>
  
At this point you will have two files a [http://www.osnexus.com/storage/sdk/Service_client.py Service_client.py] and a [http://www.osnexus.com/storage/sdk/Service_types.py Service_types.py] file which you can now use in your python programs to call into the QuantaStor service interface.
+
An example of how the file should be formatted looks like this:
 +
<pre>
 +
{
 +
    "method": "echo",
 +
    "params": {
 +
        "inputMessage": "Message"
 +
    }
 +
}
 +
</pre>
  
== PHP Integration ==
+
The format being used is JSON. You specify the command you would like to call using the key "method". Then the parameters are passed in using the key "params". If more than one parameter is specified, separate them with a comma.
  
You can integrate QuantaStor with your web services via PHP using our SOAP/WebServices interface as well.  First you'll want to download and install the PHP wsdl compiler [http://sourceforge.net/projects/wsdl2php/ wsdl2php].  Here's the series of commands to run to install this on an Ubuntu machine, this will vary a bit depending on your linux distro and you'll want to check the wsdl2php web site on sourceforge for the latest version of the compiler.
+
<pre>
 +
{
 +
    "method": "command",
 +
    "params": {
 +
        "param1": "<value1>",
 +
        "param2": "<value2>",
 +
        "param3": "<value3>"
 +
    }
 +
}
 +
</pre>
  
 +
== Reflection ==
 +
The RESTful API has basic support for reflection, meaning that you can learn about all the arguments for a given API just by calling it with the 'help' parameter like so:
 
<pre>
 
<pre>
sudo -i
+
curl -k -u admin:password https://192.168.0.116:8153/qstorapi/hostAdd?help
apt-get update
+
apt-get install php5-cli php-pear
+
wget http://superb-sea2.dl.sourceforge.net/project/wsdl2php/wsdl2php/wsdl2php-0.2.1-pear/wsdl2php-0.2.1-pear.tgz
+
pear install wsdl2php-0.2.1-pear.tgz
+
wget http://www.osnexus.com/storage/sdk/osn.wsdl
+
wsdl2php osn.wsdl
+
 
</pre>
 
</pre>
  
Now that you have wsdl2php installed you can compile the osn.wsdl file that is distributed with QuantaStor. Then end result will be a file called Service.php which you can find an example of here: [http://www.osnexus.com/storage/sdk/Service.php Service.php] This links to a PHP service file built using the QuantaStor v1.5 WSDL which can be found here:  
+
== Calling APIs with Parameters ==
[http://www.osnexus.com/storage/sdk/osn.wsdl osn.wsdl]
+
To call an API with parameters you'll need to add a & between each parameter you specify and a ? between the API name and the start of the parameters like so:
 +
<pre>
 +
curl -k -u admin:password "https://192.168.0.116:8153/qstorapi/hostAdd?iqn=iqn.1991-05.com.microsoft:osn-mediaserver3&hostname=mediaserver3&flags=0"
 +
</pre>
 +
Which will return JSON output like this (note the quotes so that the ampersand is not interpreted by the shell). Also note that sometimes it can be hard to read the JSON output so we recommend using a [http://jsonviewer.stack.hu/ JSON Formatter] when you're developing your integration code.
 +
<pre>
 +
{
 +
  "task":{
 +
      "i18nDescription":{
 +
        "messageText":null,
 +
        "messageId":null
 +
      },
 +
      "operation":"add",
 +
      "id":"ca54a531-6386-a4f7-b9de-30f505329bb1",
 +
      "objectType":"Host",
 +
      "finishTimeStamp":"1969-12-31 16:00:00",
 +
      "isRemote":false,
 +
      "createdTimeStamp":"2012-08-23 21:53:40",
 +
      "state":0,
 +
      "acls":[
 +
        {
 +
            "reserved":0,
 +
            "objectId":"ca54a531-6386-a4f7-b9de-30f505329bb1",
 +
            "ownerType":23,
 +
            "ownerId":"252d4786-b19f-ae43-1ff6-453bee8a652e",
 +
            "accessLevel":2,
 +
            "objectType":16
 +
        }
 +
      ],
 +
      "clientIpAddress":"127.0.0.1",
 +
      "parentId":null,
 +
      "modifiedByUserId":null,
 +
      "progress":0,
 +
      "customId":null,
 +
      "type":16,
 +
      "description":"Adding host 'mediaserver3' to service with iSCSI initiator IQN 'iqn.1991-05.com.microsoft:osn-mediaserver3'.",
 +
      "errorMessage":{
 +
        "function":null,
 +
        "severity":0,
 +
        "errorCode":0,
 +
        "file":null,
 +
        "message":{
 +
            "messageText":null,
 +
            "messageId":null
 +
        },
 +
        "line":0
 +
      },
 +
      "modifiedTimeStamp":"1969-12-31 16:00:00",
 +
      "storageSystemId":"50ce62e6-6846-c5b3-d8a1-27061a696604",
 +
      "createdByUserId":"252d4786-b19f-ae43-1ff6-453bee8a652e",
 +
      "name":"Add Host",
 +
      "startTimeStamp":"2012-08-23 21:53:40",
 +
      "taskState":2
 +
  },
 +
  "obj":{
 +
      "username":null,
 +
      "storageSystemId":"50ce62e6-6846-c5b3-d8a1-27061a696604",
 +
      "isRemote":false,
 +
      "hostGroupId":null,
 +
      "name":"mediaserver3",
 +
      "ipAddress":null,
 +
      "createdByUserId":"252d4786-b19f-ae43-1ff6-453bee8a652e",
 +
      "modifiedTimeStamp":"1969-12-31 16:00:00",
 +
      "createdTimeStamp":"2012-08-23 21:53:40",
 +
      "state":0,
 +
      "hostOsType":0,
 +
      "initiatorPortList":[
 +
        {
 +
            "storageSystemId":"50ce62e6-6846-c5b3-d8a1-27061a696604",
 +
            "isRemote":false,
 +
            "hostId":"4fb8c2da-235a-18f9-2620-1d8aa5da89c5",
 +
            "name":"iqn.1991-05.com.microsoft:osn-mediaserver3",
 +
            "ipAddress":null,
 +
            "createdByUserId":"252d4786-b19f-ae43-1ff6-453bee8a652e",
 +
            "modifiedTimeStamp":"1969-12-31 16:00:00",
 +
            "createdTimeStamp":"2012-08-23 21:53:40",
 +
            "wwpn":null,
 +
            "state":0,
 +
            "iqn":"iqn.1991-05.com.microsoft:osn-mediaserver3",
 +
            "initiatorType":0,
 +
            "modifiedByUserId":null,
 +
            "customId":null,
 +
            "type":13,
 +
            "id":"535abed2-830a-a437-d6fd-5af7c5b5c263"
 +
        }
 +
      ],
 +
      "modifiedByUserId":null,
 +
      "customId":null,
 +
      "password":"********",
 +
      "type":11,
 +
      "id":"4fb8c2da-235a-18f9-2620-1d8aa5da89c5",
 +
      "description":"None"
 +
  }
 +
}
 +
</pre>
  
== C++ SDK System Requirements ==
+
== Async vs. Sync (blocking vs non-blocking) API calls ==
  
You need a Windows system to install the SDK but once you have the included WSDL file you can copy that to any system to do your development fromThe simulator only uses about 20M of RAM so you can run it on pretty much anything so the SDK system requirements are very minimal.  
+
All of the APIs for QuantaStor that modify the configuration in any way will start a task in the system.  If you call any API with the flags parameter set to 0 it'll be treated as a blocking call which wait for the task to complete before returning.  If you want to call the function and have it return immediately you can pass a 1 as the flags parameter which indicates to the server that the caller wants this to be an asynchronous non-blocking callWith asynchronous calls you'll get the task object back so that you can use the taskGet API to monitor the progress of the operation.  When the task completes it will populate the customId property of the task to contain the ID(s) of the objects which were created/deleted/modified by the task.
  
== Compiling the sample .NET application ==
+
== Task Monitoring ==
  
== Async vs. Sync API calls ==
+
As indicated above, sometimes you'll want to call an API asynchronously so that you can monitor the progress of the task and/or because you want to queue up multiple operations to run simultaneously. In such cases where you call an API asynchronously (flags=1) you can monitor the progress of the task using the tastGet API or the tastEnum API if you want to see all running tasks.  When the task is completed you can check the customId property to see the ID(s) of the objects created/modified.
  
== Task Monitoring ==
+
== API Error Code Definitions ==
 +
 
 +
For all APIs a 0 is returned for SUCCESS and a non-zero error code is returned if there is a command failure along with a description of the error.  Full list of error codes are available [[Error Codes | here]].
  
== Event Polling & Registration ==
+
== Security ==
  
== Custom Roles ==
+
QuantaStor REST interface always uses SSL via HTTPS.  You can change the pem keys on your system by replacing the qstorapi_server.pem file located in /opt/osnexus/quantastor/restsrv/ with your own.  If you want to use plain HTTP without SSL you can rename or remove the qstorapi_server.pem and the RESTful service will automatically fall back to using HTTP.  After removing the file just restart the RESTful service interface with:
 +
<pre>service restsrv restart</pre>
 +
If you want to block access to the restful interface you can stop the service and/or you can remove access to port 8153 by removing the entry associated with that port number from the /etc/init.d/iptables configuration file and then restart iptables like so:
 +
<pre>service iptables restart</pre>
 +
In a similar manner you can block access to the web management interface on port 80/8080.
  
 
== Supported SOAP / WebServices Implementations ==
 
== Supported SOAP / WebServices Implementations ==
Line 83: Line 194:
 
* Apache Axis (Java, all platforms)
 
* Apache Axis (Java, all platforms)
 
* .NET (C# & Visual Basic, Windows)
 
* .NET (C# & Visual Basic, Windows)
 +
 +
== API List ==
 +
The following represents the full API list for every API in QuantaStor.  Nothing is left out, if you can do it from the web management interface or the CLI, it's here.
 +
 +
=== Examples ===
 +
<pre>
 +
curl -u username:password -k https://hostname:8153/qstorapi/aclAdd?objectId=<id>&ownerType=<int>&ownerId=<id>&accessLevel=<int>&objectType=<int>
 +
 +
curl -u username:password -k https://hostname:8153/userAdd?username=tiger&password=passWORD1&firstName=Tiger&lastName=Woods&role=Administrator
 +
 +
curl -u username:password -k -d @data.json https://hostname:8153/qstorapi/jsonrpc
 +
 +
</pre>
 +
 +
==== Example Script ====
 +
Here is an example script in python. To use this example replace the ip address with your QuantaStor boxes ip.
 +
 +
<pre>
 +
 +
import json
 +
import subprocess
 +
 +
print "I am getting the storage system info..."
 +
#To get the data make an http request (such as a curl call)
 +
 +
proc = subprocess.Popen(["curl", "-k", "-u", "admin:password",
 +
        "https://192.168.0.142:8153/qstorapi/storageSystemGet?"], stdout=subprocess.PIPE)
 +
 +
(out, err) = proc.communicate()
 +
 +
print
 +
print "Here is what the returned data looks like when I get it:"
 +
print
 +
print str(out)
 +
print
 +
 +
#call json.loads to turn it into a python dictionary
 +
out = json.loads(out)
 +
print "Here is how to get a single field from the output:"
 +
print
 +
storageSystemId = out["id"]
 +
print storageSystemId
 +
 +
</pre>
 +
 +
== QuantaStor [[REST API Reference Guide]] ==
 +
All efforts are made to keep existing REST API from changing but on rare occasions API changes to existing APIs and objects may change.  As such the following sections document the APIs as per a specific released version of QuantaStor.  New versions of QuantaStor generally introduce some new APIs and object types but these are added in a backwards compatible fashion.
 +
 +
[[REST API Reference Guide|Current Version]]
 +
 +
=== Archived Versions ===
 +
 +
[[QuantaStor REST API Reference v5.2 ]]
 +
 +
[[QuantaStor REST API Reference v4.2, v4.1]]
 +
 +
[[QuantaStor REST API Reference v4.0 and earlier]]
 +
 +
== Enumeration Types ==
 +
 +
The enumeration types listed below are used with APIs noted above.  Many of the enumerations have assigned values like "OSN_CMN_FLAG_ASYNC            = 0x0001" but for those that do not have assigned values note that they are 0 indexed. 
 +
For example, OSN_CMN_ACCESSTYPE_READWRITE should be specified as 0 and OSN_CMN_ACCESSTYPE_READONLY specified as a 1 to the storageVolumeModify API as the accessMode for changing the configuration of a storage volume.
 +
 +
* [[REST_API_Reference_Guide#Enum_Definitions|QS API Enumerations v5.5]]
 +
 +
== Ansible Documentation ==
 +
 +
Currently, OsNexus does not package the python client or the Ansible modules with the QuantaStor installation package. Individual installation instructions can be found on GitHub (Ansible modules) and PyPi (qsclient).
 +
 +
[https://github.com/OSNEXUS/QSPyClient OSNEXUS Python client in Git: OSNEXUS QSPyClient]
 +
 +
[https://pypi.org/project/quantastor-qsclient OSNEXUS QuantaStor Python Client Library ]
 +
 +
[https://github.com/OSNEXUS/qsansible OSNEXUS Ansible Modules in Git: OSNEXUS qsansible]
 +
 +
For more information about QuantaStor Ansible automation,
 +
<br>checkout our blog post
 +
[https://blog.osnexus.com/2019/11/12/automating-storage-provisioning-using-ansible-with-quantastor Automating storage provisioning using Ansible with Quantastor.]

Latest revision as of 14:33, 11 April 2023

Overview

QuantaStor was designed from the start with a service oriented architecture so that all aspects of system, cluster, and storage grid configuration may be automated. There are multiple ways to automate QuantaStor management operations including the REST API, CLI, Ansible modules, and SOAP. The Developer Guide focuses on integration with QuantaStor via the REST APIs.

Supported Languages

You can use just about any programming language you like to communicate with QuantaStor via our RESTful API. Recommended tools:

Browser Tools

We highly recommend installing a tool like JSONView or other similar browser tool so that you can view the JSON output from the various API calls in an easy to read format. When experimenting with various APIs you can then use your browser to call the API, see the results, and plan for how to integrate it into your script or application.

Examples

Here's are some examples of how to enumerate various objects using the RESTful API and the curl utility:

curl -u admin:password https://192.168.0.116:8153/qstorapi/hostEnum -k
curl -u admin:password https://192.168.0.116:8153/qstorapi/storageVolumeEnum -k
curl -u admin:password https://192.168.0.116:8153/qstorapi/storageSystemGet -k
curl -u admin:password https://192.168.0.116:8153/qstorapi/storagePoolEnum -k
curl -u admin:password https://192.168.0.116:8153/qstorapi/userEnum -k
curl -u admin:password https://192.168.0.116:8153/qstorapi/networkShareEnum -k

One quick way to test is to just enter one of these URLs (https://192.168.0.116:8153/qstorapi/hostEnum) into your web browser which will work as long as your system admin account is still using the default password. Pretty much every known language has a curl type library/module for it so the above technique will work everywhere, you just need to get up to speed with your preferred language's curl API mechanism.

Note you can even access APIs using wget which in this example will store the results into a file called hostEnum:

wget --no-check-certificate https://192.168.0.135:8153/qstorapi/hostEnum

Passing Args as a File

You can also call one of our RESTful APIs by passing a file instead of command line arguments. To do this your command will look something like this:

curl -k -u admin:password -d @file.json  https://192.168.0.116:8153/qstorapi/jsonrpc

An example of how the file should be formatted looks like this:

{
    "method": "echo",
    "params": {
        "inputMessage": "Message"
    }
}

The format being used is JSON. You specify the command you would like to call using the key "method". Then the parameters are passed in using the key "params". If more than one parameter is specified, separate them with a comma.

{
    "method": "command",
    "params": {
        "param1": "<value1>",
        "param2": "<value2>",
        "param3": "<value3>"
    }
}

Reflection

The RESTful API has basic support for reflection, meaning that you can learn about all the arguments for a given API just by calling it with the 'help' parameter like so:

curl -k -u admin:password https://192.168.0.116:8153/qstorapi/hostAdd?help

Calling APIs with Parameters

To call an API with parameters you'll need to add a & between each parameter you specify and a ? between the API name and the start of the parameters like so:

curl -k -u admin:password "https://192.168.0.116:8153/qstorapi/hostAdd?iqn=iqn.1991-05.com.microsoft:osn-mediaserver3&hostname=mediaserver3&flags=0"

Which will return JSON output like this (note the quotes so that the ampersand is not interpreted by the shell). Also note that sometimes it can be hard to read the JSON output so we recommend using a JSON Formatter when you're developing your integration code.

{
   "task":{
      "i18nDescription":{
         "messageText":null,
         "messageId":null
      },
      "operation":"add",
      "id":"ca54a531-6386-a4f7-b9de-30f505329bb1",
      "objectType":"Host",
      "finishTimeStamp":"1969-12-31 16:00:00",
      "isRemote":false,
      "createdTimeStamp":"2012-08-23 21:53:40",
      "state":0,
      "acls":[
         {
            "reserved":0,
            "objectId":"ca54a531-6386-a4f7-b9de-30f505329bb1",
            "ownerType":23,
            "ownerId":"252d4786-b19f-ae43-1ff6-453bee8a652e",
            "accessLevel":2,
            "objectType":16
         }
      ],
      "clientIpAddress":"127.0.0.1",
      "parentId":null,
      "modifiedByUserId":null,
      "progress":0,
      "customId":null,
      "type":16,
      "description":"Adding host 'mediaserver3' to service with iSCSI initiator IQN 'iqn.1991-05.com.microsoft:osn-mediaserver3'.",
      "errorMessage":{
         "function":null,
         "severity":0,
         "errorCode":0,
         "file":null,
         "message":{
            "messageText":null,
            "messageId":null
         },
         "line":0
      },
      "modifiedTimeStamp":"1969-12-31 16:00:00",
      "storageSystemId":"50ce62e6-6846-c5b3-d8a1-27061a696604",
      "createdByUserId":"252d4786-b19f-ae43-1ff6-453bee8a652e",
      "name":"Add Host",
      "startTimeStamp":"2012-08-23 21:53:40",
      "taskState":2
   },
   "obj":{
      "username":null,
      "storageSystemId":"50ce62e6-6846-c5b3-d8a1-27061a696604",
      "isRemote":false,
      "hostGroupId":null,
      "name":"mediaserver3",
      "ipAddress":null,
      "createdByUserId":"252d4786-b19f-ae43-1ff6-453bee8a652e",
      "modifiedTimeStamp":"1969-12-31 16:00:00",
      "createdTimeStamp":"2012-08-23 21:53:40",
      "state":0,
      "hostOsType":0,
      "initiatorPortList":[
         {
            "storageSystemId":"50ce62e6-6846-c5b3-d8a1-27061a696604",
            "isRemote":false,
            "hostId":"4fb8c2da-235a-18f9-2620-1d8aa5da89c5",
            "name":"iqn.1991-05.com.microsoft:osn-mediaserver3",
            "ipAddress":null,
            "createdByUserId":"252d4786-b19f-ae43-1ff6-453bee8a652e",
            "modifiedTimeStamp":"1969-12-31 16:00:00",
            "createdTimeStamp":"2012-08-23 21:53:40",
            "wwpn":null,
            "state":0,
            "iqn":"iqn.1991-05.com.microsoft:osn-mediaserver3",
            "initiatorType":0,
            "modifiedByUserId":null,
            "customId":null,
            "type":13,
            "id":"535abed2-830a-a437-d6fd-5af7c5b5c263"
         }
      ],
      "modifiedByUserId":null,
      "customId":null,
      "password":"********",
      "type":11,
      "id":"4fb8c2da-235a-18f9-2620-1d8aa5da89c5",
      "description":"None"
   }
}

Async vs. Sync (blocking vs non-blocking) API calls

All of the APIs for QuantaStor that modify the configuration in any way will start a task in the system. If you call any API with the flags parameter set to 0 it'll be treated as a blocking call which wait for the task to complete before returning. If you want to call the function and have it return immediately you can pass a 1 as the flags parameter which indicates to the server that the caller wants this to be an asynchronous non-blocking call. With asynchronous calls you'll get the task object back so that you can use the taskGet API to monitor the progress of the operation. When the task completes it will populate the customId property of the task to contain the ID(s) of the objects which were created/deleted/modified by the task.

Task Monitoring

As indicated above, sometimes you'll want to call an API asynchronously so that you can monitor the progress of the task and/or because you want to queue up multiple operations to run simultaneously. In such cases where you call an API asynchronously (flags=1) you can monitor the progress of the task using the tastGet API or the tastEnum API if you want to see all running tasks. When the task is completed you can check the customId property to see the ID(s) of the objects created/modified.

API Error Code Definitions

For all APIs a 0 is returned for SUCCESS and a non-zero error code is returned if there is a command failure along with a description of the error. Full list of error codes are available here.

Security

QuantaStor REST interface always uses SSL via HTTPS. You can change the pem keys on your system by replacing the qstorapi_server.pem file located in /opt/osnexus/quantastor/restsrv/ with your own. If you want to use plain HTTP without SSL you can rename or remove the qstorapi_server.pem and the RESTful service will automatically fall back to using HTTP. After removing the file just restart the RESTful service interface with:

service restsrv restart

If you want to block access to the restful interface you can stop the service and/or you can remove access to port 8153 by removing the entry associated with that port number from the /etc/init.d/iptables configuration file and then restart iptables like so:

service iptables restart

In a similar manner you can block access to the web management interface on port 80/8080.

Supported SOAP / WebServices Implementations

  • gSOAP (C++, all platforms)
  • Apache Axis (Java, all platforms)
  • .NET (C# & Visual Basic, Windows)

API List

The following represents the full API list for every API in QuantaStor. Nothing is left out, if you can do it from the web management interface or the CLI, it's here.

Examples

 
curl -u username:password -k https://hostname:8153/qstorapi/aclAdd?objectId=<id>&ownerType=<int>&ownerId=<id>&accessLevel=<int>&objectType=<int> 

curl -u username:password -k https://hostname:8153/userAdd?username=tiger&password=passWORD1&firstName=Tiger&lastName=Woods&role=Administrator

curl -u username:password -k -d @data.json https://hostname:8153/qstorapi/jsonrpc

Example Script

Here is an example script in python. To use this example replace the ip address with your QuantaStor boxes ip.


import json
import subprocess

print "I am getting the storage system info..."
#To get the data make an http request (such as a curl call)

proc = subprocess.Popen(["curl", "-k", "-u", "admin:password",
         "https://192.168.0.142:8153/qstorapi/storageSystemGet?"], stdout=subprocess.PIPE)

(out, err) = proc.communicate()

print
print "Here is what the returned data looks like when I get it:"
print
print str(out)
print

#call json.loads to turn it into a python dictionary
out = json.loads(out)
print "Here is how to get a single field from the output:"
print
storageSystemId = out["id"]
print storageSystemId

QuantaStor REST API Reference Guide

All efforts are made to keep existing REST API from changing but on rare occasions API changes to existing APIs and objects may change. As such the following sections document the APIs as per a specific released version of QuantaStor. New versions of QuantaStor generally introduce some new APIs and object types but these are added in a backwards compatible fashion.

Current Version

Archived Versions

QuantaStor REST API Reference v5.2

QuantaStor REST API Reference v4.2, v4.1

QuantaStor REST API Reference v4.0 and earlier

Enumeration Types

The enumeration types listed below are used with APIs noted above. Many of the enumerations have assigned values like "OSN_CMN_FLAG_ASYNC = 0x0001" but for those that do not have assigned values note that they are 0 indexed. For example, OSN_CMN_ACCESSTYPE_READWRITE should be specified as 0 and OSN_CMN_ACCESSTYPE_READONLY specified as a 1 to the storageVolumeModify API as the accessMode for changing the configuration of a storage volume.

Ansible Documentation

Currently, OsNexus does not package the python client or the Ansible modules with the QuantaStor installation package. Individual installation instructions can be found on GitHub (Ansible modules) and PyPi (qsclient).

OSNEXUS Python client in Git: OSNEXUS QSPyClient

OSNEXUS QuantaStor Python Client Library

OSNEXUS Ansible Modules in Git: OSNEXUS qsansible

For more information about QuantaStor Ansible automation,
checkout our blog post Automating storage provisioning using Ansible with Quantastor.