The cinder.db.sqlalchemy.api Module

Implementation of SQLAlchemy backend.

authorize_project_context(context, project_id)

Ensures a request has permission to access the given project.

authorize_quota_class_context(context, class_name)

Ensures a request has permission to access the given quota class.

authorize_user_context(context, user_id)

Ensures a request has permission to access the given user.

backup_create(*args, **kwargs)
backup_destroy(*args, **kwargs)
backup_get(*args, **kwargs)
backup_get_all(*args, **kwargs)
backup_get_all_by_host(*args, **kwargs)
backup_get_all_by_project(*args, **kwargs)
backup_get_all_by_volume(*args, **kwargs)
backup_update(*args, **kwargs)
cgsnapshot_create(*args, **kwargs)
cgsnapshot_destroy(*args, **kwargs)
cgsnapshot_get(*args, **kwargs)
cgsnapshot_get_all(*args, **kwargs)
cgsnapshot_get_all_by_group(*args, **kwargs)
cgsnapshot_get_all_by_project(*args, **kwargs)
cgsnapshot_update(*args, **kwargs)
consistencygroup_create(*args, **kwargs)
consistencygroup_data_get_for_project(*args, **kwargs)
consistencygroup_destroy(*args, **kwargs)
consistencygroup_get(*args, **kwargs)
consistencygroup_get_all(*args, **kwargs)
consistencygroup_get_all_by_project(*args, **kwargs)
consistencygroup_update(*args, **kwargs)
dispose_engine()
driver_initiator_data_get(*args, **kwargs)
driver_initiator_data_update(*args, **kwargs)
finish_volume_migration(*args, **kwargs)
get_backend()

The backend is this module itself.

get_engine()
get_session(**kwargs)
is_admin_context(context)

Indicates if the request context is an administrator.

is_user_context(context)

Indicates if the request context is a normal user.

iscsi_target_count_by_host(*args, **kwargs)
iscsi_target_create_safe(*args, **kwargs)
model_query(context, *args, **kwargs)

Query helper that accounts for context’s read_deleted field.

Parameters:
  • context – context to query under
  • session – if present, the session to use
  • read_deleted – if present, overrides context’s read_deleted field.
  • project_only – if present and context is user-type, then restrict query to match the context’s project_id.
or_(*clauses)

Produce a conjunction of expressions joined by OR.

E.g.:

from sqlalchemy import or_

stmt = select([users_table]).where(
                or_(
                    users_table.c.name == 'wendy',
                    users_table.c.name == 'jack'
                )
            )

The or_() conjunction is also available using the Python | operator (though note that compound expressions need to be parenthesized in order to function with Python operator precedence behavior):

stmt = select([users_table]).where(
                (users_table.c.name == 'wendy') |
                (users_table.c.name == 'jack')
            )

See also

and_()

process_sort_params(sort_keys, sort_dirs, default_keys=None, default_dir='asc')

Process the sort parameters to include default keys.

Creates a list of sort keys and a list of sort directions. Adds the default keys to the end of the list if they are not already included.

When adding the default keys to the sort keys list, the associated direction is: 1) The first element in the ‘sort_dirs’ list (if specified), else 2) ‘default_dir’ value (Note that ‘asc’ is the default value since this is the default in sqlalchemy.utils.paginate_query)

Parameters:
  • sort_keys – List of sort keys to include in the processed list
  • sort_dirs – List of sort directions to include in the processed list
  • default_keys – List of sort keys that need to be included in the processed list, they are added at the end of the list if not already specified.
  • default_dir – Sort direction associated with each of the default keys that are not supplied, used when they are added to the processed list
Returns:

list of sort keys, list of sort directions

Raises exception.InvalidInput:
 

If more sort directions than sort keys are specified or if an invalid sort direction is specified

purge_deleted_rows(*args, **kwargs)
qos_specs_associate(*args, **kwargs)
qos_specs_associations_get(*args, **kwargs)
qos_specs_create(*args, **kwargs)
qos_specs_delete(*args, **kwargs)
qos_specs_disassociate(*args, **kwargs)
qos_specs_disassociate_all(*args, **kwargs)
qos_specs_get(*args, **kwargs)
qos_specs_get_all(*args, **kwargs)
qos_specs_get_by_name(*args, **kwargs)
qos_specs_item_delete(*args, **kwargs)
qos_specs_update(*args, **kwargs)
quota_class_create(*args, **kwargs)
quota_class_destroy(*args, **kwargs)
quota_class_destroy_all_by_name(*args, **kwargs)
quota_class_get(*args, **kwargs)
quota_class_get_all_by_name(*args, **kwargs)
quota_class_get_default(context)
quota_class_update(*args, **kwargs)
quota_create(*args, **kwargs)
quota_destroy(*args, **kwargs)
quota_destroy_all_by_project(*args, **kwargs)
quota_get(*args, **kwargs)
quota_get_all_by_project(*args, **kwargs)
quota_reserve(*args, **kwargs)
quota_update(*args, **kwargs)
quota_usage_get(*args, **kwargs)
quota_usage_get_all_by_project(*args, **kwargs)
require_admin_context(f)

Decorator to require admin request context.

The first argument to the wrapped function must be the context.

require_context(f)

Decorator to require any user or admin context.

This does no authorization for user or project access matching, see authorize_project_context() and authorize_user_context().

The first argument to the wrapped function must be the context.

require_snapshot_exists(f)

Decorator to require the specified snapshot to exist.

Requires the wrapped function to use context and snapshot_id as their first two arguments.

require_volume_exists(f)

Decorator to require the specified volume to exist.

Requires the wrapped function to use context and volume_id as their first two arguments.

reservation_commit(*args, **kwargs)
reservation_expire(*args, **kwargs)
reservation_rollback(*args, **kwargs)
service_create(*args, **kwargs)
service_destroy(*args, **kwargs)
service_get(*args, **kwargs)
service_get_all(*args, **kwargs)
service_get_all_by_topic(*args, **kwargs)
service_get_by_args(*args, **kwargs)
service_get_by_host_and_topic(*args, **kwargs)
service_update(*args, **kwargs)
snapshot_create(*args, **kwargs)
snapshot_data_get_for_project(*args, **kwargs)
snapshot_destroy(*args, **kwargs)
snapshot_get(*args, **kwargs)
snapshot_get_active_by_window(*args, **kwargs)
snapshot_get_all(*args, **kwargs)
snapshot_get_all_by_project(*args, **kwargs)
snapshot_get_all_for_cgsnapshot(*args, **kwargs)
snapshot_get_all_for_volume(*args, **kwargs)
snapshot_get_by_host(*args, **kwargs)
snapshot_metadata_delete(*args, **kwargs)
snapshot_metadata_get(*args, **kwargs)
snapshot_metadata_update(*args, **kwargs)
snapshot_update(*args, **kwargs)
transfer_accept(*args, **kwargs)
transfer_create(*args, **kwargs)
transfer_destroy(*args, **kwargs)
transfer_get(*args, **kwargs)
transfer_get_all(*args, **kwargs)
transfer_get_all_by_project(*args, **kwargs)
true()

Return a constant True_ construct.

E.g.:

>>> from sqlalchemy import true
>>> print select([t.c.x]).where(true())
SELECT x FROM t WHERE true

A backend which does not support true/false constants will render as an expression against 1 or 0:

>>> print select([t.c.x]).where(true())
SELECT x FROM t WHERE 1 = 1

The true() and false() constants also feature “short circuit” operation within an and_() or or_() conjunction:

>>> print select([t.c.x]).where(or_(t.c.x > 5, true()))
SELECT x FROM t WHERE true

>>> print select([t.c.x]).where(and_(t.c.x > 5, false()))
SELECT x FROM t WHERE false

Changed in version 0.9: true() and false() feature better integrated behavior within conjunctions and on dialects that don’t support true/false constants.

See also

false()

volume_admin_metadata_delete(*args, **kwargs)
volume_admin_metadata_get(*args, **kwargs)
volume_admin_metadata_update(*args, **kwargs)
volume_attach(*args, **kwargs)
volume_attached(*args, **kwargs)
volume_attachment_get(*args, **kwargs)
volume_attachment_get_by_host(*args, **kwargs)
volume_attachment_get_by_instance_uuid(*args, **kwargs)
volume_attachment_get_used_by_volume_id(*args, **kwargs)
volume_attachment_update(*args, **kwargs)
volume_create(*args, **kwargs)
volume_data_get_for_host(*args, **kwargs)
volume_data_get_for_project(*args, **kwargs)
volume_destroy(*args, **kwargs)
volume_detach(*args, **kwargs)
volume_detached(*args, **kwargs)
volume_encryption_metadata_get(*args, **kwargs)
volume_get(*args, **kwargs)
volume_get_active_by_window(*args, **kwargs)
volume_get_all(*args, **kwargs)
volume_get_all_by_group(*args, **kwargs)
volume_get_all_by_host(*args, **kwargs)
volume_get_all_by_project(*args, **kwargs)
volume_get_iscsi_target_num(*args, **kwargs)
volume_glance_metadata_copy_from_volume_to_volume(*args, **kwargs)
volume_glance_metadata_copy_to_snapshot(*args, **kwargs)
volume_glance_metadata_copy_to_volume(*args, **kwargs)
volume_glance_metadata_create(*args, **kwargs)
volume_glance_metadata_delete_by_snapshot(*args, **kwargs)
volume_glance_metadata_delete_by_volume(*args, **kwargs)
volume_glance_metadata_get(*args, **kwargs)
volume_glance_metadata_get_all(*args, **kwargs)
volume_metadata_delete(*args, **kwargs)
volume_metadata_get(*args, **kwargs)
volume_metadata_get_item(*args, **kwargs)
volume_metadata_update(*args, **kwargs)
volume_snapshot_glance_metadata_get(*args, **kwargs)
volume_type_access_add(*args, **kwargs)
volume_type_access_get_all(*args, **kwargs)
volume_type_access_remove(*args, **kwargs)
volume_type_create(*args, **kwargs)
volume_type_destroy(*args, **kwargs)
volume_type_encryption_create(*args, **kwargs)
volume_type_encryption_delete(*args, **kwargs)
volume_type_encryption_get(*args, **kwargs)
volume_type_encryption_update(*args, **kwargs)
volume_type_encryption_volume_get(context, volume_type_id, session=None)
volume_type_extra_specs_delete(*args, **kwargs)
volume_type_extra_specs_get(*args, **kwargs)
volume_type_extra_specs_update_or_create(*args, **kwargs)
volume_type_get(*args, **kwargs)
volume_type_get_all(*args, **kwargs)
volume_type_get_by_name(*args, **kwargs)
volume_type_qos_associate(*args, **kwargs)
volume_type_qos_associations_get(*args, **kwargs)
volume_type_qos_disassociate(*args, **kwargs)
volume_type_qos_disassociate_all(*args, **kwargs)
volume_type_qos_specs_get(*args, **kwargs)
volume_type_update(*args, **kwargs)
volume_types_get_by_name_or_id(*args, **kwargs)
volume_update(*args, **kwargs)

Previous topic

The cinder.db.migration Module

Next topic

The cinder.db.sqlalchemy.migrate_repo.manage Module

This Page