Defines interface for DB access.
The underlying driver is loaded as a LazyPluggable.
Functions in this module are imported into the cinder.db namespace. Call these functions from cinder.db namespace, not the cinder.db.api namespace.
All functions in this module return objects that implement a dictionary-like interface. Currently, many of these objects are sqlalchemy objects that implement a dictionary interface. However, a future goal is to have all of these objects be simple dictionaries.
Related Flags
db_backend: | string to lookup in the list of LazyPluggable backends. sqlalchemy is the only supported backend right now. |
---|---|
sql_connection: | string specifying the sqlalchemy connection to use, like: sqlite:///var/lib/cinder/cinder.sqlite. |
enable_new_services: | |
when adding a new service to the database, is it in the pool of available hardware (Default: True) |
Bases: cinder.exception.CinderException
No more available targets
Return count of export devices.
Create an iscsi_target from the values dictionary.
The device is not returned. If the create violates the unique constraints because the iscsi_target and host already exist, no exception is raised.
Create a migration record.
Finds a migration by the id.
Finds all unconfirmed migrations within the confirmation window.
Finds a migration by the instance uuid its migrating.
Update a migration instance.
Create a quota class for the given name and resource.
Destroy the quota class or raise if it does not exist.
Destroy all quotas associated with a given quota class.
Retrieve a quota class or raise if it does not exist.
Retrieve all quotas associated with a given quota class.
Update a quota class or raise if it does not exist.
Create a quota for the given project and resource.
Destroy the quota or raise if it does not exist.
Destroy all quotas associated with a given project.
Retrieve a quota or raise if it does not exist.
Retrieve all quotas associated with a given project.
Check quotas and create appropriate reservations.
Update a quota or raise if it does not exist.
Create a quota usage for the given project and resource.
Destroy the quota usage or raise if it does not exist.
Retrieve a quota usage or raise if it does not exist.
Retrieve all usage associated with a given resource.
Update a quota usage or raise if it does not exist.
Commit quota reservations.
Create a reservation for the given project and resource.
Destroy the reservation or raise if it does not exist.
Roll back any expired reservations.
Retrieve a reservation or raise if it does not exist.
Retrieve all reservations associated with a given project.
Roll back quota reservations.
Create a service from the values dictionary.
Destroy the service or raise if it does not exist.
Get a service or raise if it does not exist.
Get all services.
Get all services for a given host.
Get all services for a given topic.
Get all volume services sorted by volume count.
Returns: | a list of (Service, volume_count) tuples. |
---|
Get the state of an service by node name and binary.
Get a service by host it’s on and topic it listens to.
Set the given properties on an service and update it.
Raises NotFound if service does not exist.
Create a new SM Backend Config entry.
Delete a SM Backend Config.
Get a specific SM Backend Config.
Get all SM Backend Configs.
Get a specific SM Backend Config.
Update a SM Backend Config entry.
Create a new SM Flavor entry.
Delete a SM Flavor.
Get a specific SM Flavor.
Get all SM Flavors.
Update a SM Flavor entry.
Create a new child Zone entry.
Delete a child Zone.
Get a specific child Zone.
Get all child Zones.
Update a child Zone entry.
Create a snapshot from the values dictionary.
Destroy the snapshot or raise if it does not exist.
Get a snapshot or raise if it does not exist.
Get all snapshots.
Get all snapshots belonging to a project.
Get all snapshots for a volume.
Set the given properties on an snapshot and update it.
Raises NotFound if snapshot does not exist.
Atomically allocate a free iscsi_target from the pool.
Ensure that a volume is set as attached.
Create a volume from the values dictionary.
Get (volume_count, gigabytes) for project.
Destroy the volume or raise if it does not exist.
Ensure that a volume is set as detached.
Get a volume or raise if it does not exist.
Get all the volumes inside the window.
Specifying a project_id will filter for a certain project.
Get all volumes.
Get all volumes belonging to a host.
Get all volumes belonging to a instance.
Get all volumes belonging to a project.
Get the target num (tid) allocated to the volume.
Delete the given metadata item.
Get all metadata for a volume.
Update metadata if it exists, otherwise create it.
Create a new volume type.
Delete a volume type.
Delete the given extra specs item.
Get all extra specs for a volume type.
Create or update volume type extra specs. This adds or modifies the key/value pairs specified in the extra specs dict argument
Get volume type by id.
Get all volume types.
Get volume type by name.
Set the given properties on an volume and update it.
Raises NotFound if volume does not exist.
Implementation of SQLAlchemy backend.
SQLAlchemy models for cinder data.
Bases: object
Base class for Cinder Models.
Delete this object.
Make the model object behave like a dict.
Includes attributes from joins.
Save this object.
Make the model object behave like a dict
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents a running cinder service on a host.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents an iscsi target for a given host
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents a running host-to-host migration.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents a single quota override for a project.
If there is no row for a given project id and resource, then the default for the quota class is used. If there is no row for a given quota class and resource, then the default for the deployment is used. If the row is present but the hard limit is Null, then the resource is unlimited.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents a single quota override for a quota class.
If there is no row for a given quota class and resource, then the default for the deployment is used. If the row is present but the hard limit is Null, then the resource is unlimited.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents the current usage for a given resource.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents a resource reservation for quotas.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents the connection to the backend for SM.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents a flavor for SM volumes.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents a running service on a host.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents a block storage device that can be attached to a VM.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents a block storage device that can be attached to a vm.
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents a metadata key/value pair for a volume
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represents additional specs as key/value pairs for a volume_type
Bases: sqlalchemy.ext.declarative.Base, cinder.db.sqlalchemy.models.CinderBase
Represent possible volume_types of volumes offered
Register Models and create metadata.
Called from cinder.db.sqlalchemy.__init__ as part of loading the driver, it will never need to be called explicitly elsewhere unless the connection is lost and needs to be reestablished.
Session Handling for SQLAlchemy backend.
Return a SQLAlchemy engine.
Return a SQLAlchemy sessionmaker using the given engine.
Return a SQLAlchemy session.
Return True if error in connecting to db.
Ensures that MySQL connections checked out of the pool are alive.
Borrowed from: http://groups.google.com/group/sqlalchemy/msg/a4ce563d802c929f
Switch sqlite connections to non-synchronous mode
Tests are lacking for the db api layer and for the sqlalchemy driver. Failures in the drivers would be detected in other test cases, though.