Defines interface for DB access.
The underlying driver is loaded as a LazyPluggable.
Functions in this module are imported into the manila.db namespace. Call these functions from manila.db namespace, not the manila.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
backend: | string to lookup in the list of LazyPluggable backends. sqlalchemy is the only supported backend right now. |
---|---|
connection: | string specifying the sqlalchemy connection to use, like: sqlite:///var/lib/manila/manila.sqlite. |
enable_new_services: | |
when adding a new service to the database, is it in the pool of available hardware (Default: True) |
Ensures a request has permission to access the given project.
Ensures a request has permission to access the given quota class.
Get availability zone by name or id.
Get all active availability zones.
Create a cgsnapshot from the values dictionary.
Destroy the cgsnapshot or raise if it does not exist.
Get a cgsnapshot.
Get all cgsnapshots.
Get all cgsnapshots belonging to a project.
Create a cgsnapshot member from the values dictionary.
Set the given properties on a cgsnapshot member and update it.
Raises NotFound if cgsnapshot member does not exist.
Return the members of a cgsnapshot.
Set the given properties on a cgsnapshot and update it.
Raises NotFound if cgsnapshot does not exist.
Create a consistency group from the values dictionary.
Destroy the consistency group or raise if it does not exist.
Get a consistency group or raise if it does not exist.
Get all consistency groups.
Get all consistency groups belonging to a project.
Get all consistency groups associated with a share server.
Set the given properties on a consistency group and update it.
Raises NotFound if consistency group does not exist.
Returns the number of cgsnapshot members linked to the share.
Returns the number of undeleted cgsnapshots with the specified cg.
Returns the number of undeleted cgs with the specified share network.
Returns the number of undeleted shares with the specified cg.
Remove one, list or all key-value pairs for given entity_id.
Get one, list or all key-value pairs for given entity_id.
Update key-value pairs for given entity_id.
Delete metadata of an export location.
Get all metadata of an export location.
Update metadata of an export location.
Create a network allocation DB record.
Delete a network allocation DB record.
Update a network allocation DB record.
Get network allocations by IP address.
Get network allocations for share server.
Create a quota class for the given name and resource.
Retrieve a quota class or raise if it does not exist.
Retrieve all quotas associated with a given quota class.
Retrieve all default quotas.
Update a quota class or raise if it does not exist.
Create a quota for the given project and resource.
Destroy all quotas associated with a given project.
Destroy all quotas associated with a given project and user.
Retrieve a quota or raise if it does not exist.
Retrieve all user quotas associated with a given project.
Retrieve all quotas associated with a given project.
Retrieve all quotas associated with a given project and user.
Check quotas and create appropriate reservations.
Update a quota or raise if it does not exist.
Create a quota usage.
Retrieve a quota usage or raise if it does not exist.
Retrieve all usage associated with a given resource.
Retrieve all usage associated with a given resource.
Update a quota usage or raise if it does not exist.
Commit quota reservations.
Roll back any expired reservations.
Roll back quota reservations.
Create security service DB record.
Delete security service DB record.
Get security service DB record.
Get all security service DB records.
Get all security service DB records for the given project.
Update security service DB record.
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 topic.
Get all share services sorted by share count.
Returns: | a list of (Service, share_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.
Allow access to share.
Deny access to share.
Get share access rule.
Returns share access by given type and access.
Get all access rules related to a certain share instance.
Get all access rules for given share.
Update the access_key field of a share access mapping.
Create new share.
Delete share.
Get specific export location of a share.
Get all export locations of a share.
Get all export locations of a share by its ID.
Get all export locations of a share instance by its ID.
Update export locations of a share instance.
Get share by id.
Get all shares.
Returns all shares with given project ID and CG id.
Returns all shares with given project ID.
Returns all shares with given share server ID.
Maps the existing access rules for the share to the instance in the DB.
Adds the instance mapping to the share’s access rules and returns the share’s access rules.
Allow access to share instance.
Deny access to share instance.
Get access rule mapping for share instance.
Create new share instance.
Delete share instance.
Get share instance by id.
Update share instance fields.
Update access rules status of share instance.
Returns all share instances.
Returns list of share instances that belong to given cg.
Returns all share instances with given host.
Returns list of shares that belong to given share.
Returns list of shares that belong to given share network.
Returns all share instances with given share_server_id.
Delete the given metadata item.
Get all metadata for a share.
Update metadata if it exists, otherwise create it.
Create a share network DB record.
Delete a share network DB record.
Get requested share network DB record.
Get all share network DB records.
Get all share network DB records for the given project.
Get all share network DB records for the given project.
Update a share network DB record.
Deletes a share replica.
Get share replica by id.
Updates a share replica with given values.
Returns all share replicas regardless of share.
Returns all share replicas for a given share.
Returns an active replica for a given share.
Create DB record with backend details.
Create share server DB record.
Delete share server DB record.
Get share server DB record by ID.
Get all share server DB records.
Get all share servers related to particular host.
Get share server DB records by host and share net not error.
Get all free share servers DB records.
Update share server DB record.
Create a snapshot from the values dictionary.
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 share.
Create a share snapshot instance for an existing snapshot.
Delete a share snapshot instance.
Get a snapshot instance or raise a NotFound exception.
Get all snapshot instances satisfying provided filters.
Set the given properties on a share snapshot instance and update it.
Raises NotFound if snapshot instance does not exist.
Set the given properties on an snapshot and update it.
Raises NotFound if snapshot does not exist.
Add share type access for project.
Get all share type access of a share type.
Remove share type access for project.
Create a new share type.
Delete a share type.
Delete the given extra specs item.
Get all extra specs for a share type.
Create or update share type extra specs.
This adds or modifies the key/value pairs specified in the extra specs dict argument.
Get share type by id.
Parameters: |
|
---|---|
Returns: | share type |
Get all share types.
Parameters: |
|
---|---|
Returns: | list of matching share types |
Get share type by name.
Update share fields.
Implementation of SQLAlchemy backend.
SQLAlchemy models for Manila data.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a private data as key-value pairs for a driver.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a cgsnapshot.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents the share snapshots in a consistency group snapshot.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a consistency group.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents the share types in a consistency group.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a private data as key-value pairs for a driver.
Bases: oslo_db.sqlalchemy.models.ModelBase, oslo_db.sqlalchemy.models.TimestampMixin, oslo_db.sqlalchemy.models.SoftDeleteMixin
Base class for Manila Models.
Mark this object as deleted.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a running manila service on a host.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents network allocation data.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a single quota override for a user with in a project.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
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.api.Base, manila.db.sqlalchemy.models.ManilaBase
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.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents the current usage for a given resource.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a resource reservation for quotas.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Security service information for manila shares.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a running service on a host.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents an NFS and CIFS shares.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents access to share.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents access to individual share instances.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents export locations of share instances.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents export location metadata of share instances.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a metadata key/value pair for a share.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents network data used by share.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Association table between compute_zones and compute_nodes tables.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents share server used by share.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a metadata key/value pair for a share server.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a snapshot of a share.
Get the aggregated ‘status’ of all instances.
A snapshot is supposed to be truly ‘available’ when it is available across all of the share instances of the parent share object. In case of replication, we only consider replicas (share instances) that are in ‘in_sync’ replica_state.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents a snapshot of a share.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represents additional specs as key/value pairs for a share_type.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represent projects associated share_types.
Bases: sqlalchemy.ext.declarative.api.Base, manila.db.sqlalchemy.models.ManilaBase
Represent possible share_types of volumes offered.
Register Models and create metadata.
Called from manila.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.
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.
If a DB schema needs to be updated, a new DB migration file needs to be added in manila/db/migrations/alembic/versions. To create such a file it’s possible to use manila-manage db revision or the corresponding tox command:
tox -e dbrevision "change_foo_table"
In addition every migration script must be tested. See examples in manila/tests/db/migrations/alembic/migrations_data_checks.py.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.