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)
cg_creating_from_src(cg_id=None, cgsnapshot_id=None)

Return a filter to check if a CG is being used as creation source.

Returned filter is meant to be used in the Conditional Update mechanism and checks if provided CG ID or CG Snapshot ID is currently being used to create another CG.

This filter will not include CGs that have used the ID but have already finished their creation (status is no longer creating).

Filter uses a subquery that allows it to be used on updates to the consistencygroups table.

cg_has_cgsnapshot_filter()

Return a filter that checks if a CG has CG Snapshots.

cg_has_volumes_filter(attached_or_with_snapshots=False)

Return a filter to check if a CG has volumes.

When attached_or_with_snapshots parameter is given a True value only attached volumes or those with snapshots will be considered.

cgsnapshot_create(*args, **kwargs)
cgsnapshot_creating_from_src()

Get a filter that checks if a CGSnapshot is being created from a CG.

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)
cluster_create(*args, **kwargs)
cluster_destroy(*args, **kwargs)
cluster_get(*args, **kwargs)
cluster_get_all(*args, **kwargs)
cluster_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_include_in_cluster(*args, **kwargs)
consistencygroup_update(*args, **kwargs)
dispose_engine()
driver_initiator_data_get(*args, **kwargs)
driver_initiator_data_insert_by_key(*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)
get_volume_summary_all(*args, **kwargs)
get_volume_summary_by_project(*args, **kwargs)
group_create(*args, **kwargs)
group_creating_from_src(group_id=None, group_snapshot_id=None)
group_destroy(*args, **kwargs)
group_get(*args, **kwargs)
group_get_all(*args, **kwargs)
group_get_all_by_project(*args, **kwargs)
group_has_group_snapshot_filter()
group_has_volumes_filter(attached_or_with_snapshots=False)
group_snapshot_create(*args, **kwargs)
group_snapshot_creating_from_src()

Get a filter to check if a grp snapshot is being created from a grp.

group_snapshot_destroy(*args, **kwargs)
group_snapshot_get(*args, **kwargs)
group_snapshot_get_all(*args, **kwargs)
group_snapshot_get_all_by_group(*args, **kwargs)
group_snapshot_get_all_by_project(*args, **kwargs)
group_snapshot_update(*args, **kwargs)
group_type_access_add(*args, **kwargs)
group_type_access_get_all(*args, **kwargs)
group_type_access_remove(*args, **kwargs)
group_type_create(*args, **kwargs)
group_type_destroy(*args, **kwargs)
group_type_get(*args, **kwargs)
group_type_get_all(*args, **kwargs)
group_type_get_by_name(*args, **kwargs)
group_type_specs_delete(*args, **kwargs)
group_type_specs_get(*args, **kwargs)
group_type_specs_update_or_create(*args, **kwargs)
group_type_update(*args, **kwargs)
group_types_get_by_name_or_id(*args, **kwargs)
group_update(*args, **kwargs)
group_volume_type_mapping_create(*args, **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
message_create(*args, **kwargs)
message_destroy(*args, **kwargs)
message_get(*args, **kwargs)
message_get_all(*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.
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)
resource_exists(*args, **kwargs)
service_create(*args, **kwargs)
service_destroy(*args, **kwargs)
service_get(*args, **kwargs)
service_get_all(*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_group_snapshot(*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_all_by_host(*args, **kwargs)
volume_attachment_get_all_by_instance_uuid(*args, **kwargs)
volume_attachment_get_all_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_generic_group(*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_include_in_cluster(*args, **kwargs)
volume_metadata_delete(*args, **kwargs)
volume_metadata_get(*args, **kwargs)
volume_metadata_update(*args, **kwargs)
volume_qos_allows_retype(new_vol_type)

Filter to check that qos allows retyping the volume to new_vol_type.

Returned sqlalchemy filter will evaluate to True when volume’s status is available or when it’s ‘in-use’ but the qos in new_vol_type is the same as the qos of the volume or when it doesn’t exist a consumer spec key that specifies anything other than the back-end in any of the 2 volume_types.

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_all_by_group(*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

volumes_update(*args, **kwargs)
worker_claim_for_cleanup(context, claimer_id, orm_worker)

Claim a worker entry for cleanup.

worker_create(context, **values)

Create a worker entry from optional arguments.

worker_destroy(context, **filters)

Delete a worker (no soft delete).

worker_get(context, **filters)

Get a worker or raise exception if it does not exist.

worker_get_all(context, **filters)

Get all workers that match given criteria.

worker_update(context, id, filters=None, orm_worker=None, **values)

Update a worker with given values.

Previous topic

The cinder.db.migration Module

Next topic

The cinder.db.sqlalchemy.migrate_repo.manage Module

This Page