Block Storage API

For details on how to use block_storage, see Using OpenStack Block Storage

The BlockStorage Class

The block_storage high-level interface is available through the block_storage member of a Connection object. The block_storage member will only be added if the service is detected.

Backup Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
backups(details=True, **query)

Retrieve a generator of backups

Parameters:
  • details – When set to False no additional details will be returned. The default, True, will cause objects with additional attributes to be returned.

  • query

    Optional query parameters to be sent to limit the resources being returned:

    • offset: pagination marker

    • limit: pagination limit

    • sort_key: Sorts by an attribute. A valid value is name, status, container_format, disk_format, size, id, created_at, or updated_at. Default is created_at. The API uses the natural sorting direction of the sort_key attribute value.

    • sort_dir: Sorts by one or more sets of attribute and sort direction combinations. If you omit the sort direction in a set, default is desc.

Returns:

A generator of backup objects.

get_backup(backup)

Get a backup

Parameters:

backup – The value can be the ID of a backup or a Backup instance.

Returns:

Backup instance

find_backup(name_or_id, ignore_missing=True, *, details=True)

Find a single backup

Parameters:
  • snapshot – The name or ID a backup

  • ignore_missing – When set to False NotFoundException will be raised when the backup does not exist.

  • details – When set to False no additional details will be returned. The default, True, will cause objects with additional attributes to be returned.

Returns:

One Backup

Raises:

NotFoundException when no resource can be found.

Raises:

DuplicateResource when multiple resources are found.

create_backup(**attrs)

Create a new Backup from attributes with native API

Parameters:

attrs – Keyword arguments which will be used to create a Backup comprised of the properties on the Backup class.

Returns:

The results of Backup creation

delete_backup(backup, ignore_missing=True, force=False)

Delete a CloudBackup

Parameters:
  • backup – The value can be the ID of a backup or a Backup instance

  • ignore_missing – When set to False NotFoundException will be raised when the zone does not exist. When set to True, no exception will be set when attempting to delete a nonexistent zone.

  • force – Whether to try forcing backup deletion

Returns:

None

import_backup(service, url)

Create a new backup from an external service.

Parameters:
  • service – The service used to perform the backup.

  • url – An identifier string to locate the backup.

Returns:

The imported backup

export_backup(backup)

Export information about a backup

Parameters:

backup – The value can be the ID of a backup or a Backup instance.

Returns:

The backup export record fields

restore_backup(backup, volume=None, name=None)

Restore a Backup to volume

Parameters:
  • backup – The value can be the ID of a backup or a Backup instance

  • volume – An ID or Volume instance of the volume to restore the backup to.

  • name – The name for new volume creation to restore.

Returns:

Updated backup instance

reset_backup_status(backup, status)

Reset status of the backup

Parameters:
  • backup – The value can be either the ID of a backup or a Backup instance.

  • status – New backup status

Returns:

None

Capabilities Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
get_capabilities(host)

Get a backend’s capabilites

Parameters:

host – Specified backend to obtain volume stats and properties.

Returns:

One :class: ~openstack.block_storage.v2.capabilites.Capabilities instance.

Raises:

NotFoundException when no resource can be found.

Consistency Group Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
get_consistency_group(consistency_group)

Get a consistency group.

Parameters:

consistency_group – The value can be either the ID of a consistency group or a ConsistencyGroup instance.

Returns:

One ConsistencyGroup

find_consistency_group(name_or_id, ignore_missing=True, *, details=True)

Find a single consistency group.

Parameters:
  • name_or_id – The name or ID of a consistency group.

  • ignore_missing – When set to False ResourceNotFound will be raised when the consistency group does not exist.

  • details – When set to False, no additional details will be returned. The default, True, will cause additional details to be returned.

Returns:

One ConsistencyGroup or None.

Raises:

ResourceNotFound when no resource can be found.

Raises:

DuplicateResource when multiple resources are found.

consistency_groups(*, details=True, **query)

Retrieve a generator of consistency groups.

Parameters:
  • details – When set to False, no additional details will be returned. The default, True, will cause additional details to be returned.

  • query

    Optional query parameters to be sent to limit the resources being returned:

    • limit: Returns a number of items up to the limit value.

    • offset: Used in conjunction with limit to return a slice of items. Specifies where to start in the list.

    • marker: The ID of the last-seen item.

    • sort_dir: Sorts the response in the requested order.

    • sort_key: Sorts the list of consistency groups by the specified attribute.

Returns:

A generator of consistency group objects.

create_consistency_group(**attrs)

Create a new consistency group.

Parameters:

attrs – Keyword arguments which will be used to create a ConsistencyGroup, comprised of the properties on the ConsistencyGroup class.

Returns:

The result of consistency group creation.

create_consistency_group_from_source(*, consistency_group_snapshot=None, consistency_group=None, name=None, description=None)

Create a new consistency group from source.

Parameters:
  • consistency_group_snapshot – The value can be either the ID of a consistency group snapshot or a ConsistencyGroupSnapshot instance. Either this or consistency_group must be provided.

  • consistency_group – The value can be either the ID of a consistency group or a ConsistencyGroup instance. Either this or consistency_group_snapshot must be provided.

  • name – The name to assign to the new consistency group.

  • description – The description to set on the new consistency group.

Returns:

The result of consistency group creation.

delete_consistency_group(consistency_group, force=False)

Delete a consistency group.

Parameters:
  • consistency_group – The value can be either the ID of a consistency group or a ConsistencyGroup instance.

  • force – When set to True, volumes in the consistency group will also be deleted when the consistency group is deleted.

Returns:

None

update_consistency_group(consistency_group, **attrs)

Update a consistency group.

Parameters:
  • consistency_group – The value can be either the ID of a consistency group or a ConsistencyGroup instance.

  • attrs – The attributes to update on the consistency group represented by consistency_group. To add or remove volumes, pass add_volumes or remove_volumes as comma-separated lists of volume IDs.

Returns:

The updated consistency group.

Consistency Group Snapshot Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
get_consistency_group_snapshot(consistency_group_snapshot)

Get a consistency group snapshot.

Parameters:

consistency_group_snapshot – The value can be either the ID of a consistency group snapshot or a ConsistencyGroupSnapshot instance.

Returns:

One ConsistencyGroupSnapshot

find_consistency_group_snapshot(name_or_id, ignore_missing=True, *, details=True)

Find a single consistency group snapshot.

Parameters:
  • name_or_id – The name or ID of a consistency group snapshot.

  • ignore_missing – When set to False ResourceNotFound will be raised when the consistency group snapshot does not exist.

  • details – When set to False, no additional details will be returned. The default, True, will cause additional details to be returned.

Returns:

One ConsistencyGroupSnapshot or None.

Raises:

ResourceNotFound when no resource can be found.

Raises:

DuplicateResource when multiple resources are found.

consistency_group_snapshots(*, details=True, **query)

Retrieve a generator of consistency group snapshots.

Parameters:
  • details – When set to False, no additional details will be returned. The default, True, will cause additional details to be returned.

  • query

    Optional query parameters to be sent to limit the resources being returned:

    • limit: Returns a number of items up to the limit value.

    • offset: Used in conjunction with limit to return a slice of items. Specifies where to start in the list.

    • marker: The ID of the last-seen item.

Returns:

A generator of consistency group snapshot objects.

create_consistency_group_snapshot(**attrs)

Create a new consistency group snapshot.

Parameters:

attrs – Keyword arguments which will be used to create a ConsistencyGroupSnapshot, comprised of the properties on the ConsistencyGroupSnapshot class. The consistencygroup_id attribute is required.

Returns:

The result of consistency group snapshot creation.

delete_consistency_group_snapshot(consistency_group_snapshot, ignore_missing=True)

Delete a consistency group snapshot.

Parameters:
  • consistency_group_snapshot – The value can be either the ID of a consistency group snapshot or a ConsistencyGroupSnapshot instance.

  • ignore_missing – When set to False ResourceNotFound will be raised when the consistency group snapshot does not exist.

Returns:

None

Extension Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
extensions()

Return a generator of extensions

Returns:

A generator of extension

Limits Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
get_limits(project=None)

Retrieves limits

Parameters:

project – A project to get limits for. The value can be either the ID of a project or an Project instance.

Returns:

A Limits object, including both AbsoluteLimit and RateLimit

QoSSpec Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
create_qos_spec(**attrs)

Create a new QoS Spec from attributes

Parameters:

attrs – Keyword arguments which will be used to create a QoSSpec, comprised of the properties on the QoSSpec class.

Returns:

The results of a QoS spec creation

Return type:

QoSSpec

delete_qos_spec(qos_spec, ignore_missing=True, *, force=False)

Delete a QoS Spec

Parameters:
  • qos_spec – The value can be either the ID of a QoS spec or a QoSSpec instance.

  • ignore_missing – When set to False ResourceNotFound will be raised when the type does not exist. When set to True, no exception will be set when attempting to delete a nonexistent type.

  • force – Whether to delete the QoS spec even if it’s in use.

Returns:

None

update_qos_spec(qos_spec, **attrs)

Update a QoS spec

Parameters:
  • qos_spec – The value can be either the ID of a QoS spec or a QoSSpec instance.

  • attrs (dict) – The attributes to update on the QoS spec

Returns:

The updated QoS spec

Return type:

QoSSpec

get_qos_spec(qos_spec)

Get a single QoS spec

Parameters:

qos_spec – The value can be either the ID of a QoS spec or a QoSSpec instance.

Returns:

One QoSSpec

Raises:

ResourceNotFound when no resource can be found.

find_qos_spec(name_or_id, ignore_missing=True, **query)

Find a single QoS spec

Parameters:
  • name_or_id – The name or ID of a QoS spec

  • ignore_missing – When set to False NotFoundException will be raised when the resource does not exist. When set to True, None will be returned when attempting to find a nonexistent resource.

  • query – Additional attributes like ‘host’

Returns:

One: class:~openstack.block_storage.v2.qos_spec.QoSSpec or None

Raises:

NotFoundException when no resource can be found.

Raises:

DuplicateResource when multiple resources are found.

qos_specs(**query)

Return a generator of QoS specs

Parameters:

query – Optional query parameters to be sent to limit the resources being returned.

Returns:

A generator of QoSSpec objects

associate_qos_spec(qos_spec, vol_type_id)

Associate a QoS spec with a volume type

Parameters:
  • qos_spec – The value can be either the ID of a QoS spec or a QoSSpec instance.

  • vol_type_id – The ID of the volume type to associate with.

Returns:

None

disassociate_qos_spec(qos_spec, vol_type_id)

Disassociate a QoS spec from a volume type

Parameters:
  • qos_spec – The value can be either the ID of a QoS spec or a QoSSpec instance.

  • vol_type_id – The ID of the volume type to disassociate from.

Returns:

None

disassociate_all_qos_spec(qos_spec)

Disassociate a QoS spec from all volume types

Parameters:

qos_spec – The value can be either the ID of a QoS spec or a QoSSpec instance.

Returns:

None

delete_qos_spec_metadata(qos_spec, keys)

Delete metadata from a QoS spec

Parameters:
  • qos_spec – The value can be either the ID of a QoS spec or a QoSSpec instance.

  • keys – The keys to delete from the QoS spec.

Returns:

None

qos_spec_associations(qos_spec)

Return a generator of associations for a QoS spec

Parameters:

qos_spec – The value can be either the ID of a QoS spec or a QoSSpec instance.

Returns:

A generator of QoSSpecAssociation objects

QuotaClassSet Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
get_quota_class_set(quota_class_set='default')

Get a single quota class set

Only one quota class is permitted, default.

Parameters:

quota_class_set – The value can be the ID of a quota class set (only default is supported) or a QuotaClassSet instance.

Returns:

One QuotaClassSet

Raises:

NotFoundException when no resource can be found.

update_quota_class_set(quota_class_set, **attrs)

Update a QuotaClassSet.

Only one quota class is permitted, default.

Parameters:
  • quota_class_set – Either the ID of a quota class set (only default is supported) or a QuotaClassSet instance.

  • attrs – The attributes to update on the QuotaClassSet represented by quota_class_set.

Returns:

The updated QuotaSet

QuotaSet Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
get_quota_set(project, usage=False, **query)

Show QuotaSet information for the project

Parameters:
  • project – ID or instance of Project of the project for which the quota should be retrieved

  • usage – When set to True quota usage and reservations would be filled.

  • query – Additional query parameters to use.

Returns:

One QuotaSet

Raises:

NotFoundException when no resource can be found.

get_quota_set_defaults(project)

Show QuotaSet defaults for the project

Parameters:

project – ID or instance of Project of the project for which the quota should be retrieved

Returns:

One QuotaSet

Raises:

NotFoundException when no resource can be found.

revert_quota_set(project, **query)

Reset Quota for the project/user.

Parameters:
  • project – ID or instance of Project of the project for which the quota should be resetted.

  • query – Additional parameters to be used.

Returns:

None

update_quota_set(project, **attrs)

Update a QuotaSet.

Parameters:
  • project – ID or instance of Project of the project for which the quota should be reset.

  • attrs – The attributes to update on the QuotaSet represented by quota_set.

Returns:

The updated QuotaSet

Service Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
find_service(name_or_id, ignore_missing=True, **query)

Find a single service

Parameters:
  • name_or_id – The name or ID of a service

  • ignore_missing – When set to False NotFoundException will be raised when the resource does not exist. When set to True, None will be returned when attempting to find a nonexistent resource.

  • query – Additional attributes like ‘host’

Returns:

One: class:~openstack.block_storage.v2.service.Service or None

Raises:

NotFoundException when no resource can be found.

Raises:

DuplicateResource when multiple resources are found.

services(**query)

Return a generator of service

Parameters:

query – Optional query parameters to be sent to limit the resources being returned.

Returns:

A generator of Service objects

enable_service(service)

Enable a service

Parameters:

service – Either the ID of a service or a Service instance.

Returns:

Updated service instance

disable_service(service, *, reason=None)

Disable a service

Parameters:
  • service – Either the ID of a service or a Service instance

  • reason – The reason to disable a service

Returns:

Updated service instance

thaw_service(service)

Thaw a service

Parameters:

service – Either the ID of a service or a Service instance

Returns:

Updated service instance

freeze_service(service)

Freeze a service

Parameters:

service – Either the ID of a service or a Service instance

Returns:

Updated service instance

failover_service(service, *, backend_id=None)

Failover a service

Only applies to replicating cinder-volume services.

Parameters:

service – Either the ID of a service or a Service instance

Returns:

Updated service instance

Snapshot Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
get_snapshot(snapshot)

Get a single snapshot

Parameters:

snapshot – The value can be the ID of a snapshot or a Snapshot instance.

Returns:

One Snapshot

Raises:

NotFoundException when no resource can be found.

find_snapshot(name_or_id, ignore_missing=True, *, details=True, all_projects=False)

Find a single snapshot

Parameters:
  • snapshot – The name or ID a snapshot

  • ignore_missing – When set to False NotFoundException will be raised when the snapshot does not exist. When set to True, None will be returned when attempting to find a nonexistent resource.

  • details – When set to False, an Snapshot object will be returned. The default, True, will cause an SnapshotDetail object to be returned.

  • all_projects – When set to True, search for snapshot by name across all projects. Note that this will likely result in a higher chance of duplicates. Admin-only by default.

Returns:

One Snapshot, one SnapshotDetail object, or None.

Raises:

NotFoundException when no resource can be found.

Raises:

DuplicateResource when multiple resources are found.

snapshots(*, details=True, all_projects=False, **query)

Retrieve a generator of snapshots

Parameters:
  • details – When set to False Snapshot objects will be returned. The default, True, will cause SnapshotDetail objects to be returned.

  • all_projects – When set to True, list snapshots from all projects. Admin-only by default.

  • query

    Optional query parameters to be sent to limit the snapshots being returned. Available parameters include:

    • name: Name of the snapshot as a string.

    • volume_id: volume id of a snapshot.

    • status: Value of the status of the snapshot so that you can filter on “available” for example.

Returns:

A generator of snapshot objects.

create_snapshot(**attrs)

Create a new snapshot from attributes

Parameters:

attrs – Keyword arguments which will be used to create a Snapshot, comprised of the properties on the Snapshot class.

Returns:

The results of snapshot creation

update_snapshot(snapshot, **attrs)

Update a snapshot

Parameters:
  • snapshot – Either the ID of a snapshot or a Snapshot instance.

  • attrs – The attributes to update on the snapshot.

Returns:

The updated snapshot

delete_snapshot(snapshot, ignore_missing=True, force=False)

Delete a snapshot

Parameters:
  • snapshot – The value can be either the ID of a snapshot or a Snapshot instance.

  • ignore_missing – When set to False NotFoundException will be raised when the snapshot does not exist. When set to True, no exception will be set when attempting to delete a nonexistent snapshot.

  • force – Whether to try forcing snapshot deletion.

Returns:

None

reset_snapshot_status(snapshot, status)

Reset status of the snapshot

Parameters:
  • snapshot – The value can be either the ID of a backup or a Snapshot instance.

  • status – New snapshot status

Returns:

None

manage_snapshot(**attrs)

Creates a snapshot by using existing storage rather than allocating new storage.

Parameters:

attrs – Keyword arguments which will be used to create a Snapshot, comprised of the properties on the Snapshot class.

Returns:

The results of snapshot creation

unmanage_snapshot(snapshot)

Unmanage a snapshot from block storage provisioning.

Parameters:

snapshot – Either the ID of a snapshot or a Snapshot.

Returns:

None

fetch_snapshot_metadata(snapshot)

Return a dictionary of metadata for a snapshot

Parameters:

snapshot – Either the ID of a snapshot or a Snapshot.

Returns:

A Snapshot with the snapshot’s metadata. All keys and values are Unicode text.

get_snapshot_metadata(snapshot)

Return a dictionary of metadata for a snapshot

Deprecated since version 4.14.0: Use fetch_snapshot_metadata() instead.

set_snapshot_metadata(snapshot, **metadata)

Update metadata for a snapshot

Parameters:
  • snapshot – Either the ID of a snapshot or a Snapshot.

  • metadata – Key/value pairs to be updated in the snapshot’s metadata. No other metadata is modified by this call. All keys and values are stored as Unicode.

Returns:

A Snapshot with the snapshot’s metadata. All keys and values are Unicode text.

delete_snapshot_metadata(snapshot, keys=None)

Delete metadata for a snapshot

Parameters:
  • snapshot – Either the ID of a snapshot or a Snapshot.

  • keys – The keys to delete. If omitted, all metadata is removed.

Returns:

None

Stats Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
backend_pools(**query)

Returns a generator of cinder Back-end storage pools

Parameters:

query – Optional query parameters to be sent to limit the resources being returned.

:returns A generator of cinder Back-end storage pools objects

Transfer Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
create_transfer(**attrs)

Create a new Transfer record

Parameters:
  • volume_id – The value is ID of the volume.

  • name – The value is name of the transfer

  • attrs – Keyword arguments which will be used to create a Transfer comprised of the properties on the Transfer class.

Returns:

The results of Transfer creation

delete_transfer(transfer, ignore_missing=True)

Delete a volume transfer

Parameters:
  • transfer – The value can be either the ID of a transfer or a Transfer` instance.

  • ignore_missing – When set to False NotFoundException will be raised when the transfer does not exist. When set to True, no exception will be set when attempting to delete a nonexistent transfer.

Returns:

None

find_transfer(name_or_id, ignore_missing=True)

Find a single transfer

Parameters:
  • name_or_id – The name or ID a transfer

  • ignore_missing – When set to False NotFoundException will be raised when the volume transfer does not exist.

Returns:

One Transfer

Raises:

NotFoundException when no resource can be found.

Raises:

DuplicateResource when multiple resources are found.

get_transfer(transfer)

Get a single transfer

Parameters:

transfer – The value can be the ID of a transfer or a Transfer instance.

Returns:

One Transfer

Raises:

NotFoundException when no resource can be found.

transfers(*, details=True, all_projects=False, **query)

Retrieve a generator of transfers

Parameters:
  • details – When set to False no extended attributes will be returned. The default, True, will cause objects with additional attributes to be returned.

  • all_projects – When set to True, list transfers from all projects. Admin-only by default.

  • query – Optional query parameters to be sent to limit the transfers being returned.

Returns:

A generator of transfer objects.

accept_transfer(transfer, auth_key)

Accept a Transfer

Parameters:
  • transfer – The value can be the ID of a transfer or a Transfer instance.

  • auth_key – The key to authenticate volume transfer.

Returns:

The results of Transfer creation

Type Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
get_type(type)

Get a single type

Parameters:

type – The value can be the ID of a type or a Type instance.

Returns:

One Type

Raises:

NotFoundException when no resource can be found.

find_type(name_or_id, ignore_missing=True)

Find a single volume type

Parameters:
  • snapshot – The name or ID a volume type

  • ignore_missing – When set to False ResourceNotFound will be raised when the volume type does not exist.

Returns:

One Type

Raises:

ResourceNotFound when no resource can be found.

Raises:

DuplicateResource when multiple resources are found.

types(**query)

Retrieve a generator of volume types

Returns:

A generator of volume type objects.

create_type(**attrs)

Create a new type from attributes

Parameters:

attrs – Keyword arguments which will be used to create a Type, comprised of the properties on the Type class.

Returns:

The results of type creation

delete_type(type, ignore_missing=True)

Delete a type

Parameters:
  • type – The value can be either the ID of a type or a Type instance.

  • ignore_missing – When set to False NotFoundException will be raised when the type does not exist. When set to True, no exception will be set when attempting to delete a nonexistent type.

Returns:

None

update_type(type, **attrs)

Update a type

Parameters:
  • type – The value can be either the ID of a type or a Type instance.

  • attrs – The attributes to update on the type

Returns:

The updated type

update_type_extra_specs(type, **attrs)

Update the extra_specs for a type

Parameters:
  • type – The value can be either the ID of a type or a Type instance.

  • attrs – The extra spec attributes to update on the type

Returns:

A dict containing updated extra_specs

delete_type_extra_specs(type, keys)

Delete the extra_specs for a type

Note: This method will do a HTTP DELETE request for every key in keys.

Parameters:
  • type – The value can be either the ID of a type or a Type instance.

  • keys – The keys to delete.

Returns:

None

get_type_access(type)

Lists project IDs that have access to private volume type.

Parameters:

type – The value can be either the ID of a type or a Type instance.

Returns:

List of dictionaries describing projects that have access to the specified type

add_type_access(type, project)

Adds private volume type access to a project.

Parameters:
  • type – The value can be either the ID of a type or a Type instance.

  • project – An ID or Project instance of the project to add access for.

Returns:

None

remove_type_access(type, project)

Remove private volume type access from a project.

Parameters:
  • type – The value can be either the ID of a type or a Type instance.

  • project – An ID or Project instance of the project to remove access for.

Returns:

None

get_type_encryption(volume_type)

Get the encryption details of a volume type

Parameters:

volume_type – The value can be the ID of a type or a Type instance.

Returns:

One TypeEncryption

Raises:

NotFoundException when no resource can be found.

create_type_encryption(volume_type, **attrs)

Create new type encryption from attributes

Parameters:
  • volume_type – The value can be the ID of a type or a Type instance.

  • attrs – Keyword arguments which will be used to create a TypeEncryption, comprised of the properties on the TypeEncryption class.

Returns:

The results of type encryption creation

delete_type_encryption(encryption=None, volume_type=None, ignore_missing=True)

Delete type encryption attributes

Parameters:
  • encryption – The value can be None or a TypeEncryption instance. If encryption is None then volume_type must be specified.

  • volume_type – The value can be the ID of a type or a Type instance. Required if encryption is None.

  • ignore_missing – When set to False NotFoundException will be raised when the type does not exist. When set to True, no exception will be set when attempting to delete a nonexistent type.

Returns:

None

update_type_encryption(encryption=None, volume_type=None, **attrs)

Update a type

Parameters:
  • encryption – The value can be None or a TypeEncryption instance. If this is None then volume_type must be specified.

  • volume_type – The value can be the ID of a type or a Type instance. Required if encryption is None.

  • attrs – The attributes to update on the type encryption.

Returns:

The updated type encryption

Volume Operations

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
get_volume(volume)

Get a single volume

Parameters:

volume – The value can be the ID of a volume or a Volume instance.

Returns:

One Volume

Raises:

NotFoundException when no resource can be found.

find_volume(name_or_id, ignore_missing=True, *, details=True, all_projects=False)

Find a single volume

Parameters:
  • volume – The name or ID a volume

  • ignore_missing – When set to False NotFoundException will be raised when the volume does not exist.

  • details – When set to False no extended attributes will be returned. The default, True, will cause an object with additional attributes to be returned.

  • all_projects – When set to True, search for volume by name across all projects. Note that this will likely result in a higher chance of duplicates. Admin-only by default.

Returns:

One Volume or None.

Raises:

NotFoundException when no resource can be found.

Raises:

DuplicateResource when multiple resources are found.

volumes(*, details=True, all_projects=False, **query)

Retrieve a generator of volumes

Parameters:
  • details – When set to False no extended attributes will be returned. The default, True, will cause objects with additional attributes to be returned.

  • all_projects – When set to True, list volumes from all projects. Admin-only by default.

  • query

    Optional query parameters to be sent to limit the volumes being returned. Available parameters include:

    • name: Name of the volume as a string.

    • status: Value of the status of the volume so that you can filter on “available” for example.

Returns:

A generator of volume objects.

create_volume(**attrs)

Create a new volume from attributes

Parameters:

attrs – Keyword arguments which will be used to create a Volume, comprised of the properties on the Volume class.

Returns:

The results of volume creation

update_volume(volume, **attrs)

Update a volume

Parameters:
  • volume – Either the ID of a volume or a Volume instance.

  • attrs – The attributes to update on the volume.

Returns:

The updated volume

delete_volume(volume, ignore_missing=True, *, force=False, cascade=False)

Delete a volume

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • ignore_missing – When set to False NotFoundException will be raised when the volume does not exist. When set to True, no exception will be set when attempting to delete a nonexistent volume.

  • force – Whether to try forcing volume deletion.

  • cascade – Whether to remove any snapshots along with the volume.

Returns:

None

extend_volume(volume, size)

Extend a volume

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • size – New volume size

Returns:

None

set_volume_readonly(volume, readonly=True)

Set a volume’s read-only flag.

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • readonly – Whether the volume should be a read-only volume or not.

Returns:

None

retype_volume(volume, new_type, migration_policy='never')

Retype the volume.

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • new_type – The new volume type that volume is changed with. The value can be either the ID of the volume type or a Type instance.

  • migration_policy – Specify if the volume should be migrated when it is re-typed. Possible values are on-demand or never. Default: never.

Returns:

None

set_volume_bootable_status(volume, bootable)

Set bootable status of the volume.

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • bootable – Specifies whether the volume should be bootable or not.

Returns:

None

set_volume_image_metadata(volume, **metadata)

Update image metadata for a volume

Parameters:
  • volume – Either the ID of a volume or a Volume.

  • metadata – Key/value pairs to be updated in the volume’s image metadata. No other metadata is modified by this call.

Returns:

None

delete_volume_image_metadata(volume, keys=None)

Delete metadata for a volume

Parameters:
  • volume – Either the ID of a volume or a Volume.

  • keys – The keys to delete. If omitted, all metadata is removed.

Returns:

None

reset_volume_status(volume, status=None, attach_status=None, migration_status=None)

Reset volume statuses.

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • status – The new volume status.

  • attach_status – The new volume attach status.

  • migration_status – The new volume migration status (admin only).

Returns:

None

attach_volume(volume, mountpoint, instance=None, host_name=None)

Attaches a volume to a server.

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • mountpoint – The attaching mount point.

  • instance – The UUID of the attaching instance.

  • host_name – The name of the attaching host.

Returns:

None

detach_volume(volume, attachment, force=False, connector=None)

Detaches a volume from a server.

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • attachment – The ID of the attachment.

  • force – Whether to force volume detach (Rolls back an unsuccessful detach operation after you disconnect the volume.)

  • connector – The connector object.

Returns:

None

unmanage_volume(volume)
Removes a volume from Block Storage management without removing the

back-end storage object that is associated with it.

Parameters:

volume – The value can be either the ID of a volume or a Volume instance.

Returns:

None

migrate_volume(volume, host=None, force_host_copy=False, lock_volume=False)

Migrates a volume to the specified host.

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • host – The target host for the volume migration. Host format is host@backend.

  • force_host_copy – If false (the default), rely on the volume backend driver to perform the migration, which might be optimized. If true, or the volume driver fails to migrate the volume itself, a generic host-based migration is performed.

  • lock_volume – If true, migrating an available volume will change its status to maintenance preventing other operations from being performed on the volume such as attach, detach, retype, etc.

Returns:

None

complete_volume_migration(volume, new_volume, error=False)

Complete the migration of a volume.

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • new_volume – The UUID of the new volume.

  • error – Used to indicate if an error has occured elsewhere that requires clean up.

Returns:

None

upload_volume_to_image(volume, image_name, force=False, disk_format=None, container_format=None)

Uploads the specified volume to image service.

Parameters:
  • volume – The value can be either the ID of a volume or a Volume instance.

  • image_name – The name for the new image.

  • force – Enables or disables upload of a volume that is attached to an instance.

  • disk_format – Disk format for the new image.

  • container_format – Container format for the new image.

Returns:

dictionary describing the image.

fetch_volume_metadata(volume)

Return a dictionary of metadata for a volume

Parameters:

volume – Either the ID of a volume or a Volume.

Returns:

A Volume with the volume’s metadata. All keys and values are Unicode text.

get_volume_metadata(volume)

Return a dictionary of metadata for a volume

Deprecated since version 4.14.0: Use fetch_volume_metadata() instead.

set_volume_metadata(volume, **metadata)

Update metadata for a volume

Parameters:
  • volume – Either the ID of a volume or a Volume.

  • metadata – Key/value pairs to be updated in the volume’s metadata. No other metadata is modified by this call. All keys and values are stored as Unicode.

Returns:

A Volume with the volume’s metadata. All keys and values are Unicode text.

delete_volume_metadata(volume, keys=None)

Delete metadata for a volume

Parameters:
  • volume – Either the ID of a volume or a Volume.

  • keys – The keys to delete. If omitted, all metadata is removed.

Returns:

None

Helpers

class openstack.block_storage.v2._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
wait_for_status(res, status='available', failures=None, interval=2, wait=None, attribute='status', callback=None)

Wait for the resource to be in a particular status.

Parameters:
  • session – The session to use for making this request.

  • resource – The resource to wait on to reach the status. The resource must have a status attribute specified via attribute.

  • status – Desired status of the resource.

  • failures – Statuses that would indicate the transition failed such as ‘ERROR’. Defaults to [‘ERROR’].

  • interval – Number of seconds to wait between checks.

  • wait – Maximum number of seconds to wait for transition. Set to None to wait forever.

  • attribute – Name of the resource attribute that contains the status.

  • callback – A callback function. This will be called with a single value, progress. This is API specific but is generally a percentage value from 0-100.

Returns:

The updated resource.

Raises:

ResourceTimeout if the transition to status failed to occur in wait seconds.

Raises:

ResourceFailure if the resource transitioned to one of the states in failures.

Raises:

AttributeError if the resource does not have a status attribute

wait_for_delete(res, interval=2, wait=120, callback=None)

Wait for a resource to be deleted.

Parameters:
  • res – The resource to wait on to be deleted.

  • interval – Number of seconds to wait before to consecutive checks.

  • wait – Maximum number of seconds to wait before the change.

  • callback – A callback function. This will be called with a single value, progress, which is a percentage value from 0-100.

Returns:

The resource is returned on success.

Raises:

ResourceTimeout if transition to delete failed to occur in the specified seconds.