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)
condition_db_filter(model, field, value)

Create matching filter.

If value is an iterable other than a string, any of the values is a valid match (OR), so we’ll use SQL IN operator.

If it’s not an iterator == operator will be used.

condition_not_db_filter(model, field, value, auto_none=True)

Create non matching filter.

If value is an iterable other than a string, any of the values is a valid match (OR), so we’ll use SQL IN operator.

If it’s not an iterator == operator will be used.

If auto_none is True then we’ll consider NULL values as different as well, like we do in Python and not like SQL does.

conditional_update(*args, **kwargs)
consistencygroup_create(*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)
get_backend()

The backend is this module itself.

get_booleans_for_table(table_name)
get_by_id(*args, **kwargs)
get_engine()
get_model_for_versioned_object(versioned_object)
get_session(**kwargs)
handle_db_data_error(f)
image_volume_cache_create(*args, **kwargs)
image_volume_cache_delete(*args, **kwargs)
image_volume_cache_get_all_for_host(*args, **kwargs)
image_volume_cache_get_and_update_last_used(*args, **kwargs)
image_volume_cache_get_by_volume_id(*args, **kwargs)
is_admin_context(context)

Indicates if the request context is an administrator.

is_orm_value(obj)

Check if object is an ORM field or expression.

is_user_context(context)

Indicates if the request context is a normal user.

is_valid_model_filters(model, filters)

Return True if filter values exist on the model

Parameters:
  • model – a Cinder model
  • filters – dictionary of filters
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.
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_allocated_get_all_by_project(*args, **kwargs)
quota_allocated_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_class_update_resource(*args, **kwargs)
quota_create(*args, **kwargs)
quota_destroy(*args, **kwargs)
quota_destroy_all_by_project(*args, **kwargs)
quota_destroy_by_project(*args, **kwargs)

Destroy all limit quotas associated with a project.

Leaves usage and reservation quotas intact.

quota_get(*args, **kwargs)
quota_get_all_by_project(*args, **kwargs)
quota_reserve(*args, **kwargs)
quota_update(*args, **kwargs)
quota_update_resource(*args, **kwargs)
quota_usage_get(*args, **kwargs)
quota_usage_get_all_by_project(*args, **kwargs)
quota_usage_update_resource(*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_binary(*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)
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_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_glance_metadata_bulk_create(*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_glance_metadata_list_get(*args, **kwargs)
volume_has_attachments_filter()
volume_has_snapshots_filter()
volume_has_undeletable_snapshots_filter()
volume_metadata_delete(*args, **kwargs)
volume_metadata_get(*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)
volume_update_status_based_on_attachment(context, volume_id)

Update volume status based on attachment.

Get volume and check if ‘volume_attachment’ parameter is present in volume. If ‘volume_attachment’ is None then set volume status to ‘available’ else set volume status to ‘in-use’.

Parameters:
  • context – context to query under
  • volume_id – id of volume to be updated
Returns:

updated volume

Previous topic

The cinder.db.migration Module

Next topic

The cinder.db.sqlalchemy.migrate_repo.manage Module

Project Source

This Page