cinder.db.api module¶
Defines interface for DB access.
Functions in this module are imported into the cinder.db namespace. Call these functions from cinder.db namespace, not the cinder.db.api namespace.
All functions in this module return objects that implement a dictionary-like interface. Currently, many of these objects are sqlalchemy objects that implement a dictionary interface. However, a future goal is to have all of these objects be simple dictionaries.
Related Flags
- connection:
string specifying the sqlalchemy connection to use, like: sqlite:///var/lib/cinder/cinder.sqlite.
- enable_new_services:
when adding a new service to the database, is it in the pool of available hardware (Default: True)
- apply_like_filters(model)¶
- attachment_destroy(context, attachment_id)¶
Destroy the specified attachment record.
- attachment_specs_delete(context, attachment_id, key)¶
DEPRECATED: Delete attachment_specs for the specified attachment.
- attachment_specs_exist(context)¶
- attachment_specs_get(context, attachment_id)¶
DEPRECATED: Fetch the attachment_specs for the specified attachment.
- attachment_specs_update_or_create(context, attachment_id, specs)¶
DEPRECATED: Update attachment_specs for the specified attachment.
- 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(context, values)¶
- backup_destroy(context, backup_id)¶
- backup_get(context, backup_id, read_deleted=None, project_only=True)¶
- backup_get_all(context, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
- backup_get_all_active_by_window(context, begin, end=None, project_id=None)¶
Return backups that were active during window.
- backup_get_all_by_host(context, host)¶
- backup_get_all_by_project(context, project_id, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
- backup_get_all_by_volume(context, volume_id, vol_project_id, filters=None)¶
- backup_metadata_get(context, backup_id)¶
- backup_metadata_update(context, backup_id, metadata, delete)¶
- backup_update(context, backup_id, values)¶
- calculate_resource_count(context, resource_type, filters)¶
Calculate total count with filters applied
- 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(context, values)¶
- cgsnapshot_creating_from_src()¶
Get a filter that checks if a CGSnapshot is being created from a CG.
- cgsnapshot_destroy(context, cgsnapshot_id)¶
- cgsnapshot_get(context, cgsnapshot_id)¶
- cgsnapshot_get_all(context, filters=None)¶
- cgsnapshot_get_all_by_group(context, group_id, filters=None)¶
- cgsnapshot_get_all_by_project(context, project_id, filters=None)¶
- cgsnapshot_update(context, cgsnapshot_id, values)¶
- cleanup_expired_messages(context)¶
- cluster_create(context, values)¶
Create a cluster from the values dictionary.
- cluster_destroy(context, cluster_id)¶
Destroy the cluster or raise if it does not exist or has hosts.
- cluster_get(context, id=None, is_up=None, get_services=False, services_summary=False, read_deleted='no', name_match_level=None, **filters)¶
Get a cluster that matches the criteria.
- Parameters:
id – Id of the cluster.
is_up – Boolean value to filter based on the cluster’s up status.
get_services – If we want to load all services from this cluster.
services_summary – If we want to load num_hosts and num_down_hosts fields.
read_deleted – Filtering based on delete status. Default value is “no”.
filters – Field based filters in the form of key/value.
name_match_level – ‘pool’, ‘backend’, or ‘host’ for name filter (as defined in _filter_host method)
- Raises:
ClusterNotFound – If cluster doesn’t exist.
- cluster_get_all(context, is_up=None, get_services=False, services_summary=False, read_deleted='no', name_match_level=None, **filters)¶
Get all clusters that match the criteria.
- Parameters:
is_up – Boolean value to filter based on the cluster’s up status.
get_services – If we want to load all services from this cluster.
services_summary – If we want to load num_hosts and num_down_hosts fields.
read_deleted – Filtering based on delete status. Default value is “no”.
name_match_level – ‘pool’, ‘backend’, or ‘host’ for name filter (as defined in _filter_host method)
filters – Field based filters in the form of key/value.
- cluster_update(context, cluster_id, values)¶
Set the given properties on an cluster and update it.
Raises ClusterNotFound if cluster does not exist.
- conditional_update(context, model, values, expected_values, filters=None, include_deleted='no', project_only=False, order=None)¶
Compare-and-swap conditional update SQLAlchemy implementation.
- configure(conf)¶
- consistencygroup_create(context, values, cg_snap_id=None, cg_id=None)¶
- consistencygroup_destroy(context, consistencygroup_id)¶
- consistencygroup_get(context, consistencygroup_id)¶
- consistencygroup_get_all(context, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
Retrieves all consistency groups.
If no sort parameters are specified then the returned cgs are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
filters – Filters for the query in the form of key/value.
- Returns:
list of matching consistency groups
- consistencygroup_get_all_by_project(context, project_id, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
Retrieves all consistency groups in a project.
If no sort parameters are specified then the returned cgs are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
filters – Filters for the query in the form of key/value.
- Returns:
list of matching consistency groups
- consistencygroup_include_in_cluster(context, cluster, partial_rename=True, **filters)¶
Include all consistency groups matching the filters into a cluster.
- consistencygroup_update(context, consistencygroup_id, values)¶
- dispose_engine()¶
Force the engine to establish new connections.
- driver_initiator_data_get(context, initiator, namespace)¶
- driver_initiator_data_insert_by_key(context, initiator, namespace, key, value)¶
- get_all_projects_with_default_type(context, volume_type_id)¶
Get all projects with volume_type_id as their default type
- get_booleans_for_table(table_name)¶
- get_by_id(context, model, id, *args, **kwargs)¶
- get_engine()¶
- get_model_for_versioned_object(versioned_object)¶
- get_projects(context, model, read_deleted='no')¶
- get_snapshot_summary(context, project_only, filters=None)¶
Retrieves all snapshots summary.
- Parameters:
context – context to query under
project_only – limit summary to snapshots
filters – dictionary of filters; values that are in lists, tuples, or sets cause an ‘IN’ operation, while exact matching is used for other values, see _process_snaps_filters function for more information
- Returns:
snapshots summary
- get_volume_summary(context, project_only, filters=None)¶
Retrieves all volumes summary.
- Parameters:
context – context to query under
project_only – limit summary to project volumes
filters – dictionary of filters; values that are in lists, tuples, or sets cause an ‘IN’ operation, while exact matching is used for other values, see _process_volume_filters function for more information
- Returns:
volume summary
- group_create(context, values, group_snapshot_id=None, source_group_id=None)¶
- group_creating_from_src(group_id=None, group_snapshot_id=None)¶
- group_destroy(context, group_id)¶
- group_get(context, group_id)¶
- group_get_all(context, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
Retrieves all groups.
If no sort parameters are specified then the returned groups are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
filters – Filters for the query in the form of key/value.
- Returns:
list of matching groups
- group_get_all_by_project(context, project_id, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
Retrieves all groups in a project.
If no sort parameters are specified then the returned groups are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
filters – Filters for the query in the form of key/value.
- Returns:
list of matching groups
- group_has_group_snapshot_filter()¶
- group_has_volumes_filter(attached_or_with_snapshots=False)¶
- group_include_in_cluster(context, cluster, partial_rename=True, **filters)¶
Include all generic groups matching the filters into a cluster.
- group_snapshot_create(context, values)¶
- group_snapshot_creating_from_src()¶
Get a filter to check if a grp snapshot is being created from a grp.
- group_snapshot_destroy(context, group_snapshot_id)¶
- group_snapshot_get(context, group_snapshot_id)¶
- group_snapshot_get_all(context, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
- group_snapshot_get_all_by_group(context, group_id, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
- group_snapshot_get_all_by_project(context, project_id, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
- group_snapshot_update(context, group_snapshot_id, values)¶
- group_type_access_add(context, type_id, project_id)¶
Add given tenant to the group type access list.
- group_type_access_get_all(context, type_id)¶
- group_type_access_remove(context, type_id, project_id)¶
Remove given tenant from the group type access list.
- group_type_create(context, values, projects=None)¶
Create a new group type.
In order to pass in group specs, the values dict should contain a ‘group_specs’ key/value pair: {‘group_specs’ : {‘k1’: ‘v1’, ‘k2’: ‘v2’, …}}
- group_type_destroy(context, type_id)¶
- group_type_get(context, id, inactive=False, expected_fields=None)¶
Return a dict describing specific group_type.
- group_type_get_all(context, inactive=False, filters=None, marker=None, limit=None, sort_keys=None, sort_dirs=None, offset=None, list_result=False)¶
Returns a dict describing all group_types with name as key.
If no sort parameters are specified then the returned group types are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
filters – dictionary of filters; values that are in lists, tuples, or sets cause an ‘IN’ operation, while exact matching is used for other values, see _process_volume_type_filters function for more information
list_result – For compatibility, if list_result = True, return a list instead of dict.
- Returns:
list/dict of matching group types
- group_type_get_by_name(context, name)¶
Return a dict describing specific group_type.
- group_type_specs_delete(context, group_type_id, key)¶
- group_type_specs_get(context, group_type_id)¶
- group_type_specs_update_or_create(context, group_type_id, group_specs)¶
- group_type_update(context, group_type_id, values)¶
- group_types_get_by_name_or_id(context, group_type_list)¶
Return a dict describing specific group_type.
- group_update(context, group_id, values)¶
- group_volume_type_mapping_create(context, group_id, volume_type_id)¶
Add group volume_type mapping entry.
- handle_db_data_error(f)¶
- image_volume_cache_create(context, host, cluster_name, image_id, image_updated_at, volume_id, size)¶
- image_volume_cache_delete(context, volume_id)¶
- image_volume_cache_get_all(context, **filters)¶
- image_volume_cache_get_and_update_last_used(context, image_id, **filters)¶
- image_volume_cache_get_by_volume_id(context, volume_id)¶
- image_volume_cache_include_in_cluster(context, cluster, partial_rename=True, **filters)¶
Include all volumes matching the filters into a cluster.
- is_admin_context(context)¶
Indicates if the request context is an administrator.
- is_backend_frozen(context, host, cluster_name)¶
Check if a storage backend is frozen based on host and cluster_name.
- 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, exclude_list=None)¶
Return True if filter values exist on the model
- Parameters:
model – a Cinder model
filters – dictionary of filters
- message_create(context, values)¶
- message_destroy(context, message_id)¶
- message_get(context, message_id)¶
- message_get_all(context, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
Retrieves all messages.
If no sort parameters are specified then the returned messages are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
filters – dictionary of filters; values that are in lists, tuples, or sets cause an ‘IN’ operation, while exact matching is used for other values, see _process_messages_filters function for more information
- Returns:
list of matching messages
- model_query(context, model, *args, **kwargs)¶
Query helper that accounts for context’s read_deleted field.
- Parameters:
context – A request context to query under
model – Model to query. Must be a subclass of ModelBase.
args – Arguments to query. If None - model is used.
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
- project_default_volume_type_get(context, project_id=None)¶
Get default volume type(s) for a project(s)
If a project id is passed, it returns default type for that particular project else returns default volume types for all projects
- project_default_volume_type_set(context, volume_type_id, project_id)¶
Set default volume type for a project
- project_default_volume_type_unset(context, project_id)¶
Unset default volume type for a project (hard delete)
- purge_deleted_rows(context, age_in_days)¶
Purge deleted rows older than age from cinder tables.
- qos_specs_associate(context, qos_specs_id, type_id)¶
Associate volume type from specified qos specs.
- qos_specs_associations_get(context, qos_specs_id)¶
Return all entities associated with specified qos specs.
For now, the only entity that is possible to associate with a qos specs is volume type, so this is just a wrapper of volume_type_qos_associations_get(). But it’s possible to extend qos specs association to other entities, such as volumes, sometime in future.
- qos_specs_create(context, values)¶
Create a new QoS specs.
:param values dictionary that contains specifications for QoS
Expected format of the input parameter:
{ 'name': 'Name', 'consumer': 'front-end', 'specs': { 'total_iops_sec': 1000, 'total_bytes_sec': 1024000 } }
- qos_specs_delete(context, qos_specs_id)¶
- qos_specs_disassociate(context, qos_specs_id, type_id)¶
Disassociate volume type from specified qos specs.
- qos_specs_disassociate_all(context, qos_specs_id)¶
Disassociate all entities associated with specified qos specs.
For now, the only entity that is possible to associate with a qos specs is volume type, so this is just a wrapper of volume_type_qos_disassociate_all(). But it’s possible to extend qos specs association to other entities, such as volumes, sometime in future.
- qos_specs_get(context, qos_specs_id, inactive=False)¶
- qos_specs_get_all(context, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
Returns a list of all qos_specs.
Results is like:
[{ 'id': SPECS-UUID, 'name': 'qos_spec-1', 'consumer': 'back-end', 'specs': { 'key1': 'value1', 'key2': 'value2', ... } }, { 'id': SPECS-UUID, 'name': 'qos_spec-2', 'consumer': 'front-end', 'specs': { 'key1': 'value1', 'key2': 'value2', ... } }, ]
- qos_specs_get_by_name(context, name, inactive=False)¶
- qos_specs_item_delete(context, qos_specs_id, key)¶
- qos_specs_update(context, qos_specs_id, values)¶
Make updates to an existing qos specs.
Perform add, update or delete key/values to a qos specs.
- quota_class_create(context, class_name, resource, limit)¶
- quota_class_destroy(context, class_name, resource)¶
- quota_class_destroy_all_by_name(context, class_name)¶
- quota_class_get(context, class_name, resource)¶
- quota_class_get_all_by_name(context, class_name)¶
- quota_class_get_defaults(context)¶
- quota_class_update(context, class_name, resource, limit)¶
- quota_class_update_resource(context, old_res, new_res)¶
- quota_create(context, project_id, resource, limit)¶
- quota_destroy(context, project_id, resource)¶
- quota_destroy_all_by_project(context, project_id, only_quotas=False)¶
Destroy all quotas associated with a project.
This includes limit quotas, usage quotas and reservation quotas. Optionally can only remove limit quotas and leave other types as they are.
- Parameters:
context – The request context, for access checks.
project_id – The ID of the project being deleted.
only_quotas – Only delete limit quotas, leave other types intact.
- quota_destroy_by_project(context, project_id)¶
Destroy all limit quotas associated with a project.
Leaves usage and reservation quotas intact.
- quota_get(context, project_id, resource)¶
- quota_get_all_by_project(context, project_id)¶
- quota_reserve(context, resources, quotas, deltas, expire, until_refresh, max_age, project_id=None)¶
- quota_update(context, project_id, resource, limit)¶
- quota_update_resource(context, old_res, new_res)¶
- quota_usage_get(context, project_id, resource)¶
- quota_usage_get_all_by_project(context, project_id)¶
- quota_usage_update_resource(context, old_res, new_res)¶
- remove_temporary_admin_metadata_data_migration(context, max_count)¶
- require_admin_context(f)¶
Decorator to require admin request context.
The first argument to the wrapped function must be the context.
- require_backup_exists(f)¶
Decorator to require the specified snapshot to exist.
Requires the wrapped function to use context and backup_id as their first two arguments.
- 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()andauthorize_user_context().The first argument to the wrapped function must be the context.
- require_qos_specs_exists(f)¶
Decorator to require the specified QoS speces exist.
Requires the wrapped function to use context and qos_specs_id as their first two arguments.
- 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(context, reservations, project_id=None)¶
- reservation_expire(context)¶
- reservation_rollback(context, reservations, project_id=None)¶
- reset_active_backend(context, enable_replication, active_backend_id, backend_host)¶
- resource_exists(context, model, resource_id)¶
- service_create(context, values)¶
- service_destroy(context, service_id)¶
- service_get(context, service_id=None, backend_match_level=None, **filters)¶
Get a service that matches the criteria.
A possible filter is is_up=True and it will filter nodes that are down.
- Parameters:
service_id – Id of the service.
filters – Filters for the query in the form of key/value.
backend_match_level – ‘pool’, ‘backend’, or ‘host’ for host and cluster filters (as defined in _filter_host method)
- Raises:
ServiceNotFound – If service doesn’t exist.
- service_get_all(context, backend_match_level=None, **filters)¶
Get all services that match the criteria.
A possible filter is is_up=True and it will filter nodes that are down.
- Parameters:
filters – Filters for the query in the form of key/value.
backend_match_level – ‘pool’, ‘backend’, or ‘host’ for host and cluster filters (as defined in _filter_host method)
- service_get_by_uuid(context, service_uuid)¶
- service_update(context, service_id, values, retry=True)¶
- snapshot_create(context, values)¶
- snapshot_data_get_for_project(context, project_id, volume_type_id=None, host=None)¶
- snapshot_destroy(context, snapshot_id)¶
- snapshot_get(context, snapshot_id)¶
- snapshot_get_all(context, filters=None, marker=None, limit=None, sort_keys=None, sort_dirs=None, offset=None)¶
Retrieves all snapshots.
If no sorting parameters are specified then returned snapshots are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
filters – dictionary of filters; will do exact matching on values. Special keys host and cluster_name refer to the volume.
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
- Returns:
list of matching snapshots
- snapshot_get_all_active_by_window(context, begin, end=None, project_id=None)¶
Return snapshots that were active during window.
- snapshot_get_all_by_host(context, host, filters=None)¶
- snapshot_get_all_by_project(context, project_id, filters=None, marker=None, limit=None, sort_keys=None, sort_dirs=None, offset=None)¶
Retrieves all snapshots in a project.
If no sorting parameters are specified then returned snapshots are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
project_id – project for all snapshots being retrieved
filters – dictionary of filters; will do exact matching on values
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
- Returns:
list of matching snapshots
- snapshot_get_all_for_cgsnapshot(context, cgsnapshot_id)¶
- snapshot_get_all_for_group_snapshot(context, group_snapshot_id)¶
- snapshot_get_all_for_volume(context, volume_id)¶
- snapshot_get_latest_for_volume(context, volume_id)¶
- snapshot_metadata_delete(context, snapshot_id, key)¶
- snapshot_metadata_get(context, snapshot_id)¶
- snapshot_metadata_update(context, snapshot_id, metadata, delete)¶
- snapshot_update(context, snapshot_id, values)¶
- transfer_accept(context, transfer_id, user_id, project_id, no_snapshots=False)¶
- transfer_create(context, values)¶
- transfer_destroy(context, transfer_id)¶
- transfer_get(context, transfer_id)¶
- transfer_get_all(context, marker=None, limit=None, sort_keys=None, sort_dirs=None, filters=None, offset=None)¶
- transfer_get_all_by_project(context, project_id, marker=None, limit=None, sort_keys=None, sort_dirs=None, filters=None, offset=None)¶
- volume_admin_metadata_delete(context, volume_id, key)¶
- volume_admin_metadata_get(context, volume_id)¶
- volume_admin_metadata_update(context, volume_id, metadata, delete, add=True, update=True)¶
- volume_attach(context, values)¶
- volume_attached(context, attachment_id, instance_uuid, host_name, mountpoint, attach_mode='rw', mark_attached=True)¶
This method updates a volume attachment entry.
This function saves the information related to a particular attachment for a volume. It also updates the volume record to mark the volume as attached or attaching.
The mark_attached argument is a boolean, when set to True, we mark the volume as ‘in-use’ and the ‘attachment’ as ‘attached’, if False, we use ‘attaching’ for both of these status settings.
- volume_attachment_get(context, attachment_id)¶
Fetch the specified attachment record.
- volume_attachment_get_all(context, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
Retrieve all Attachment records with filter and pagination options.
- volume_attachment_get_all_by_host(context, host, filters=None)¶
- volume_attachment_get_all_by_instance_uuid(context, instance_uuid, filters=None)¶
Fetch all attachment records associated with the specified instance.
- volume_attachment_get_all_by_project(context, project_id, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)¶
Retrieve all Attachment records for specific project.
- volume_attachment_get_all_by_volume_id(context, volume_id)¶
- volume_attachment_update(context, attachment_id, values)¶
- volume_create(context, values)¶
- volume_data_get_for_host(context, host, count_only=False)¶
- volume_data_get_for_project(context, project_id, host=None)¶
- volume_destroy(context, volume_id)¶
- volume_detached(context, volume_id, attachment_id)¶
Delete an attachment and update the volume accordingly.
After marking the attachment as detached the method will decide the status and attach_status values for the volume based on the current status and the remaining attachments and their status.
Volume status may be changed to: in-use, attaching, detaching, reserved, or available.
Volume attach_status will be changed to one of: attached, attaching, detaching, reserved, or detached.
- volume_encryption_metadata_get(context, volume_id)¶
Return the encryption metadata for a given volume.
- volume_get(context, volume_id)¶
- volume_get_all(context, marker=None, limit=None, sort_keys=None, sort_dirs=None, filters=None, offset=None)¶
Retrieves all volumes.
If no sort parameters are specified then the returned volumes are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
filters – dictionary of filters; values that are in lists, tuples, or sets cause an ‘IN’ operation, while exact matching is used for other values, see _process_volume_filters function for more information
- Returns:
list of matching volumes
- volume_get_all_active_by_window(context, begin, end=None, project_id=None)¶
Return volumes that were active during window.
- volume_get_all_by_generic_group(context, group_id, filters=None)¶
Retrieves all volumes associated with the group_id.
- Parameters:
context – context to query under
group_id – group ID for all volumes being retrieved
filters – dictionary of filters; values that are in lists, tuples, or sets cause an ‘IN’ operation, while exact matching is used for other values, see _process_volume_filters function for more information
- Returns:
list of matching volumes
- volume_get_all_by_group(context, group_id, filters=None)¶
Retrieves all volumes associated with the group_id.
- Parameters:
context – context to query under
group_id – consistency group ID for all volumes being retrieved
filters – dictionary of filters; values that are in lists, tuples, or sets cause an ‘IN’ operation, while exact matching is used for other values, see _process_volume_filters function for more information
- Returns:
list of matching volumes
- volume_get_all_by_host(context, host, filters=None)¶
Retrieves all volumes hosted on a host.
- Parameters:
context – context to query under
host – host for all volumes being retrieved
filters – dictionary of filters; values that are in lists, tuples, or sets cause an ‘IN’ operation, while exact matching is used for other values, see _process_volume_filters function for more information
- Returns:
list of matching volumes
- volume_get_all_by_project(context, project_id, marker, limit, sort_keys=None, sort_dirs=None, filters=None, offset=None)¶
Retrieves all volumes in a project.
If no sort parameters are specified then the returned volumes are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
project_id – project for all volumes being retrieved
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
filters – dictionary of filters; values that are in lists, tuples, or sets cause an ‘IN’ operation, while exact matching is used for other values, see _process_volume_filters function for more information
- Returns:
list of matching volumes
- volume_glance_metadata_bulk_create(context, volume_id, metadata)¶
Update the Glance metadata for a volume by adding new key:value pairs.
This API does not support changing the value of a key once it has been created.
- volume_glance_metadata_copy_from_volume_to_volume(context, src_volume_id, volume_id)¶
Update the Glance metadata for a volume.
This copies all of the key:value pairs from the originating volume, to ensure that a volume created from the volume (clone) will retain the original metadata.
- volume_glance_metadata_copy_to_snapshot(context, snapshot_id, volume_id)¶
Update the Glance metadata for a snapshot.
This copies all of the key:value pairs from the originating volume, to ensure that a volume created from the snapshot will retain the original metadata.
- volume_glance_metadata_copy_to_volume(context, volume_id, snapshot_id)¶
Update Glance metadata from a volume.
Update the Glance metadata from a volume (created from a snapshot) by copying all of the key:value pairs from the originating snapshot.
This is so that the Glance metadata from the original volume is retained.
- volume_glance_metadata_create(context, volume_id, key, value)¶
Update the Glance metadata for a volume by adding a new key:value pair.
This API does not support changing the value of a key once it has been created.
- volume_glance_metadata_delete_by_snapshot(context, snapshot_id)¶
- volume_glance_metadata_delete_by_volume(context, volume_id)¶
- volume_glance_metadata_get(context, volume_id)¶
Return the Glance metadata for the specified volume.
- volume_glance_metadata_get_all(context)¶
Return the Glance metadata for all volumes.
- volume_glance_metadata_list_get(context, volume_id_list)¶
Return the glance metadata for a volume list.
- volume_has_attachments_filter()¶
- volume_has_other_project_snp_filter()¶
- volume_has_snapshots_filter()¶
- volume_has_snapshots_in_a_cgsnapshot_filter()¶
- volume_has_undeletable_snapshots_filter()¶
- volume_include_in_cluster(context, cluster, partial_rename=True, **filters)¶
Include all volumes matching the filters into a cluster.
- volume_metadata_delete(context, volume_id, key, meta_type=METADATA_TYPES.user)¶
- volume_metadata_get(context, volume_id)¶
- volume_metadata_update(context, volume_id, metadata, delete, meta_type=METADATA_TYPES.user)¶
- 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(context, snapshot_id)¶
Return the Glance metadata for the specified snapshot.
- volume_type_access_add(context, type_id, project_id)¶
Add given tenant to the volume type access list.
- volume_type_access_get_all(context, type_id)¶
- volume_type_access_remove(context, type_id, project_id)¶
Remove given tenant from the volume type access list.
- volume_type_create(context, values, projects=None)¶
Create a new volume type.
In order to pass in extra specs, the values dict should contain a ‘extra_specs’ key/value pair: {‘extra_specs’ : {‘k1’: ‘v1’, ‘k2’: ‘v2’, …}}
- volume_type_destroy(context, type_id)¶
- volume_type_encryption_create(context, volume_type_id, values)¶
- volume_type_encryption_delete(context, volume_type_id)¶
- volume_type_encryption_get(context, volume_type_id)¶
- volume_type_encryption_update(context, volume_type_id, values)¶
- volume_type_encryption_volume_get(context, volume_type_id)¶
- volume_type_extra_specs_delete(context, volume_type_id, key)¶
- volume_type_extra_specs_get(context, volume_type_id)¶
- volume_type_extra_specs_update_or_create(context, volume_type_id, extra_specs)¶
- volume_type_get(context, id, inactive=False, expected_fields=None)¶
Get volume type by id.
- Parameters:
context – context to query under
id – Volume type id to get.
inactive – Consider inactive volume types when searching
expected_fields – Return those additional fields. Supported fields are: projects.
- Returns:
volume type
- volume_type_get_all(context, inactive=False, filters=None, marker=None, limit=None, sort_keys=None, sort_dirs=None, offset=None, list_result=False)¶
Returns a dict describing all volume_types with name as key.
If no sort parameters are specified then the returned volume types are sorted first by the ‘created_at’ key and then by the ‘id’ key in descending order.
- Parameters:
context – context to query under
marker – the last item of the previous page, used to determine the next page of results to return
limit – maximum number of items to return
sort_keys – list of attributes by which results should be sorted, paired with corresponding item in sort_dirs
sort_dirs – list of directions in which results should be sorted, paired with corresponding item in sort_keys
filters – dictionary of filters; values that are in lists, tuples, or sets cause an ‘IN’ operation, while exact matching is used for other values, see _process_volume_type_filters function for more information
list_result – For compatibility, if list_result = True, return a list instead of dict.
- Returns:
list/dict of matching volume types
- volume_type_get_all_by_group(context, group_id)¶
- volume_type_get_by_name(context, name)¶
Return a dict describing specific volume_type.
- volume_type_qos_associate(context, type_id, qos_specs_id)¶
- volume_type_qos_associations_get(context, qos_specs_id, inactive=False)¶
- volume_type_qos_disassociate(context, qos_specs_id, type_id)¶
Disassociate volume type from qos specs.
- volume_type_qos_disassociate_all(context, qos_specs_id)¶
Disassociate all volume types associated with specified qos specs.
- volume_type_qos_specs_get(context, type_id)¶
Return all qos specs for given volume type.
Result looks like:
{ 'qos_specs': { 'id': 'qos-specs-id', 'name': 'qos_specs_name', 'consumer': 'Consumer', 'specs': { 'key1': 'value1', 'key2': 'value2', 'key3': 'value3' } } }
- volume_type_update(context, volume_type_id, values)¶
- volume_types_get_by_name_or_id(context, volume_type_list)¶
Return a dict describing specific volume_type.
- volume_update(context, volume_id, values)¶
- volume_update_all_by_service(context)¶
Ensure volumes have the correct service_uuid value for their host.
In some deployment tools, when performing an upgrade, all service records are recreated including c-vol service which gets a new record in the services table, though its host name is constant. Later we then delete the old service record. As a consequence, the volumes have the right host name but the service UUID needs to be updated to the ID of the new service record.
- Parameters:
context – context to query under
- 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(context, values_list)¶
- 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, until=None, db_filters=None, **filters)¶
Get all workers that match given criteria.
- worker_update(context, id, filters=None, orm_worker=None, **values)¶
Update a worker with given values.