client – HPLeftHandClient

HPLeftHand REST Client

Author:Kurt Martin
Description:This is the LeftHand/StoreVirtual Client that talks to the

LeftHand OS REST Service.

This client requires and works with version 11.5 of the LeftHand firmware

class hplefthandclient.client.HPLeftHandClient(api_url)[source]
debug_rest(flag)[source]

This is useful for debugging requests to LeftHand

Parameters:flag (bool) – set to True to enable debugging
login(username, password)[source]

This authenticates against the LH OS REST server and creates a session.

Parameters:
  • username (str) – The username
  • password (str) – The password
Returns:

None

logout()[source]

This destroys the session and logs out from the LH OS server

Returns:None
getClusters()[source]

Get the list of Clusters

Returns:list of Clusters
getCluster(cluster_id)[source]

Get information about a Cluster

Parameters:cluster_id (str) – The id of the cluster to find
Returns:cluster
getClusterByName(name)[source]

Get information about a cluster by name

Parameters:name (str) – The name of the cluster to find
Returns:cluster
Raises:HTTPNotFound -

NON_EXISTENT_CLUSTER - cluster doesn’t exist

getServers()[source]

Get the list of Servers

Returns:list of Servers
getServer(server_id)[source]

Get information about a server

Parameters:server_id (str) – The id of the server to find
Returns:server
Raises:HTTPServerError
getServerByName(name)[source]

Get information about a server by name

Parameters:name (str) – The name of the server to find
Returns:server
Raises:HTTPNotFound -

NON_EXISTENT_SERVER - server doesn’t exist

createServer(name, iqn, optional=None)[source]

Create a server by name

Parameters:
  • name (str) – The name of the server to create
  • iqn – The iSCSI qualified name
  • optional (dict) – Dictionary of optional params
optional = {
    'description' : "some comment",
    'iscsiEnabled' : True,
    'chapName': "some chap name",
    'chapAuthenticationRequired': False,
    'chapInitiatorSecret': "initiator secret",
    'chapTargetSecret': "target secret",
    'iscsiLoadBalancingEnabled': True,
    'controllingServerName': "server name",
    'fibreChannelEnabled': False,
    'inServerCluster": True
}
Returns:server
Raises:HTTPNotFound -

NON_EXISTENT_SERVER - server doesn’t exist

deleteServer(server_id)[source]

Delete a Server

Parameters:server_id – the server ID to delete
Raises:HTTPNotFound -

NON_EXISTENT_SERVER - The server does not exist

getSnapshots()[source]

Get the list of Snapshots

Returns:list of Snapshots
getSnapshot(snapshot_id)[source]

Get information about a Snapshot

Returns:snapshot
Raises:HTTPServerError
getSnapshotByName(name)[source]

Get information about a snapshot by name

Parameters:name – The name of the snapshot to find
Returns:volume
Raises:HTTPNotFound -

NON_EXISTENT_SNAP - shapshot doesn’t exist

createSnapshot(name, source_volume_id, optional=None)[source]

Create a snapshot of an existing Volume

Parameters:
  • name (str) – Name of the Snapshot
  • source_volume_id (int) – The volume you want to snapshot
  • optional (dict) – Dictionary of optional params
optional = {
    'description' : "some comment",
    'inheritAccess' : false
}
deleteSnapshot(snapshot_id)[source]

Delete a Snapshot

Parameters:snapshot_id – the snapshot ID to delete
Raises:HTTPNotFound -

NON_EXISTENT_SNAPSHOT - The snapshot does not exist

cloneSnapshot(name, source_snapshot_id, optional=None)[source]

Create a clone of an existing Shapshot

Parameters:
  • name (str) – Name of the Snapshot clone
  • source_snapshot_id (int) – The snapshot you want to clone
  • optional (dict) – Dictionary of optional params
optional = {
    'description' : "some comment"
}
getVolumes()[source]

Get the list of Volumes

Returns:list of Volumes
getVolume(volume_id)[source]

Get information about a volume

Parameters:volume_id (str) – The id of the volume to find
Returns:volume
Raises:HTTPNotFound -

NON_EXISTENT_VOL - volume doesn’t exist

getVolumeByName(name)[source]

Get information about a volume by name

Parameters:name – The name of the volume to find
Returns:volume
Raises:HTTPNotFound -

NON_EXISTENT_VOL - volume doesn’t exist

createVolume(name, cluster_id, size, optional=None)[source]

Create a new volume

Parameters:
  • name (str) – the name of the volume
  • cluster_id (int) – the cluster Id
  • sizeKB (int) – size in KB for the volume
  • optional (dict) – dict of other optional items
optional = {
 'description': 'some comment',
 'isThinProvisioned': 'true',
 'autogrowSeconds': 200,
 'clusterName': 'somename',
 'isAdaptiveOptimizationEnabled': 'true',
 'dataProtectionLevel': 2,
}
Returns:List of Volumes
Raises:HTTPConflict -

EXISTENT_SV - Volume Exists already

deleteVolume(volume_id)[source]

Delete a volume

Parameters:name (str) – the name of the volume
Raises:HTTPNotFound -

NON_EXISTENT_VOL - The volume does not exist

modifyVolume(volume_id, optional)[source]

Modify an existing volume.

Parameters:volume_id (str) – The id of the volume to find
Returns:volume
Raises:HTTPNotFound -

NON_EXISTENT_VOL - volume doesn’t exist

cloneVolume(name, source_volume_id, optional=None)[source]

Create a clone of an existing Volume

Parameters:
  • name (str) – Name of the Volume clone
  • source_volume_id (int) – The Volume you want to clone
  • optional (dict) – Dictionary of optional params
optional = {
    'description' : "some comment"
}
addServerAccess(volume_id, server_id, optional=None)[source]

Assign a Volume to a Server

Parameters:
  • volume_id – Volume ID of the volume
  • server_id – Server ID of the server to add the volume to
  • optional (dict) – Dictionary of optional params
optional = {
    'Transport' : 0,
    'Lun' : 1,
}
removeServerAccess(volume_id, server_id)[source]

Unassign a Volume from a Server

Parameters:
  • volume_id – Volume ID of the volume
  • server_id – Server ID of the server to remove the volume fom