For details on how to use block_storage, see Using OpenStack Block Storage
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.
Get a single volume
Find a single volume
snapshot – The name or ID a volume
ignore_missing (bool) – When set to False
ResourceNotFound
will be raised
when the volume does not exist.
One Volume
ResourceNotFound
when no resource can be found.
Retrieve a generator of volumes
details (bool) – When set to False
no extended attributes
will be returned. The default, True
, will cause objects with
additional attributes to be returned.
query (kwargs) –
Optional query parameters to be sent to limit the volumes being returned. Available parameters include:
name: Name of the volume as a string.
all_projects: Whether return the volumes in all projects
status: Value of the status of the volume so that you can filter on “available” for example.
A generator of volume objects.
Create a new volume from attributes
Delete a volume
volume – The value can be either the ID of a volume or a
Volume
instance.
ignore_missing (bool) – When set to False
ResourceNotFound
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 (bool) – Whether to try forcing volume deletion.
None
Return a dictionary of metadata for a volume
Update metadata for a volume
volume – Either the ID of a volume or a
Volume
.
metadata (kwargs) – 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.
A Volume
with the
volume’s metadata. All keys and values are Unicode text.
Delete metadata for a volume
volume – Either the ID of a volume or a
Volume
.
keys (list) – The keys to delete. If left empty complete metadata will be removed.
None
Extend a volume
volume – The value can be either the ID of a volume or a
Volume
instance.
size – New volume size
None
Set a volume’s read-only flag.
volume – The value can be either the ID of a volume or a
Volume
instance.
readonly (bool) – Whether the volume should be a read-only volume or not.
None
Retype the volume.
volume – The value can be either the ID of a volume or a
Volume
instance.
new_type (str) – The new volume type that volume is changed with.
migration_policy (str) – Specify if the volume should be migrated when it is re-typed. Possible values are on-demand or never. Default: never.
None
Set bootable status of the volume.
volume – The value can be either the ID of a volume or a
Volume
instance.
bootable (bool) – Specifies whether the volume should be bootable or not.
None
Reset volume statuses.
volume – The value can be either the ID of a volume or a
Volume
instance.
status (str) – The new volume status.
attach_status (str) – The new volume attach status.
migration_status (str) – The new volume migration status (admin only).
None
Revert a volume to its latest snapshot.
This method only support reverting a detached volume, and the volume status must be available.
Attaches a volume to a server.
volume – The value can be either the ID of a volume or a
Volume
instance.
mountpoint (str) – The attaching mount point.
instance (str) – The UUID of the attaching instance.
host_name (str) – The name of the attaching host.
None
Detaches a volume from a server.
volume – The value can be either the ID of a volume or a
Volume
instance.
attachment (str) – The ID of the attachment.
force (bool) – Whether to force volume detach (Rolls back an unsuccessful detach operation after you disconnect the volume.)
connector (dict) – The connector object.
None
back-end storage object that is associated with it.
volume – The value can be either the ID of a volume or a
Volume
instance.
None
Migrates a volume to the specified host.
volume – The value can be either the ID of a volume or a
Volume
instance.
host (str) – The target host for the volume migration. Host format is host@backend.
force_host_copy (bool) – 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 (bool) – 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.
cluster (str) – The target cluster for the volume migration. Cluster format is cluster@backend. Starting with microversion 3.16, either cluster or host must be specified. If host is specified and is part of a cluster, the cluster is used as the target for the migration.
None
Complete the migration of a volume.
volume – The value can be either the ID of a volume or a
Volume
instance.
new_volume (str) – The UUID of the new volume.
error (bool) – Used to indicate if an error has occured elsewhere that requires clean up.
None
Uploads the specified volume to image service.
volume – The value can be either the ID of a volume or a
Volume
instance.
name (str image) – The name for the new image.
force (bool) – Enables or disables upload of a volume that is attached to an instance.
disk_format (str) – Disk format for the new image.
container_format (str) – Container format for the new image.
visibility (str) – The visibility property of the new image.
protected (str) – Whether the new image is protected.
dictionary describing the image.
Mark volume as reserved.
volume – The value can be either the ID of a volume or a
Volume
instance.
None
Unmark volume as reserved.
volume – The value can be either the ID of a volume or a
Volume
instance.
None
Update volume status to ‘detaching’.
volume – The value can be either the ID of a volume or a
Volume
instance.
None
Update volume status to ‘in-use’.
volume – The value can be either the ID of a volume or a
Volume
instance.
None
Initialize volume attachment.
volume – The value can be either the ID of a volume or a
Volume
instance.
connector (dict) – The connector object.
None
Update volume status to ‘in-use’.
volume – The value can be either the ID of a volume or a
Volume
instance.
connector (dict) – The connector object.
None
Returns a generator of cinder Back-end storage pools
query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
:returns A generator of cinder Back-end storage pools objects
Retrieve a generator of backups
details (bool) – When set to False
no additional details will be returned. The default, True
,
will cause objects with additional attributes to be returned.
query (dict) –
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.
project_id: Project ID to query backups for.
A generator of backup objects.
Get a backup
Find a single backup
snapshot – The name or ID a backup
ignore_missing (bool) – When set to False
ResourceNotFound
will be raised
when the backup does not exist.
One Backup
ResourceNotFound
when no resource can be found.
Create a new Backup from attributes with native API
Delete a CloudBackup
backup – The value can be the ID of a backup or a
Backup
instance
ignore_missing (bool) – When set to False
ResourceNotFound
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 (bool) – Whether to try forcing backup deletion
None
Restore a Backup to volume
Reset status of the backup
backup – The value can be either the ID of a backup or a
Backup
instance.
status (str) – New backup status
None
Return a generator of availability zones
A generator of availability zone
AvailabilityZone
Retrieves limits
A Limit object, including both
AbsoluteLimit
and
RateLimit
Limit
Get a backend’s capabilites
host – Specified backend to obtain volume stats and properties.
One :class: ~openstack.block_storage.v3.capabilites.Capabilities instance.
ResourceNotFound
when no
resource can be found.
Get a group
group_id – The ID of the group to get.
attrs (dict) – Optional query parameters to be sent to limit the resources being returned.
A Group instance.
group
Find a single group
name_or_id – The name or ID of a group.
ignore_missing (bool) – When set to False
ResourceNotFound
will be raised
when the group snapshot does not exist.
One Group
ResourceNotFound
when no resource can be found.
Retrieve a generator of groups
details (bool) – When set to False
, no additional details will
be returned. The default, True
, will cause additional details
to be returned.
query (dict) –
Optional query parameters to be sent to limit the resources being returned:
all_tenants: Shows details for all project.
sort: Comma-separated list of sort keys and optional sort directions.
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.
list_volume: Show volume ids in this group.
detailed: If True, will list groups with details.
search_opts: Search options.
A generator of group objects.
Create a new group from attributes
attrs (dict) – Keyword arguments which will be used to create
a Group
comprised of
the properties on the Group class.
The results of group creation.
Group
.
Creates a new group from source
attrs (dict) – Keyword arguments which will be used to create
a Group
comprised of
the properties on the Group class.
The results of group creation.
Group
.
Reset group status
group – The Group
to set the state.
status – The status for a group.
None
Delete a group
group – The Group
to
delete.
delete_volumes (bool) – When set to True
, volumes in group
will be deleted.
None
.
Update a group
group – The value can be the ID of a group or a
Group
instance.
attrs (dict) – The attributes to update on the group.
The updated group
Group
Get a specific group type
group_type – The value can be the ID of a group type
or a GroupType
instance.
One :class: ~openstack.block_storage.v3.group_type.GroupType instance.
ResourceNotFound
when no
resource can be found.
Find a single group type
name_or_id – The name or ID of a group type.
ignore_missing (bool) – When set to False
ResourceNotFound
will be raised
when the group type does not exist.
One
GroupType
ResourceNotFound
when no
resource can be found.
Retrive a generator of group types
query (dict) –
Optional query parameters to be sent to limit the resources being returned:
sort: Comma-separated list of sort keys and optional sort directions in the form of <key> [:<direction>]. A valid direction is asc (ascending) or desc (descending).
limit: Requests a page size of items. Returns a number of items up to a limit value. Use the limit parameter to make an initial limited request and use the ID of the last-seen item from the response as the marker parameter value in a subsequent limited request.
offset: Used in conjunction with limit to return a slice of items. Is where to start in the list.
marker: The ID of the last-seen item.
A generator of group type objects.
Create a group type
attrs (dict) – Keyword arguments which will be used to create
a GroupType
comprised of the properties on the GroupType class.
The results of group type creation.
GroupTye
.
Delete a group type
group_type – The value can be the ID of a group type
or a GroupType
instance.
ignore_missing (bool) – When set to False
ResourceNotFound
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.
‘’None’’
Update a group_type
group_type – The value can be the ID of a group type or a
GroupType
instance.
attrs (dict) – The attributes to update on the group type.
The updated group type.
GroupType
Lists group specs of a group type.
group_type – Either the ID of a group type or a
GroupType
instance.
One GroupType
Create group specs for a group type.
group_type – Either the ID of a group type or a
GroupType
instance.
group_specs (dict) – dict of extra specs
One GroupType
Retrieve a group spec property for a group type.
group_type – Either the ID of a group type or a
GroupType
instance.
prop (str) – Property name.
String value of the requested property.
Update a group spec property for a group type.
group_type – Either the ID of a group type or a
GroupType
instance.
prop (str) – Property name.
val (str) – Property value.
String value of the requested property.
Delete a group spec property from a group type.
group_type – Either the ID of a group type or a
GroupType
instance.
prop (str) – Property name.
None
Get a single type
Find a single volume type
snapshot – The name or ID a volume type
ignore_missing (bool) – When set to False
ResourceNotFound
will be raised
when the type does not exist.
One Type
ResourceNotFound
when no resource can be found.
Retrieve a generator of volume types
A generator of volume type objects.
Create a new type from attributes
Delete a type
type – The value can be either the ID of a type or a
Type
instance.
ignore_missing (bool) – 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.
None
Update a type
Update the extra_specs for a type
type – The value can be either the ID of a type or a
Type
instance.
attrs (dict) – The extra spec attributes to update on the type
A dict containing updated extra_specs
Delete the extra_specs for a type
Note: This method will do a HTTP DELETE request for every key in keys.
type – The value can be either the ID of a type or a
Type
instance.
keys – The keys to delete
None
Lists project IDs that have access to private volume type.
type – The value can be either the ID of a type or a
Type
instance.
List of dictionaries describing projects that have access to the specified type
Adds private volume type access to a project.
type – The value can be either the ID of a type or a
Type
instance.
project_id (str) – The ID of the project. Volume Type access to be added to this project ID.
None
Remove private volume type access from a project.
type – The value can be either the ID of a type or a
Type
instance.
project_id (str) – The ID of the project. Volume Type access to be removed to this project ID.
None
Get the encryption details of a volume type
volume_type_id – The value can be the ID of a type or a
Type
instance.
One TypeEncryption
ResourceNotFound
when no resource can be found.
Create new type encryption from attributes
volume_type – The value can be the ID of a type or a
Type
instance.
attrs (dict) – Keyword arguments which will be used to create
a TypeEncryption
,
comprised of the properties on the TypeEncryption class.
The results of type encryption creation
TypeEncryption
Delete type encryption attributes
encryption – The value can be None or a
TypeEncryption
instance. If encryption_id is None then
volume_type_id must be specified.
volume_type – The value can be the ID of a type or a
Type
instance. Required if encryption_id is None.
ignore_missing (bool) – 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.
None
Update a type
encryption – The value can be None or a
TypeEncryption
instance. If this is None
then volume_type_id
must be
specified.
volume_type – The value can be the ID of a type or a
Type
instance.
Required if encryption_id
is None.
attrs (dict) – The attributes to update on the type encryption.
The updated type encryption
TypeEncryption
Get a single snapshot
Find a single snapshot
snapshot – The name or ID a snapshot
ignore_missing (bool) – When set to False
ResourceNotFound
will be raised
when the snapshot does not exist.
One Snapshot
ResourceNotFound
when no resource can be found.
Retrieve a generator of snapshots
details (bool) – When set to False
:class:
~openstack.block_storage.v3.snapshot.Snapshot
objects will be returned. The default, True
, will cause
more attributes to be returned.
query (kwargs) –
Optional query parameters to be sent to limit the snapshots being returned. Available parameters include:
name: Name of the snapshot as a string.
all_projects: Whether return the snapshots in all projects.
project_id: Filter the snapshots by project.
volume_id: volume id of a snapshot.
status: Value of the status of the snapshot so that you can filter on “available” for example.
A generator of snapshot objects.
Create a new snapshot from attributes
Update a snapshot
Delete a snapshot
snapshot – The value can be either the ID of a snapshot or a
Snapshot
instance.
ignore_missing (bool) – When set to False
ResourceNotFound
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 (bool) – Whether to try forcing snapshot deletion.
None
Return a dictionary of metadata for a snapshot
Update metadata for a snapshot
snapshot – Either the ID of a snapshot or a
Snapshot
.
metadata (kwargs) – 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.
A
Snapshot
with the
snapshot’s metadata. All keys and values are Unicode text.
Delete metadata for a snapshot
snapshot – Either the ID of a snapshot or a
Snapshot
.
keys (list) – The keys to delete. If left empty complete metadata will be removed.
None
Reset status of the snapshot
snapshot – The value can be either the ID of a backup or a
Snapshot
instance.
status (str) – New snapshot status
None
Update fields related to the status of a snapshot.
snapshot – The value can be either the ID of a backup or a
Snapshot
instance.
status (str) – New snapshot status
progress (str) – A percentage value for snapshot build progress.
None
Returns a generator of cinder Back-end storage pools
query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
:returns A generator of cinder Back-end storage pools objects
Show quota set information for the project
project – ID or instance of
Project
of the project for
which the quota should be retrieved
usage (bool) – When set to True
quota usage and reservations
would be filled.
query (dict) – Additional query parameters to use.
One QuotaSet
ResourceNotFound
when no resource can be found.
Show quota set defaults for the project
project – ID or instance of
Project
of the project for
which the quota should be retrieved
One QuotaSet
ResourceNotFound
when no resource can be found.
Reset quota for the project/user.
project – ID or instance of
Project
of the project for
which the quota should be resetted.
query (dict) – Additional parameters to be used.
None
Update a quota set.
Wait for a resource to be in a particular status.
res – The resource to wait on to reach the specified status.
The resource must have a status
attribute.
status – Desired status.
failures (list
) – Statuses that would be interpreted as failures.
interval – Number of seconds to wait before to consecutive checks. Default to 2.
wait – Maximum number of seconds to wait before the change. Default to 120.
The resource is returned on success.
ResourceTimeout
if transition
to the desired status failed to occur in specified seconds.
ResourceFailure
if the resource
has transited to one of the failure statuses.
AttributeError
if the resource does not have a
status
attribute.
Wait for a resource to be deleted.
res – The resource to wait on to be deleted.
interval – Number of seconds to wait before to consecutive checks. Default to 2.
wait – Maximum number of seconds to wait before the change. Default to 120.
The resource is returned on success.
ResourceTimeout
if transition
to delete failed to occur in the specified seconds.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.