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.
Volume Operations¶
- class openstack.block_storage.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- get_volume(volume)
Get a single volume
- volumes(details=True, **query)
Retrieve a generator of volumes
- Parameters
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.
- Returns
A generator of volume objects.
- create_volume(**attrs)
Create a new volume from attributes
- delete_volume(volume, ignore_missing=True, force=False)
Delete a volume
- Parameters
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 toTrue
, no exception will be set when attempting to delete a nonexistent volume.force (bool) – Whether to try forcing volume deletion.
- Returns
None
Backup Operations¶
- class openstack.block_storage.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- backups(details=True, **query)
Retrieve a generator of backups
- Parameters
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.
- Returns
A generator of backup objects.
- get_backup(backup)
Get a backup
- create_backup(**attrs)
Create a new Backup from attributes with native API
- 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
instanceignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the zone does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent zone.force (bool) – Whether to try forcing backup deletion
- Returns
None
- restore_backup(backup, volume_id, name)
Restore a Backup to volume
Type Operations¶
- class openstack.block_storage.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- get_type(type)
Get a single type
- types(**query)
Retrieve a generator of volume types
- Returns
A generator of volume type objects.
- create_type(**attrs)
Create a new type from attributes
- 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 (bool) – When set to
False
ResourceNotFound
will be raised when the type does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent type.
- Returns
None
Snapshot Operations¶
- class openstack.block_storage.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- get_snapshot(snapshot)
Get a single snapshot
- snapshots(details=True, **query)
Retrieve a generator of snapshots
- Parameters
details (bool) – When set to
False
Snapshot
objects will be returned. The default,True
, will causeSnapshotDetail
objects 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.
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
- delete_snapshot(snapshot, ignore_missing=True)
Delete a snapshot
- Parameters
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 toTrue
, no exception will be set when attempting to delete a nonexistent snapshot.
- Returns
None
Stats Operations¶
- class openstack.block_storage.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- backend_pools(**query)
Returns a generator of cinder Back-end storage pools
- Parameters
query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
:returns A generator of cinder Back-end storage pools objects
QuotaSet Operations¶
- class openstack.block_storage.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- 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 retrievedusage (bool) – When set to
True
quota usage and reservations would be filled.query (dict) – Additional query parameters to use.
- Returns
One
QuotaSet
- Raises
ResourceNotFound
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
ResourceNotFound
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 (dict) – Additional parameters to be used.
- Returns
None
- update_quota_set(quota_set, query=None, **attrs)
Update a QuotaSet.