cinder.volume.api module

Handles all requests relating to volumes.

class API(image_service=None)

Bases: cinder.db.base.Base

API for interacting with the volume manager.

AVAILABLE_MIGRATION_STATUS = (None, 'deleting', 'error', 'success')
accept_transfer(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, new_user: str, new_project: str, no_snapshots: bool = False) dict
attach(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, instance_uuid: str, host_name: str, mountpoint: str, mode: str) cinder.objects.volume_attachment.VolumeAttachment
attachment_create(ctxt: cinder.context.RequestContext, volume_ref: cinder.objects.volume.Volume, instance_uuid: str, connector: Optional[dict] = None, attach_mode: Optional[str] = 'null') cinder.objects.volume_attachment.VolumeAttachment

Create an attachment record for the specified volume.

attachment_delete(ctxt: cinder.context.RequestContext, attachment) cinder.objects.volume_attachment.VolumeAttachmentList
attachment_update(ctxt: cinder.context.RequestContext, attachment_ref: cinder.objects.volume_attachment.VolumeAttachment, connector) cinder.objects.volume_attachment.VolumeAttachment

Update an existing attachment record.

begin_detaching(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume) None
calculate_resource_count(context: cinder.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: context.RequestContext, volume: objects.Volume, metadata: dict[str, str], force: bool) dict[str, Optional[str]]

Create a new image from the specified volume.

create(context: cinder.context.RequestContext, size: Union[str, int], name: Optional[str], description: Optional[str], snapshot: Optional[cinder.objects.snapshot.Snapshot] = None, image_id: Optional[str] = None, volume_type: Optional[cinder.objects.volume_type.VolumeType] = None, metadata: Optional[dict] = None, availability_zone: Optional[str] = None, source_volume: Optional[cinder.objects.volume.Volume] = None, scheduler_hints=None, source_replica=None, consistencygroup: Optional[cinder.objects.consistencygroup.ConsistencyGroup] = None, cgsnapshot: Optional[cinder.objects.cgsnapshot.CGSnapshot] = None, multiattach: Optional[bool] = False, source_cg=None, group: Optional[cinder.objects.group.Group] = None, group_snapshot=None, source_group=None, backup: Optional[cinder.objects.backup.Backup] = None)
create_snapshot(context: context.RequestContext, volume: objects.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) objects.Snapshot
create_snapshot_force(context: context.RequestContext, volume: objects.Volume, name: str, description: str, metadata: Optional[dict[str, Any]] = None) objects.Snapshot
create_snapshot_in_db(context: cinder.context.RequestContext, volume: cinder.objects.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) cinder.objects.snapshot.Snapshot
create_snapshots_in_db(context: cinder.context.RequestContext, volume_list: list, name: str, description: str, cgsnapshot_id: str, group_snapshot_id: Optional[str] = None) list
create_volume_metadata(context: context.RequestContext, volume: objects.Volume, metadata: dict[str, Any]) dict

Creates volume metadata.

delete(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, force: bool = False, unmanage_only: bool = False, cascade: bool = False) None
delete_snapshot(context: cinder.context.RequestContext, snapshot: cinder.objects.snapshot.Snapshot, force: bool = False, unmanage_only: bool = False) None
delete_snapshot_metadata(context: cinder.context.RequestContext, snapshot: cinder.objects.snapshot.Snapshot, key: str) None

Delete the given metadata item from a snapshot.

delete_volume_metadata(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, key: str, meta_type=METADATA_TYPES.user) None

Delete the given metadata item from a volume.

detach(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, attachment_id: str) None
extend(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, new_size: int) None
extend_attached_volume(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, new_size: int) None
failover(ctxt: cinder.context.RequestContext, host: str, cluster_name: str, secondary_id: Optional[str] = None) None
freeze_host(ctxt: cinder.context.RequestContext, host: str, cluster_name: str) None
get(context: cinder.context.RequestContext, volume_id: str, viewable_admin_meta: bool = False) cinder.objects.volume.Volume
get_all(context: cinder.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) cinder.objects.volume.VolumeList
get_all_snapshots(context: 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) objects.SnapshotList
get_list_volumes_image_metadata(context: context.RequestContext, volume_id_list: list[str]) DefaultDict[str, str]
get_manageable_snapshots(context: 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: 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: cinder.context.RequestContext, snapshot_id: str) cinder.objects.snapshot.Snapshot
get_snapshot_metadata(context: cinder.context.RequestContext, snapshot: cinder.objects.snapshot.Snapshot) dict

Get all metadata associated with a snapshot.

get_volume(context: cinder.context.RequestContext, volume_id: str) cinder.objects.volume.Volume
get_volume_image_metadata(context: context.RequestContext, volume: objects.Volume) dict[str, str]
get_volume_metadata(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume) dict

Get all metadata associated with a volume.

get_volume_summary(context: cinder.context.RequestContext, filters: Optional[dict] = None) cinder.objects.volume.VolumeList
get_volumes_image_metadata(context: cinder.context.RequestContext) collections.defaultdict
initialize_connection(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, connector: dict) dict
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: cinder.context.RequestContext, host: str, cluster_name: Optional[str], ref: dict, name: Optional[str] = None, description: Optional[str] = None, volume_type: Optional[cinder.objects.volume_type.VolumeType] = None, metadata: Optional[dict] = None, availability_zone: Optional[str] = None, bootable: Optional[bool] = False) cinder.objects.volume.Volume
manage_existing_snapshot(context: cinder.context.RequestContext, ref: dict, volume: cinder.objects.volume.Volume, name: Optional[str] = None, description: Optional[str] = None, metadata: Optional[dict] = None) cinder.objects.snapshot.Snapshot
migrate_volume(context: cinder.context.RequestContext, volume: cinder.objects.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: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, new_volume: cinder.objects.volume.Volume, error: bool) str
reimage(context, volume, image_id, reimage_reserved=False)
reserve_volume(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume) None
retype(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, new_type: Union[str, cinder.objects.volume_type.VolumeType], migration_policy: Optional[str] = None) None

Attempt to modify the type associated with an existing volume.

revert_to_snapshot(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, snapshot: cinder.objects.snapshot.Snapshot) None

revert a volume to a snapshot

roll_detaching(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume) None
terminate_connection(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, connector: dict, force: bool = False) None
thaw_host(ctxt: cinder.context.RequestContext, host: str, cluster_name: str) Optional[str]
unreserve_volume(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume) None
update(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, fields: dict) None
update_readonly_flag(context: cinder.context.RequestContext, volume: cinder.objects.volume.Volume, flag) None
update_snapshot(context: context.RequestContext, snapshot: objects.Snapshot, fields: dict[str, Any]) None
update_snapshot_metadata(context: context.RequestContext, snapshot: objects.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: context.RequestContext, volume: objects.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: context.RequestContext, volume: objects.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: cinder.db.base.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.