client – HPELeftHandClient

HPELeftHand REST Client

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

LeftHand OS REST Service. This version also supports running actions on the LeftHand that use SSH.

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

class hpelefthandclient.client.HPELeftHandClient(api_url, secure=False)[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
getSnapshotParentVolume(name)[source]

Get the parent volume for a Snapshot

Parameters:name (str) – The name of the snapshot
Returns:parent volume
Raises:HTTPNotFound - Snapshot not found.
Raises:HTTPNotFound - NON_EXISTENT_VOL - volume 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"
}
modifySnapshot(snapshot_id, options)[source]

Modify an existing snapshot.

Parameters:
  • snapshot_id (str) – The id of the snapshot to find
  • options (dict) – Dictionary of snapshot options to be modified
Returns:

snapshot

Raises:

HTTPServerError - SNAPSHOT_ID_NOT_FOUND - snapshot doesn’t exist

getVolumes(cluster=None, fields=None)[source]

Get the list of Volumes

Parameters:
  • cluster (str) – a cluster name
  • fields (list) – specific fields of the returning data
Returns:

list of Volumes

getVolume(volume_id, query=None)[source]

Get information about a volume

Parameters:
  • volume_id (str) – The id of the volume to find
  • query – Optional query parameter, e.g. fields, expand-links
Returns:

volume

Raises:

HTTPNotFound - NON_EXISTENT_VOL - volume doesn’t exist

getVolumeByName(name)[source]

Get information about a volume by name

Parameters:name (str) – The name of the volume to find
Returns:volume
Raises:HTTPNotFound - NON_EXISTENT_VOL - volume doesn’t exist
findServerVolumes(server_name)[source]

Find volumes that are exported to a server.

Parameters:server_name (str) – The name of the server to search.
Returns:A list of volumes that are on the specified server.
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
makeVolumeRemote(name, snapshot_name)[source]

Make a volume remote. This command is issued against a secondary cluster and tells a volume it is associated to a primary volume on another system,

Parameters:
  • name (str) – Name of the volume
  • snapshot_name (str) – Name of the remote snapshot that will be auto created.
makeVolumePrimary(name)[source]

Make a remote volume a priamry volume. This command is issued against a secondary array to make a volume primary again. After a failover, this is needed to attach the volume.

Parameters:name (str) – Name of the volume
createRemoteSnapshotSchedule(name, schedule_name, recur_period, start_time, retention_count, remote_cluster, remote_retention_count, remote_volume_name, remote_ip, remote_user_name, remote_password)[source]

Creates a remote snapshot schedule. This command is run on the primary system and effectively creates asynchronous periodic replication between two arrays.

Parameters:
  • name (str) – Name of primary volume
  • schedule_name (str) – Name of the schedule
  • recur_period (int) – How often the remote snapshot will take place. Minimum of 1800 seconds (30 mins).
  • start_time (str) – ISO 8601, UTC formatted date string like: YYYY-MM-DDTHH:MM:SSZ
  • retention_count (int) – The number of snapshots to maintain. Must be between 1 and 50.
  • remote_cluster (str) – The name of the remote cluster to host the remote volume.
  • remote_retention_count (int) – The number of remote snapshots to maintain. Must be between 1 and 50.
  • remote_volume_name (str) – The name of the remote volume to host the snapshot.
  • remote_ip (str) – The IP address of the remote group. NOTE: This CANNOT be the VIP. It must be an IP of a node within the cluster.
  • remote_user_name (str) – The authentication user name for the remote group.
  • remote_password (str) – The password for the remote group.
deleteRemoteSnapshotSchedule(name)[source]

Deletes and existing remote snapshot schedule.

Parameters:name (str) – Name of the remote snapshot schedule.
getRemoteSnapshotSchedule(name)[source]

Retrieves remote snapshot schedule information

Parameters:name (str) – Name of the remote snapshot schedule.
Returns:Command output with the remote snapshot schedule information.
stopRemoteSnapshotSchedule(name)[source]

Stops a remote snapshot schedule

Parameters:name (str) – Name of the remote snapshot schedule.
startRemoteSnapshotSchedule(name)[source]

Starts a remote snapshot schedule

Parameters:name (str) – Name of the remote snapshot schedule.
doesRemoteSnapshotScheduleExist(name)[source]

Determines if a remote snapshot schedule exists.

Parameters:name (str) – Name of the remote snapshot schedule.
Returns:Whether or not a remote snapshot schedule exists.
getIPFromCluster(cluster_name)[source]

Given a cluster name, this will return the first IP address in the cluster. The main use case for this is to create remote snapshot schedules, considering the VIP cannot be provided; an individual node IP is required.

Parameters:cluster_name (str) – The cluster name
Returns:IP address of a node in the cluster

Previous topic

client – HPELeftHandClient

Next topic

exceptions – HTTP Exceptions

This Page