Revert "Optional separate database for placement API"

This reverts commit 1b5f9f8203c90fe447d33c89f238104026052d1e.

On IRC I we decided that we agreed no migrations should be placement
specific, we should just use the API table migrations to generate the
schema for both DBs.

There is also a separate debate around the alias for the aggregates
table, but that is not really a reason to revert, its just things in
here that will need rework.

Change-Id: I275945aee9d9be8e35d6ddc05515df39d559457a
This commit is contained in:
John Garbutt
2016-08-25 15:30:15 +00:00
committed by Dan Smith
parent c454ffa9f7
commit a9d11231a3
6 changed files with 3 additions and 50 deletions

View File

@@ -75,7 +75,6 @@ LOG = logging.getLogger(__name__)
main_context_manager = enginefacade.transaction_context() main_context_manager = enginefacade.transaction_context()
api_context_manager = enginefacade.transaction_context() api_context_manager = enginefacade.transaction_context()
placement_context_manager = enginefacade.transaction_context()
def _get_db_conf(conf_group, connection=None): def _get_db_conf(conf_group, connection=None):
@@ -109,10 +108,6 @@ def _context_manager_from_context(context):
def configure(conf): def configure(conf):
main_context_manager.configure(**_get_db_conf(conf.database)) main_context_manager.configure(**_get_db_conf(conf.database))
api_context_manager.configure(**_get_db_conf(conf.api_database)) api_context_manager.configure(**_get_db_conf(conf.api_database))
if conf.placement_database.connection is None:
conf.placement_database = conf.api_database
placement_context_manager.configure(
**_get_db_conf(conf.placement_database))
def create_context_manager(connection=None): def create_context_manager(connection=None):
@@ -147,10 +142,6 @@ def get_api_engine():
return api_context_manager.get_legacy_facade().get_engine() return api_context_manager.get_legacy_facade().get_engine()
def get_placement_engine():
return placement_context_manager.get_legacy_facade().get_engine()
_SHADOW_TABLE_PREFIX = 'shadow_' _SHADOW_TABLE_PREFIX = 'shadow_'
_DEFAULT_QUOTA_NAME = 'default' _DEFAULT_QUOTA_NAME = 'default'
PER_PROJECT_QUOTAS = ['fixed_ips', 'floating_ips', 'networks'] PER_PROJECT_QUOTAS = ['fixed_ips', 'floating_ips', 'networks']

View File

@@ -354,31 +354,6 @@ class ResourceProviderAggregate(API_BASE):
aggregate_id = Column(Integer, primary_key=True, nullable=False) aggregate_id = Column(Integer, primary_key=True, nullable=False)
class PlacementAggregate(API_BASE):
"""Represents a grouping of resource providers."""
# NOTE(rpodolyaka): placement API can optionally use the subset of tables
# of api DB instead of requiring its own DB. aggregates table is the only
# table which schema is a bit different (additional `name` column), but we
# can work around that by providing an additional mapping class to a
# subset of table columns, so that this model works for both separate and
# shared DBs cases.
__table__ = API_BASE.metadata.tables['aggregates']
__mapper_args__ = {
'exclude_properties': ['name']
}
resource_providers = orm.relationship(
'ResourceProvider',
secondary='resource_provider_aggregates',
primaryjoin=('PlacementAggregate.id == '
'ResourceProviderAggregate.aggregate_id'),
secondaryjoin=('ResourceProviderAggregate.resource_provider_id == '
'ResourceProvider.id'),
backref='aggregates'
)
class InstanceGroupMember(API_BASE): class InstanceGroupMember(API_BASE):
"""Represents the members for an instance group.""" """Represents the members for an instance group."""
__tablename__ = 'instance_group_member' __tablename__ = 'instance_group_member'

View File

@@ -31,7 +31,6 @@ from nova.i18n import _
INIT_VERSION = {} INIT_VERSION = {}
INIT_VERSION['main'] = 215 INIT_VERSION['main'] = 215
INIT_VERSION['api'] = 0 INIT_VERSION['api'] = 0
INIT_VERSION['placement'] = 0
_REPOSITORY = {} _REPOSITORY = {}
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@@ -42,8 +41,6 @@ def get_engine(database='main', context=None):
return db_session.get_engine(context=context) return db_session.get_engine(context=context)
if database == 'api': if database == 'api':
return db_session.get_api_engine() return db_session.get_api_engine()
if database == 'placement':
return db_session.get_placement_engine()
def db_sync(version=None, database='main', context=None): def db_sync(version=None, database='main', context=None):
@@ -174,8 +171,6 @@ def _find_migrate_repo(database='main'):
rel_path = 'migrate_repo' rel_path = 'migrate_repo'
if database == 'api': if database == 'api':
rel_path = os.path.join('api_migrations', 'migrate_repo') rel_path = os.path.join('api_migrations', 'migrate_repo')
if database == 'placement':
rel_path = os.path.join('placement_migrations', 'migrate_repo')
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
rel_path) rel_path)
assert os.path.exists(path) assert os.path.exists(path)

View File

@@ -213,7 +213,6 @@ class TestCase(testtools.TestCase):
if self.USES_DB: if self.USES_DB:
self.useFixture(nova_fixtures.Database()) self.useFixture(nova_fixtures.Database())
self.useFixture(nova_fixtures.Database(database='api')) self.useFixture(nova_fixtures.Database(database='api'))
self.useFixture(nova_fixtures.Database(database='placement'))
self.useFixture(nova_fixtures.DefaultFlavorsFixture()) self.useFixture(nova_fixtures.DefaultFlavorsFixture())
elif not self.USES_DB_SELF: elif not self.USES_DB_SELF:
self.useFixture(nova_fixtures.DatabasePoisonFixture()) self.useFixture(nova_fixtures.DatabasePoisonFixture())

View File

@@ -43,7 +43,7 @@ from nova.tests.functional.api import client
_TRUE_VALUES = ('True', 'true', '1', 'yes') _TRUE_VALUES = ('True', 'true', '1', 'yes')
CONF = cfg.CONF CONF = cfg.CONF
DB_SCHEMA = {'main': "", 'api': "", 'placement': ""} DB_SCHEMA = {'main': "", 'api': ""}
SESSION_CONFIGURED = False SESSION_CONFIGURED = False
@@ -221,7 +221,7 @@ class Database(fixtures.Fixture):
def __init__(self, database='main', connection=None): def __init__(self, database='main', connection=None):
"""Create a database fixture. """Create a database fixture.
:param database: The type of database, 'main', 'api' or 'placement' :param database: The type of database, 'main' or 'api'
:param connection: The connection string to use :param connection: The connection string to use
""" """
super(Database, self).__init__() super(Database, self).__init__()
@@ -242,8 +242,6 @@ class Database(fixtures.Fixture):
self.get_engine = session.get_engine self.get_engine = session.get_engine
elif database == 'api': elif database == 'api':
self.get_engine = session.get_api_engine self.get_engine = session.get_api_engine
elif database == 'placement':
self.get_engine = session.get_placement_engine
def _cache_schema(self): def _cache_schema(self):
global DB_SCHEMA global DB_SCHEMA
@@ -277,7 +275,7 @@ class DatabaseAtVersion(fixtures.Fixture):
"""Create a database fixture. """Create a database fixture.
:param version: Max version to sync to (or None for current) :param version: Max version to sync to (or None for current)
:param database: The type of database, 'main', 'api', 'placement' :param database: The type of database, 'main' or 'api'
""" """
super(DatabaseAtVersion, self).__init__() super(DatabaseAtVersion, self).__init__()
self.database = database self.database = database
@@ -286,8 +284,6 @@ class DatabaseAtVersion(fixtures.Fixture):
self.get_engine = session.get_engine self.get_engine = session.get_engine
elif database == 'api': elif database == 'api':
self.get_engine = session.get_api_engine self.get_engine = session.get_api_engine
elif database == 'placement':
self.get_engine = session.get_placement_engine
def cleanup(self): def cleanup(self):
engine = self.get_engine() engine = self.get_engine()

View File

@@ -49,13 +49,11 @@ class APIFixture(fixture.GabbiFixture):
config.parse_args([], default_config_files=None, configure_db=False, config.parse_args([], default_config_files=None, configure_db=False,
init_rpc=False) init_rpc=False)
self.placement_db_fixture = fixtures.Database('placement')
# NOTE(cdent): api and main database are not used but we still need # NOTE(cdent): api and main database are not used but we still need
# to manage them to make the fixtures work correctly and not cause # to manage them to make the fixtures work correctly and not cause
# conflicts with other tests in the same process. # conflicts with other tests in the same process.
self.api_db_fixture = fixtures.Database('api') self.api_db_fixture = fixtures.Database('api')
self.main_db_fixture = fixtures.Database('main') self.main_db_fixture = fixtures.Database('main')
self.placement_db_fixture.reset()
self.api_db_fixture.reset() self.api_db_fixture.reset()
self.main_db_fixture.reset() self.main_db_fixture.reset()
@@ -63,7 +61,6 @@ class APIFixture(fixture.GabbiFixture):
os.environ['RP_NAME'] = uuidutils.generate_uuid() os.environ['RP_NAME'] = uuidutils.generate_uuid()
def stop_fixture(self): def stop_fixture(self):
self.placement_db_fixture.cleanup()
self.api_db_fixture.cleanup() self.api_db_fixture.cleanup()
self.main_db_fixture.cleanup() self.main_db_fixture.cleanup()
if self.conf: if self.conf: