cinder.volume.api module¶
Handles all requests relating to volumes.
- class API(image_service=None)¶
Bases:
Base
API for interacting with the volume manager.
- AVAILABLE_MIGRATION_STATUS = (None, 'deleting', 'error', 'success')¶
- accept_transfer(context: RequestContext, volume: Volume, new_user: str, new_project: str, no_snapshots: bool = False) dict ¶
- attach(context: RequestContext, volume: Volume, instance_uuid: str, host_name: str, mountpoint: str, mode: str) VolumeAttachment ¶
- attachment_create(ctxt: RequestContext, volume_ref: Volume, instance_uuid: str, connector: dict | None = None, attach_mode: str | None = 'null') VolumeAttachment ¶
Create an attachment record for the specified volume.
- attachment_delete(ctxt: RequestContext, attachment) VolumeAttachmentList ¶
- attachment_deletion_allowed(ctxt: RequestContext, attachment_or_attachment_id, volume=None)¶
Check if deleting an attachment is allowed (Bug #2004555)
Allowed is based on the REST API policy, the status of the attachment, where it is used, and who is making the request.
Deleting an attachment on the Cinder side while leaving the volume connected to the nova host results in leftover devices that can lead to data leaks/corruption.
OS-Brick may have code to detect it, but in some cases it is detected after it has already been exposed, so it’s better to prevent users from being able to intentionally triggering the issue.
- attachment_update(ctxt: RequestContext, attachment_ref: VolumeAttachment, connector) VolumeAttachment ¶
Update an existing attachment record.
- begin_detaching(context: RequestContext, volume: Volume) None ¶
- calculate_resource_count(context: RequestContext, resource_type: str, filters: dict | None) int ¶
- check_volume_filters(filters: dict, strict: bool = False) None ¶
Sets the user filter value to accepted format
- copy_volume_to_image(context: RequestContext, volume: Volume, metadata: dict[str, str], force: bool) dict[str, str | None] ¶
Create a new image from the specified volume.
- create(context: RequestContext, size: str | int, name: str | None, description: str | None, snapshot: Snapshot | None = None, image_id: str | None = None, volume_type: VolumeType | None = None, metadata: dict | None = None, availability_zone: str | None = None, source_volume: Volume | None = None, scheduler_hints=None, source_replica=None, consistencygroup: ConsistencyGroup | None = None, cgsnapshot: CGSnapshot | None = None, source_cg=None, group: Group | None = None, group_snapshot=None, source_group=None, backup: Backup | None = None)¶
- create_snapshot(context: RequestContext, volume: Volume, name: str, description: str, metadata: dict[str, Any] | None = None, cgsnapshot_id: str | None = None, group_snapshot_id: str | None = None, allow_in_use: bool = False) Snapshot ¶
- create_snapshot_force(context: RequestContext, volume: Volume, name: str, description: str, metadata: dict[str, Any] | None = None) Snapshot ¶
- create_snapshot_in_db(context: RequestContext, volume: Volume, name: str | None, description: str | None, force: bool, metadata: dict | None, cgsnapshot_id: str | None, commit_quota: bool = True, group_snapshot_id: str | None = None, allow_in_use: bool = False) Snapshot ¶
- create_snapshots_in_db(context: RequestContext, volume_list: list, name: str, description: str, cgsnapshot_id: str, group_snapshot_id: str | None = None) list ¶
- create_volume_metadata(context: RequestContext, volume: Volume, metadata: dict[str, Any]) dict ¶
Creates volume metadata.
- delete(context: RequestContext, volume: Volume, force: bool = False, unmanage_only: bool = False, cascade: bool = False) None ¶
- delete_snapshot(context: RequestContext, snapshot: Snapshot, force: bool = False, unmanage_only: bool = False) None ¶
- delete_snapshot_metadata(context: RequestContext, snapshot: Snapshot, key: str) None ¶
Delete the given metadata item from a snapshot.
- delete_volume_metadata(context: RequestContext, volume: Volume, key: str, meta_type=METADATA_TYPES.user) None ¶
Delete the given metadata item from a volume.
- detach(context: RequestContext, volume: Volume, attachment_id: str) None ¶
- extend(context: RequestContext, volume: Volume, new_size: int) None ¶
- extend_attached_volume(context: RequestContext, volume: Volume, new_size: int) None ¶
- extend_volume_completion(context: RequestContext, volume: Volume, error: bool)¶
- failover(ctxt: RequestContext, host: str, cluster_name: str, secondary_id: str | None = None) None ¶
- freeze_host(ctxt: RequestContext, host: str, cluster_name: str) None ¶
- get(context: RequestContext, volume_id: str, viewable_admin_meta: bool = False) Volume ¶
- get_all(context: RequestContext, marker: str | None = None, limit: int | None = None, sort_keys: Iterable[str] | None = None, sort_dirs: Iterable[str] | None = None, filters: dict | None = None, viewable_admin_meta: bool = False, offset: int | None = None) VolumeList ¶
- get_all_snapshots(context: RequestContext, search_opts: dict | None = None, marker: str | None = None, limit: int | None = None, sort_keys: list[str] | None = None, sort_dirs: list[str] | None = None, offset: int | None = None) SnapshotList ¶
- get_list_volumes_image_metadata(context: RequestContext, volume_id_list: list[str]) DefaultDict[str, str] ¶
- get_manageable_snapshots(context: RequestContext, host: str, cluster_name: str | None, marker: str | None = None, limit: int | None = None, offset: int | None = None, sort_keys: list[str] | None = None, sort_dirs: list[str] | None = None) list[dict] ¶
- get_manageable_volumes(context: RequestContext, host: str, cluster_name, marker: str | None = None, limit: int | None = None, offset: int | None = None, sort_keys: list[str] | None = None, sort_dirs: list[str] | None = None)¶
- get_snapshot(context: RequestContext, snapshot_id: str) Snapshot ¶
- get_snapshot_metadata(context: RequestContext, snapshot: Snapshot) dict ¶
Get all metadata associated with a snapshot.
- get_volume(context: RequestContext, volume_id: str) Volume ¶
- get_volume_image_metadata(context: RequestContext, volume: Volume) dict[str, str] ¶
- get_volume_metadata(context: RequestContext, volume: Volume) dict ¶
Get all metadata associated with a volume.
- get_volume_summary(context: RequestContext, filters: dict | None = None) VolumeList ¶
- get_volumes_image_metadata(context: RequestContext) defaultdict ¶
- initialize_connection(context: RequestContext, volume: Volume, connector: dict) dict ¶
- static is_service_request(ctxt: RequestContext) bool ¶
Check if a request is coming from a service
A request is coming from a service if it has a service token and the service user has one of the roles configured in the service_token_roles configuration option in the [keystone_authtoken] section (defaults to service).
- list_availability_zones(enable_cache: bool = False, refresh_cache: bool = False) tuple ¶
Describe the known availability zones
- Parameters:
enable_cache – Enable az cache
refresh_cache – Refresh cache immediately
- Returns:
tuple of dicts, each with a ‘name’ and ‘available’ key
- manage_existing(context: RequestContext, host: str, cluster_name: str | None, ref: dict, name: str | None = None, description: str | None = None, volume_type: VolumeType | None = None, metadata: dict | None = None, availability_zone: str | None = None, bootable: bool | None = False) Volume ¶
- manage_existing_snapshot(context: RequestContext, ref: dict, volume: Volume, name: str | None = None, description: str | None = None, metadata: dict | None = None) Snapshot ¶
- migrate_volume(context: RequestContext, volume: Volume, host: str, cluster_name: str, force_copy: bool, lock_volume: bool) None ¶
Migrate the volume to the specified host or cluster.
- migrate_volume_completion(context: RequestContext, volume: Volume, new_volume: Volume, error: bool) str ¶
- reimage(context, volume, image_id, reimage_reserved=False)¶
- reserve_volume(context: RequestContext, volume: Volume) None ¶
- retype(context: RequestContext, volume: Volume, new_type: str | VolumeType, migration_policy: str | None = None) None ¶
Attempt to modify the type associated with an existing volume.
- revert_to_snapshot(context: RequestContext, volume: Volume, snapshot: Snapshot) None ¶
revert a volume to a snapshot
- roll_detaching(context: RequestContext, volume: Volume) None ¶
- terminate_connection(context: RequestContext, volume: Volume, connector: dict, force: bool = False) None ¶
- thaw_host(ctxt: RequestContext, host: str, cluster_name: str) str | None ¶
- unreserve_volume(context: RequestContext, volume: Volume) None ¶
- update(context: RequestContext, volume: Volume, fields: dict) None ¶
- update_readonly_flag(context: RequestContext, volume: Volume, flag) None ¶
- update_snapshot(context: RequestContext, snapshot: Snapshot, fields: dict[str, Any]) None ¶
- update_snapshot_metadata(context: RequestContext, snapshot: Snapshot, metadata: dict[str, Any], delete: bool = False) dict ¶
Updates or creates snapshot metadata.
If delete is True, metadata items that are not specified in the metadata argument will be deleted.
- update_volume_admin_metadata(context: RequestContext, volume: Volume, metadata: dict[str, Any], delete: bool | None = False, add: bool | None = True, update: bool | None = True) dict ¶
Updates or creates volume administration metadata.
If delete is True, metadata items that are not specified in the metadata argument will be deleted.
- update_volume_metadata(context: RequestContext, volume: Volume, metadata: dict[str, Any], delete: bool = False, meta_type=METADATA_TYPES.user) dict ¶
Updates volume metadata.
If delete is True, metadata items that are not specified in the metadata argument will be deleted.