This tutorial is intended as an introduction to working with HPLeftHandClient.


Before we start, make sure that you have the HPLeftHandClient distribution installed. In the Python shell, the following should run without raising an exception:

>>> import hplefthandclient

This tutorial also assumes that a LeftHand array is up and running and the LeftHand OS is running.

Create the Client and login

The first step when working with HPLeftHandClient is to create a HPLeftHandClient to the LeftHand drive array and logging in to create the session. You must login() prior to calling the other APIs to do work on the LeftHand. Doing so is easy:

from hplefthandclient import client, exceptions
#this creates the client object and sets the url to the
#LeftHand server with IP on port 8008.
cl = client.HPLeftHandClient("")

# SSL certification verification is defaulted to False. In order to
# override this, set secure=True. or secure='/path/to/cert.crt'
# cl = client.HP3ParClient("",
#                          secure=True)
# Or, to use ca certificates as documented by Python Requests,
# pass in the ca-certificates.crt file
# http://docs.python-requests.org/en/v1.0.4/user/advanced
# cl = client.HP3ParClient("",
#                          secure='/etc/ssl/certs/ca-certificates.crt')

    cl.login(username, password)
    print "Login worked!"
except exceptions.HTTPUnauthorized as ex:
    print "Login failed."

When you are done with the the client, it’s a good idea to logout from the LeftHand so there isn’t a stale session sitting around.

print "logout worked"

Getting a list of Volumes

After you have logged in, you can start making calls to the LeftHand APIs. A simple example is getting a list of existing volumes on the array with a call to getVolumes().

import pprint
   volumes = cl.getVolumes()
except exceptions.HTTPUnauthorized as ex:
   print "You must login first"
except Exception as ex:
   #something unexpected happened
   print ex


volumes is an array of volumes in the above call

Table Of Contents

Previous topic

Installing / Upgrading

Next topic


This Page