DSM-API Python

Install

redirect install dir,

$ cat env.sh
export PREFIX=$HOME/dSS/sysroot
$ . env.sh

aptitude install swig python-dev
cd dsm-api
cmake -DWITH_SCRIPTING=ON -DCMAKE_INSTALL_PREFIX=$PREFIX
make install

Run

$ cat env.sh
export PREFIX=$HOME/dSS/sysroot
export LD_LIBRARY_PATH=$PREFIX/lib
export PYTHONPATH=$PREFIX/lib/python2.7/dist-packages
. env.sh

Always run these in your python session first.

from dsmapi2 import *
h = DsmApiInitialize()
DsmApiOpen(h, "tcp://localhost:8442", 0)

Inspect module

import dsmapi2
dir(dsmapi2)

Sample Run:

    $ ipython
    Python 2.7.4 (default, Apr 19 2013, 18:28:01)
    Type "copyright", "credits" or "license" for more information.

    IPython 0.13.2 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.     

    In [1]: from dsmapi2 import *

    In [2]: h = DsmApiInitialize()

    In [3]: DsmApiOpen(h, "tcp://localhost:8442", 0)
    Out[3]: 0

    In [4]: DsmApiGetBusMembers?
    Type:       function
    String Form:<function DsmApiGetBusMembers at 0x20d1ed8>
    File:       /usr/local/lib/python2.7/dist-packages/dsmapi2/__init__.py
    Definition: DsmApiGetBusMembers(*args)
    Docstring:
    DsmApiGetBusMembers(handle, device_list_size) -> (error, device_list)

    Request a list of the current bus members.

    Arguments:
    handle -- Handle to the library instance
    device_list_size -- device_list has space for this many devices.

    Return values:
    error -- the number of devices in device_list; negative if an error occured
    device_list -- List of devices. Preallocate a buffer of size device_list_size * sizeof(dsid_t)

    In [5]: