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


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

>>> import hpelefthandclient

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 HPELeftHandClient is to create a HPELeftHandClient 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 hpelefthandclient import client, exceptions
#this creates the client object and sets the url to the
#LeftHand server with IP on port 8081.
cl = client.HPELeftHandClient("")

# SSL certification verification is defaulted to False. In order to
# override this, set secure=True. or secure='/path/to/cert.crt'
# cl = client.HPELeftHandClient("",
#                                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.HPELeftHandClient("",
#                                secure='/etc/ssl/certs/ca-certificates.crt')

# Set the SSH authentication options for the SSH based calls.
cl.setSSHOptions(ip_address, username, password)

    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