oslo.db.sqlalchemy.provision

Provision test environment for specific DB backends

class oslo.db.sqlalchemy.provision.Backend(database_type, url)

Bases: object

Represent a particular database backend that may be provisionable.

The Backend object maintains a database type (e.g. database without specific driver type, such as “sqlite”, “postgresql”, etc.), a target URL, a base Engine for that URL object that can be used to provision databases and a BackendImpl which knows how to perform operations against this type of Engine.

classmethod all_viable_backends()

Return an iterator of all Backend objects that are present

and provisionable.

classmethod backend_for_database_type(database_type)

Return and verify the Backend for the given database type.

Creates the engine if it does not already exist and raises BackendNotAvailable if it cannot be produced.

Returns:a base Engine that allows provisioning of databases.
Raises:BackendNotAvailable, if an engine for this backend cannot be produced.
backends_by_database_type = {'sqlite': <oslo.db.sqlalchemy.provision.Backend object at 0x7f22c0806c50>, 'postgresql': <oslo.db.sqlalchemy.provision.Backend object at 0x7f22c0806990>, 'mysql': <oslo.db.sqlalchemy.provision.Backend object at 0x7f22c0806950>}
create_named_database(ident)

Create a database with the given name.

database_exists(ident)

Return True if a database of the given name exists.

drop_named_database(ident, conditional=False)

Drop a database with the given name.

provisioned_engine(ident)

Given the URL of a particular database backend and the string

name of a particular ‘database’ within that backend, return an Engine instance whose connections will refer directly to the named database.

For hostname-based URLs, this typically involves switching just the ‘database’ portion of the URL with the given name and creating an engine.

For URLs that instead deal with DSNs, the rules may be more custom; for example, the engine may need to connect to the root URL and then emit a command to switch to the named database.

class oslo.db.sqlalchemy.provision.BackendImpl(drivername)

Bases: object

Provide database-specific implementations of key provisioning

functions.

BackendImpl is owned by a Backend instance which delegates to it for all database-specific features.

classmethod all_impls()

Return an iterator of all possible BackendImpl objects.

These are BackendImpls that are implemented, but not necessarily provisionable.

create_named_database(engine, ident)

Create a database with the given name.

create_opportunistic_driver_url()

Produce a string url known as the ‘opportunistic’ URL.

This URL is one that corresponds to an established Openstack convention for a pre-established database login, which, when detected as available in the local environment, is automatically used as a test platform for a specific type of driver.

drop_named_database(engine, ident, conditional=False)

Drop a database with the given name.

impl = <oslo.db.sqlalchemy.utils.DialectSingleFunctionDispatcher object at 0x7f22c0718250>
provisioned_engine(base_url, ident)

Return a provisioned engine.

Given the URL of a particular database backend and the string name of a particular ‘database’ within that backend, return an Engine instance whose connections will refer directly to the named database.

For hostname-based URLs, this typically involves switching just the ‘database’ portion of the URL with the given name and creating an engine.

For URLs that instead deal with DSNs, the rules may be more custom; for example, the engine may need to connect to the root URL and then emit a command to switch to the named database.

class oslo.db.sqlalchemy.provision.ProvisionedDatabase(database_type)

Bases: object

Represent a single database node that can be used for testing in

a serialized fashion.

ProvisionedDatabase includes features for full lifecycle management of a node, in a way that is context-specific. Depending on how the test environment runs, ProvisionedDatabase should know if it needs to create and drop databases or if it is making use of a database that is maintained by an external process.

dispose()
oslo.db.sqlalchemy.provision.main(argv=None)

Command line interface to create/drop databases.

::create: Create test database with random names. ::drop: Drop database created by previous command. ::echo: create random names and display them; don’t create.

Previous topic

oslo.db.sqlalchemy.models

Next topic

oslo.db.sqlalchemy.session

This Page