Lava Client

The Lava client provides access to all public Cloud Big Data API methods.

Authentication

Authenticating to the Cloud Big Data API is similar to that of any other Rackspace product; you will need the following information:

  • Rackspace username
  • Tenant ID
  • Cloud Big Data API key
  • Region

You can get all of this information from the Rackspace Cloud Control Panel. The username with which you log in is the same one you will need to authenticate using Lava. To get the tenant ID, click on the Account: <username> link in the upper-right; it will be at the top as Account # <tenant>. The list of available regions on the left; make sure to use the abbreviation, not the proper name, e.g. ORD instead of Chicago. Lastly, to find the API key, click on the Account: <username> link again, and select Account Settings. The API key will be under Login Details.

Now that you have the requisite information, you can create the client:

>>> from lavaclient import Lava
>>> client = Lava('myusername',
...               region='DFW',
...               api_key='807895ec1ec4ca255e49ccc6715bf29f',
...               tenant_id=123456)

Creating the client will cause it to automatically authenticate. Each time you authenticate, the client will receive a token, which you can use to prevent having to authenticate again (until the token expires). For example, you could cache the token in a file, which you can re-use for future clients:

>>> import os.path

>>> TOKEN_CACHE = '/tmp/lava_token'

>>> def make_client(username, region, api_key, tenant_id):
...     if os.path.isfile(TOKEN_CACHE):
...         with open(TOKEN_CACHE, 'r') as f:
...             token = f.read().strip()
...     else:
...         token = None
...
...     client = Lava(username,
...                   token=token,
...                   region=region,
...                   api_key=api_key,
...                   tenant_id=tenant_id)
...
...     with open(TOKEN_CACHE, 'w') as f:
...         f.write(client.token)
...
...     return client

The client will automatically reauthenticate during API calls if it detects that the token has expired. However, you can force the issue with reauthenticate().

API Reference

class lavaclient.Lava(username, region=None, token=None, api_key=None, auth_url=None, tenant_id=None, endpoint=None, verify_ssl=None)

Cloud Big Data API client. Creating an instance will automatically attempt to authenticate.

Parameters:
  • username – Rackspace username
  • region – Region identifier, e.g. ‘DFW’
  • api_key – API key string
  • token – API token from previous authentication
  • auth_url – Override Keystone authentication url; typically left at the default
  • tenant_id – Rackspace tenant ID
  • endpoint – Cloud Big Data endpoint URL; usually discovered automatically with a valid region
clusters

See: lavaclient.api.clusters

limits

See: lavaclient.api.limits

flavors

See: lavaclient.api.flavors

stacks

See: lavaclient.api.stacks

distros

See: lavaclient.api.distros

scripts

See: lavaclient.api.scripts

nodes

See: lavaclient.api.nodes

credentials

See: lavaclient.api.credentials

reauthenticate()

Reauthenticate with keystone, assuming our token is no longer valid

endpoint

Cloud Big Data endpoint; may be passed as endpoint option to Lava

token

Authentication token; may be passed as token option to Lava