pyrax
Python Bindings for the Rackspace Cloud
 All Classes Namespaces Files Functions Variables Properties
Public Member Functions | Public Attributes
BaseIdentity Class Reference

This class handles all of the basic authentication requirements for working with an OpenStack Cloud system. More...

Inheritance diagram for BaseIdentity:
FakeIdentity

List of all members.

Public Member Functions

def __init__
 Initializes the attributes for this identity object.
def auth_token
 Simple alias to self.token.
def auth_endpoint
 Abstracts out the logic for connecting to different auth endpoints.
def auth_endpoint
def get_default_region
 In cases where the region has not been specified, return the value to use.
def __getattr__
 Magic to allow for specification of client by region/service or by service/region.
def get_client
 Returns the client object for the specified service and region.
def set_credentials
 Sets the username and password directly.
def set_credential_file
 Reads in the credentials from the supplied file.
def auth_with_token
 If a valid token is already known, this call uses it to generate the service catalog.
def method_head
def method_get
def method_post
def method_put
def method_delete
def method_patch
def authenticate
 Using the supplied credentials, connects to the specified authentication endpoint and attempts to log in.
def keyring_auth
 Uses the keyring module to retrieve the user's password or api_key.
def unauthenticate
 Clears out any credentials, tokens, and service catalog info.
def get_extensions
 Returns a list of extensions enabled on this service.
def get_token
 Returns the auth token, if it is valid.
def list_tokens
 ADMIN ONLY.
def check_token
 ADMIN ONLY.
def revoke_token
 ADMIN ONLY.
def get_token_endpoints
 ADMIN ONLY.
def list_users
 ADMIN ONLY.
def create_user
 ADMIN ONLY.
def find_user_by_name
 Returns a User object by searching for the supplied user name.
def find_user_by_email
 Returns a User object by searching for the supplied user's email address.
def find_user_by_id
 Returns a User object by searching for the supplied user ID.
def get_user
 Returns the user specified by either ID, username or email.
def update_user
 ADMIN ONLY.
def delete_user
 ADMIN ONLY.
def list_roles_for_user
 ADMIN ONLY.
def list_credentials
 Returns a user's non-password credentials.
def reset_api_key
 Not available in basic Keystone identity.
def get_tenant
 Returns the tenant for the current user.
def list_tenants
 Lists all tenants associated with the currently authenticated user (admin=False), or all tenants (admin=True).
def create_tenant
 ADMIN ONLY.
def update_tenant
 ADMIN ONLY.
def delete_tenant
 ADMIN ONLY.
def list_roles
 Returns a list of all global roles for users, optionally limited by service.
def get_role
 Returns a Role object representing the specified parameter.
def add_role_to_user
 Adds the specified role to the specified user.
def delete_role_from_user
 Deletes the specified role from the specified user.

Public Attributes

 username
 password
 tenant_id
 tenant_name
 token
 expires
 region
 verify_ssl
 api_key
 services
 regions
 authenticated
 user_agent
 http_log_debug
 service_mapping
 service_catalog
 user

Detailed Description

This class handles all of the basic authentication requirements for working with an OpenStack Cloud system.


Constructor & Destructor Documentation

def __init__ (   self,
  username = None,
  password = None,
  tenant_id = None,
  tenant_name = None,
  auth_endpoint = None,
  api_key = None,
  token = None,
  credential_file = None,
  region = None,
  timeout = None,
  verify_ssl = True 
)

Initializes the attributes for this identity object.


Member Function Documentation

def __getattr__ (   self,
  att 
)

Magic to allow for specification of client by region/service or by service/region.

If a service is specified, this should return an object whose endpoints contain keys for each available region for that service. If a region is specified, an object with keys for each service available in that region should be returned.

def add_role_to_user (   self,
  role,
  user 
)

Adds the specified role to the specified user.

There is no return value upon success. Passing a non-existent role or user raises a NotFound exception.

def auth_endpoint (   self)

Abstracts out the logic for connecting to different auth endpoints.

def auth_endpoint (   self,
  val 
)
def auth_token (   self)

Simple alias to self.token.

def auth_with_token (   self,
  token,
  tenant_id = None,
  tenant_name = None 
)

If a valid token is already known, this call uses it to generate the service catalog.

Reimplemented in FakeIdentity.

def authenticate (   self,
  username = None,
  password = None,
  api_key = None,
  tenant_id = None 
)

Using the supplied credentials, connects to the specified authentication endpoint and attempts to log in.

Credentials can either be passed directly to this method, or previously-stored credentials can be used. If authentication is successful, the token and service catalog information is stored, and clients for each service and region are created.

def check_token (   self,
  token = None 
)

ADMIN ONLY.

Returns True or False, depending on whether the current token is valid.

def create_tenant (   self,
  name,
  description = None,
  enabled = True 
)

ADMIN ONLY.

Creates a new tenant.

def create_user (   self,
  name,
  email,
  password = None,
  enabled = True 
)

ADMIN ONLY.

Creates a new user for this tenant (account). The username and email address must be supplied. You may optionally supply the password for this user; if not, the API server generates a password and return it in the 'password' attribute of the resulting User object. NOTE: this is the ONLY time the password is returned; after the initial user creation, there is NO WAY to retrieve the user's password.

You may also specify that the user should be created but not active by passing False to the enabled parameter.

def delete_role_from_user (   self,
  role,
  user 
)

Deletes the specified role from the specified user.

There is no return value upon success. Passing a non-existent role or user raises a NotFound exception.

def delete_tenant (   self,
  tenant 
)

ADMIN ONLY.

Removes the tenant from the system. There is no 'undo' available, so you should be certain that the tenant specified is the tenant you wish to delete.

def delete_user (   self,
  user 
)

ADMIN ONLY.

Removes the user from the system. There is no 'undo' available, so you should be certain that the user specified is the user you wish to delete.

def find_user_by_email (   self,
  email 
)

Returns a User object by searching for the supplied user's email address.

Returns None if there is no match for the given ID.

def find_user_by_id (   self,
  uid 
)

Returns a User object by searching for the supplied user ID.

Returns None if there is no match for the given ID.

def find_user_by_name (   self,
  name 
)

Returns a User object by searching for the supplied user name.

Returns None if there is no match for the given name.

def get_client (   self,
  service,
  region,
  public = True,
  cached = True 
)

Returns the client object for the specified service and region.

By default the public endpoint is used. If you wish to work with a services internal endpoints, specify `public=False`.

By default, if a client has already been created for the given service, region, and public values, that will be returned. To force a new client to be created, pass 'cached=False'.

def get_default_region (   self)

In cases where the region has not been specified, return the value to use.

Subclasses may use information in the service catalog to determine the appropriate default value.

def get_extensions (   self)

Returns a list of extensions enabled on this service.

def get_role (   self,
  role 
)

Returns a Role object representing the specified parameter.

The 'role' parameter can be either an existing Role object, or the ID of the role.

If an invalid role is passed, a NotFound exception is raised.

def get_tenant (   self)

Returns the tenant for the current user.

def get_token (   self,
  force = False 
)

Returns the auth token, if it is valid.

If not, calls the auth endpoint to get a new token. Passing 'True' to 'force' forces a call for a new token, even if there already is a valid token.

Reimplemented in FakeIdentity.

def get_token_endpoints (   self)

ADMIN ONLY.

Returns a list of all endpoints for the current auth token.

def get_user (   self,
  user_id = None,
  username = None,
  email = None 
)

Returns the user specified by either ID, username or email.

Since more than user can have the same email address, searching by that term returns a list of 1 or more User objects. Searching by username or ID returns a single User.

If a user_id that doesn't belong to the current account is searched for, a Forbidden exception is raised. When searching by username or email, a NotFound exception is raised if there is no matching user.

def keyring_auth (   self,
  username = None 
)

Uses the keyring module to retrieve the user's password or api_key.

def list_credentials (   self,
  user = None 
)

Returns a user's non-password credentials.

If no user is specified, the credentials for the currently authenticated user are returned.

You cannot retrieve passwords by this or any other means.

def list_roles (   self,
  service_id = None,
  limit = None,
  marker = None 
)

Returns a list of all global roles for users, optionally limited by service.

Pagination can be handled through the standard 'limit' and 'marker' parameters.

def list_roles_for_user (   self,
  user 
)

ADMIN ONLY.

Returns a list of roles for the specified user. Each role will be a 3-tuple, consisting of (role_id, role_name, role_description).

def list_tenants (   self,
  admin = True 
)

Lists all tenants associated with the currently authenticated user (admin=False), or all tenants (admin=True).

def list_tokens (   self)

ADMIN ONLY.

Returns a dict containing tokens, endpoints, user info, and role metadata.

def list_users (   self)

ADMIN ONLY.

Returns a list of objects for all users for the tenant (account) if this request is issued by a user holding the admin role (identity:user-admin).

def method_delete (   self,
  uri,
  admin = False,
  data = None,
  headers = None,
  std_headers = True 
)
def method_get (   self,
  uri,
  admin = False,
  data = None,
  headers = None,
  std_headers = True 
)
def method_head (   self,
  uri,
  admin = False,
  data = None,
  headers = None,
  std_headers = True 
)
def method_patch (   self,
  uri,
  admin = False,
  data = None,
  headers = None,
  std_headers = True 
)
def method_post (   self,
  uri,
  admin = False,
  data = None,
  headers = None,
  std_headers = True 
)
def method_put (   self,
  uri,
  admin = False,
  data = None,
  headers = None,
  std_headers = True 
)
def reset_api_key (   self,
  user = None 
)

Not available in basic Keystone identity.

def revoke_token (   self,
  token 
)

ADMIN ONLY.

Returns True or False, depending on whether deletion of the specified token was successful.

def set_credential_file (   self,
  credential_file,
  region = None,
  tenant_id = None,
  authenticate = False 
)

Reads in the credentials from the supplied file.

It should be a standard config file in the format:

[keystone] username = myusername password = top_secret tenant_id = my_id

def set_credentials (   self,
  username,
  password = None,
  region = None,
  tenant_id = None,
  authenticate = False 
)

Sets the username and password directly.

def unauthenticate (   self)

Clears out any credentials, tokens, and service catalog info.

def update_tenant (   self,
  tenant,
  name = None,
  description = None,
  enabled = True 
)

ADMIN ONLY.

Updates an existing tenant.

def update_user (   self,
  user,
  email = None,
  username = None,
  uid = None,
  enabled = None 
)

ADMIN ONLY.

Updates the user attributes with the supplied values.


Member Data Documentation

Reimplemented in FakeIdentity.

Reimplemented in FakeIdentity.

Reimplemented in FakeIdentity.

Reimplemented in FakeIdentity.

Reimplemented in FakeIdentity.

Reimplemented in FakeIdentity.

Reimplemented in FakeIdentity.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Properties