cinder.volume.api module

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: Optional[dict] = None, attach_mode: Optional[str] = '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: Optional[dict]) 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, Optional[str]]

Create a new image from the specified volume.

create(context: RequestContext, size: Union[str, int], name: Optional[str], description: Optional[str], snapshot: Optional[Snapshot] = None, image_id: Optional[str] = None, volume_type: Optional[VolumeType] = None, metadata: Optional[dict] = None, availability_zone: Optional[str] = None, source_volume: Optional[Volume] = None, scheduler_hints=None, source_replica=None, consistencygroup: Optional[ConsistencyGroup] = None, cgsnapshot: Optional[CGSnapshot] = None, source_cg=None, group: Optional[Group] = None, group_snapshot=None, source_group=None, backup: Optional[Backup] = None)
create_snapshot(context: RequestContext, volume: Volume, name: str, description: str, metadata: Optional[dict[str, Any]] = None, cgsnapshot_id: Optional[str] = None, group_snapshot_id: Optional[str] = None, allow_in_use: bool = False) Snapshot
create_snapshot_force(context: RequestContext, volume: Volume, name: str, description: str, metadata: Optional[dict[str, Any]] = None) Snapshot
create_snapshot_in_db(context: RequestContext, volume: Volume, name: Optional[str], description: Optional[str], force: bool, metadata: Optional[dict], cgsnapshot_id: Optional[str], commit_quota: bool = True, group_snapshot_id: Optional[str] = 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: Optional[str] = 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
failover(ctxt: RequestContext, host: str, cluster_name: str, secondary_id: Optional[str] = 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: Optional[str] = None, limit: Optional[int] = None, sort_keys: Optional[Iterable[str]] = None, sort_dirs: Optional[Iterable[str]] = None, filters: Optional[dict] = None, viewable_admin_meta: bool = False, offset: Optional[int] = None) VolumeList
get_all_snapshots(context: RequestContext, search_opts: Optional[dict] = None, marker: Optional[str] = None, limit: Optional[int] = None, sort_keys: Optional[list[str]] = None, sort_dirs: Optional[list[str]] = None, offset: Optional[int] = 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: Optional[str], marker: Optional[str] = None, limit: Optional[int] = None, offset: Optional[int] = None, sort_keys: Optional[list[str]] = None, sort_dirs: Optional[list[str]] = None) list[dict]
get_manageable_volumes(context: RequestContext, host: str, cluster_name, marker: Optional[str] = None, limit: Optional[int] = None, offset: Optional[int] = None, sort_keys: Optional[list[str]] = None, sort_dirs: Optional[list[str]] = 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: Optional[dict] = 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: Optional[str], ref: dict, name: Optional[str] = None, description: Optional[str] = None, volume_type: Optional[VolumeType] = None, metadata: Optional[dict] = None, availability_zone: Optional[str] = None, bootable: Optional[bool] = False) Volume
manage_existing_snapshot(context: RequestContext, ref: dict, volume: Volume, name: Optional[str] = None, description: Optional[str] = None, metadata: Optional[dict] = 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: Union[str, VolumeType], migration_policy: Optional[str] = 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) Optional[str]
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: Optional[bool] = False, add: Optional[bool] = True, update: Optional[bool] = 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.

class HostAPI

Bases: Base

Sub-set of the Volume Manager API for managing host operations.

set_host_enabled(context, host, enabled)

Sets the specified host’s ability to accept new volumes.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

Page Contents