keystone.resource.backends package

Submodules

keystone.resource.backends.base module

class keystone.resource.backends.base.ResourceDriverBase[source]

Bases: object

delete_project(project_id)[source]

Delete an existing project.

Raises keystone.exception.ProjectNotFound:
 if project_id does not exist
get_project(project_id)[source]

Get a project by ID.

Returns:project_ref
Raises keystone.exception.ProjectNotFound:
 if project_id does not exist
is_leaf_project(project_id)[source]

Check if a project is a leaf in the hierarchy.

Parameters:project_id – the driver will check if this project is a leaf in the hierarchy.
Raises keystone.exception.ProjectNotFound:
 if project_id does not exist
list_project_ids_from_domain_ids(domain_ids)[source]

List project ids for the provided list of domain ids.

Parameters:domain_ids – list of domain ids
Returns:a list of project ids owned by the specified domain ids.

This method is used internally by the assignment manager to bulk read a set of project ids given a list of domain ids.

list_project_parents(project_id)[source]

List all parents from a project by its ID.

Parameters:project_id – the driver will list the parents of this project.
Returns:a list of project_refs or an empty list.
Raises keystone.exception.ProjectNotFound:
 if project_id does not exist
list_projects(hints)[source]

List projects in the system.

Parameters:hints – filter hints which the driver should implement if at all possible.
Returns:a list of project_refs or an empty list.
list_projects_from_ids(project_ids)[source]

List projects for the provided list of ids.

Parameters:project_ids – list of ids
Returns:a list of project_refs.

This method is used internally by the assignment manager to bulk read a set of projects given their ids.

list_projects_in_domain(domain_id)[source]

List projects in the domain.

Parameters:domain_id – the driver MUST only return projects within this domain.
Returns:a list of project_refs or an empty list.
list_projects_in_subtree(project_id)[source]

List all projects in the subtree of a given project.

Parameters:project_id – the driver will get the subtree under this project.
Returns:a list of project_refs or an empty list
Raises keystone.exception.ProjectNotFound:
 if project_id does not exist
update_project(project_id, project)[source]

Update an existing project.

Raises:
class keystone.resource.backends.base.ResourceDriverV8[source]

Bases: keystone.resource.backends.base.ResourceDriverBase

Removed or redefined methods from V8.

Move the abstract methods of any methods removed or modified in later versions of the driver from ResourceDriverBase to here. We maintain this so that legacy drivers, which will be a subclass of ResourceDriverV8, can still reference them.

create_domain(domain_id, domain)[source]

Create a new domain.

Raises keystone.exception.Conflict:
 if the domain_id or domain name already exists
create_project(tenant_id, tenant)[source]

Create a new project.

Parameters:
  • tenant_id – This parameter can be ignored.
  • tenant (dict) – The new project

Project schema:

type: object
properties:
    id:
        type: string
    name:
        type: string
    domain_id:
        type: string
    description:
        type: string
    enabled:
        type: boolean
    parent_id:
        type: string
    is_domain:
        type: boolean
required: [id, name, domain_id]
additionalProperties: true

If project doesn’t match the schema the behavior is undefined.

The driver can impose requirements such as the maximum length of a field. If these requirements are not met the behavior is undefined.

Raises keystone.exception.Conflict:
 if the project id already exists or the name already exists for the domain_id.
delete_domain(domain_id)[source]

Delete an existing domain.

Raises keystone.exception.DomainNotFound:
 if domain_id does not exist
get_domain(domain_id)[source]

Get a domain by ID.

Returns:domain_ref
Raises keystone.exception.DomainNotFound:
 if domain_id does not exist
get_domain_by_name(domain_name)[source]

Get a domain by name.

Returns:domain_ref
Raises keystone.exception.DomainNotFound:
 if domain_name does not exist
get_project_by_name(tenant_name, domain_id)[source]

Get a tenant by name.

Returns:tenant_ref
Raises keystone.exception.ProjectNotFound:
 if a project with the tenant_name does not exist within the domain
list_domains(hints)[source]

List domains in the system.

Parameters:hints – filter hints which the driver should implement if at all possible.
Returns:a list of domain_refs or an empty list.
list_domains_from_ids(domain_ids)[source]

List domains for the provided list of ids.

Parameters:domain_ids – list of ids
Returns:a list of domain_refs.

This method is used internally by the assignment manager to bulk read a set of domains given their ids.

update_domain(domain_id, domain)[source]

Update an existing domain.

Raises:
class keystone.resource.backends.base.ResourceDriverV9[source]

Bases: keystone.resource.backends.base.ResourceDriverBase

New or redefined methods from V8.

Add any new V9 abstract methods (or those with modified signatures) to this class.

create_project(project_id, project)[source]

Create a new project.

Parameters:
  • project_id – This parameter can be ignored.
  • project (dict) – The new project

Project schema:

type: object
properties:
    id:
        type: string
    name:
        type: string
    domain_id:
        type: [string, null]
    description:
        type: string
    enabled:
        type: boolean
    parent_id:
        type: string
    is_domain:
        type: boolean
required: [id, name, domain_id]
additionalProperties: true

If the project doesn’t match the schema the behavior is undefined.

The driver can impose requirements such as the maximum length of a field. If these requirements are not met the behavior is undefined.

Raises keystone.exception.Conflict:
 if the project id already exists or the name already exists for the domain_id.
delete_projects_from_ids(project_ids)[source]

Delete a given list of projects.

Deletes a list of projects. Ensures no project on the list exists after it is successfully called. If an empty list is provided, the it is silently ignored. In addition, if a project ID in the list of project_ids is not found in the backend, no exception is raised, but a message is logged.

get_project_by_name(project_name, domain_id)[source]

Get a project by name.

Returns:project_ref
Raises keystone.exception.ProjectNotFound:
 if a project with the project_name does not exist within the domain
list_projects_acting_as_domain(hints)[source]

List all projects acting as domains.

Parameters:hints – filter hints which the driver should implement if at all possible.
Returns:a list of project_refs or an empty list.
class keystone.resource.backends.base.V9ResourceWrapperForV8Driver(*args, **kwargs)[source]

Bases: keystone.resource.backends.base.ResourceDriverV9

Wrapper class to supported a V8 legacy driver.

In order to support legacy drivers without having to make the manager code driver-version aware, we wrap legacy drivers so that they look like the latest version. For the various changes made in a new driver, here are the actions needed in this wrapper:

Method removed from new driver - remove the call-through method from this
class, since the manager will no longer be calling it.
Method signature (or meaning) changed - wrap the old method in a new
signature here, and munge the input and output parameters accordingly.
New method added to new driver - add a method to implement the new
functionality here if possible. If that is not possible, then return NotImplemented, since we do not guarantee to support new functionality with legacy drivers.

This wrapper contains the following support for newer manager code:

  • The current manager code expects domains to be represented as projects acting as domains, something that may not be possible in a legacy driver. Hence the wrapper will map any calls for projects acting as a domain back onto the driver domain methods. The caveat for this, is that this assumes that there can not be a clash between a project_id and a domain_id, in which case it may not be able to locate the correct entry.
create_project(project_id, project)[source]
delete_project(project_id)[source]
delete_projects_from_ids(project_ids)[source]
get_project(project_id)[source]
get_project_by_name(project_name, domain_id)[source]
is_leaf_project(project_id)[source]
list_project_ids_from_domain_ids(domain_ids)[source]
list_project_parents(project_id)[source]

List a project’s ancestors.

The current manager expects the ancestor tree to end with the project acting as the domain (since that’s now the top of the tree), but a legacy driver will not have that top project in their projects table, since it’s still in the domain table. Hence we lift the algorithm for traversing up the tree from the driver to here, so that our version of get_project() is called, which will fetch the “project” from the right table.

list_projects(hints)[source]

List projects and/or domains.

We use the hints filter to determine whether we are listing projects, domains or both.

If the filter includes domain_id==None, then we should only list domains (convert to a project acting as a domain) since regular projects always have a non-None value for domain_id.

Likewise, if the filter includes domain_id==<non-None value>, then we should only list projects.

If there is no domain_id filter, then we need to do a combained listing of domains and projects, converting domains to projects acting as a domain.

list_projects_acting_as_domain(hints)[source]
list_projects_from_ids(project_ids)[source]
list_projects_in_domain(domain_id)[source]
list_projects_in_subtree(project_id)[source]
update_project(project_id, project)[source]
keystone.resource.backends.base.get_project_from_domain(domain_ref)[source]

Create a project ref from the provided domain ref.

keystone.resource.backends.sql module

Module contents