Auth1

class Auth1.Auth1(env)[source]

Bases: object

A class that handles the auth and token caching for Rackspace Cloud accounts. It only uses api key for auth. You will be prompted for creds if a .cloudAccount.yml file doesn’t exist. Create the object to initially validate. Any time an api request is needed, call validate() to verify the token.

Variables: cloudAccount – List containing the following creds username – Cloud username(string) key – Cloud api key(string) token – Cloud cached token(string) expires – Cloud token expiration time(string) tenant – Cloud tenant id

cloudAccountUK – List containing the following UK creds username – Cloud UK username(string) key – Cloud UK api key(string) token – Cloud UK token(string) expires – Cloud UK token expiration time(string) tenant – Cloud tenant id

endpoints – Dictionary containing US and UK Auth endpoints

pd – Current working directory

Public Functions: __init__ – Object initialization validate – Validates current token stored in cloudAccount.

Private Functions: _auth – Authenticate using cloudAccount credentials and endpoints _updateResults – Dumps account and endpoints to file _logResults – _logError –

validate(force=False)[source]

Checks expires time to current time and re-auths if needed.

Arguments: force – Force token re-auth if needed(bool).

Returns: True or False indicating an existing valid cached token or re-auth success.

cloudAccount = ''
endpoints = {'UK': 'https://lon.identity.api.rackspacecloud.com/v1.1/auth', 'US': 'https://identity.api.rackspacecloud.com/v1.1/auth'}
env = ''
headers = {}
pd = '/Users/smlstvnh/projects/RSCloud/rscloud'
region = None

Previous topic

CloudServersNG

Next topic

Auth2