HP LeftHand REST Client
Author: | Kurt Martin |
---|---|
Author: | Walter A. Boring IV |
Copyright: | Copyright 2013, Hewlett Packard Development Company, L.P. |
License: | Apache v2.0 |
Current version of 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
Assign a Volume to a Server
Parameters: |
|
---|
optional = {
'Transport' : 0,
'Lun' : 1,
}
Create a clone of an existing Shapshot
Parameters: |
|
---|
optional = {
'description' : "some comment"
}
Create a clone of an existing Volume
Parameters: |
|
---|
optional = {
'description' : "some comment"
}
Create a server by name
Parameters: |
|
---|
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
Create a snapshot of an existing Volume
Parameters: |
|
---|
optional = {
'description' : "some comment",
'inheritAccess' : false
}
Create a new volume
Parameters: |
|
---|
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
This is useful for debugging requests to LeftHand
Parameters: | flag (bool) – set to True to enable debugging |
---|
Delete a Server
Parameters: | server_id – the server ID to delete |
---|---|
Raises : | HTTPNotFound - |
NON_EXISTENT_SERVER - The server does not exist
Delete a Snapshot
Parameters: | snapshot_id – the snapshot ID to delete |
---|---|
Raises : | HTTPNotFound - |
NON_EXISTENT_SNAPSHOT - The snapshot does not exist
Delete a volume
Parameters: | name (str) – the name of the volume |
---|---|
Raises : | HTTPNotFound - |
NON_EXISTENT_VOL - The volume does not exist
Get information about a Cluster
Parameters: | cluster_id (str) – The id of the cluster to find |
---|---|
Returns: | cluster |
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
Get information about a server
Parameters: | server_id (str) – The id of the server to find |
---|---|
Returns: | server |
Raises : | HTTPServerError |
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
Get information about a Snapshot
Returns: | snapshot |
---|---|
Raises : | HTTPServerError |
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
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
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
This authenticates against the LH OS REST server and creates a session.
Parameters: |
|
---|---|
Returns: | None |
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
Exceptions for the client
Author: | Walter A. Boring IV |
---|---|
Description: | This contains the HTTP exceptions that can come back from the REST calls |
Bases: exceptions.Exception
The base exception class for all exceptions this library raises.
Parameters: | error (array) – The error array |
---|
Bases: hplefthandclient.exceptions.ClientException
HTTP 502 - The server was acting as a gateway or proxy and received an invalid response from the upstream server.
Bases: hplefthandclient.exceptions.ClientException
HTTP 400 - Bad request: you sent some malformed data.
Bases: hplefthandclient.exceptions.ClientException
HTTP 409 - Conflict: A Conflict happened on the server
Bases: hplefthandclient.exceptions.ClientException
HTTP 417 - The server cannot meet the requirements of the Expect request-header field.
Bases: hplefthandclient.exceptions.ClientException
HTTP 403 - Forbidden: your credentials don’t give you access to this resource.
Bases: hplefthandclient.exceptions.ClientException
HTTP 504 - The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
Bases: hplefthandclient.exceptions.ClientException
HTTP 410 - Indicates that the resource requested is no longer available and will not be available again.
Bases: hplefthandclient.exceptions.ClientException
HTTP 411 - The request did not specify the length of its content, which is required by the requested resource.
Bases: hplefthandclient.exceptions.ClientException
HTTP 405 - Method not Allowed
Bases: hplefthandclient.exceptions.ClientException
HTTP 406 - Method not Acceptable
Bases: hplefthandclient.exceptions.ClientException
HTTP 404 - Not found
Bases: hplefthandclient.exceptions.ClientException
HTTP 501 - Not Implemented: the server does not support this operation.
Bases: hplefthandclient.exceptions.ClientException
HTTP 412 - The server does not meet one of the preconditions that the requester put on the request.
Bases: hplefthandclient.exceptions.ClientException
HTTP 407 - The client must first authenticate itself with the proxy.
Bases: hplefthandclient.exceptions.ClientException
HTTP 413 - The request is larger than the server is willing or able to process
Bases: hplefthandclient.exceptions.ClientException
HTTP 408 - The server timed out waiting for the request.
Bases: hplefthandclient.exceptions.ClientException
HTTP 414 - The URI provided was too long for the server to process.
Bases: hplefthandclient.exceptions.ClientException
HTTP 416 - The client has asked for a portion of the file, but the server cannot supply that portion.
Bases: hplefthandclient.exceptions.ClientException
HTTP 500 -
Bases: hplefthandclient.exceptions.ClientException
HTTP 503 - The server is currently unavailable
Bases: hplefthandclient.exceptions.ClientException
HTTP 418 - I’m a Tea Pot
Bases: hplefthandclient.exceptions.ClientException
HTTP 401 - Unauthorized: bad credentials.
Bases: hplefthandclient.exceptions.ClientException
HTTP 415 - The request entity has a media type which the server or resource does not support.
Bases: hplefthandclient.exceptions.ClientException
HTTP 505 - The server does not support the HTTP protocol version used in the request.
HPLeftHand HTTP Client :Author: Walter A. Boring IV :Description: This is the HTTP Client that is used to make the actual calls.
It includes the authentication that knows the cookie name for LH.
Bases: httplib2.Http
An HTTP REST Client that sends and recieves JSON data as the body of the HTTP request.
Parameters: |
|
---|
This tries to create an authenticated session with the LH OS server
Parameters: |
|
---|
Make an HTTP DELETE request to the server.
#example call
try {
headers, body = http.delete('/volumes/%s' % name)
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
Parameters: | url (str) – The relative url from the LH api_url |
---|---|
Returns: | headers - dict of HTTP Response headers |
Returns: | body - the body of the response. If the body was JSON, |
it will be an object
Make an HTTP GET request to the server.
#example call
try {
headers, body = http.get('/volumes')
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
Parameters: | url (str) – The relative url from the LH api_url |
---|---|
Returns: | headers - dict of HTTP Response headers |
Returns: | body - the body of the response. If the body was JSON, |
it will be an object
Make an HTTP POST request to the server.
#example call
try {
info = {'name': 'new volume name', 'sizeMiB': 300}
headers, body = http.post('/volumes', body=info)
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
Parameters: | url (str) – The relative url from the LH api_url |
---|---|
Returns: | headers - dict of HTTP Response headers |
Returns: | body - the body of the response. If the body was JSON, |
it will be an object
Make an HTTP PUT request to the server.
#example call
try {
info = {'name': 'something'}
headers, body = http.put('/volumes', body=info)
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
Parameters: | url (str) – The relative url from the LH api_url |
---|---|
Returns: | headers - dict of HTTP Response headers |
Returns: | body - the body of the response. If the body was JSON, |
it will be an object
This makes an HTTP Request to the LH server. You should use get, post, delete instead.