Fix the generated cell0 default database name

This makes the default database name for cell0 be based on the
main database name, not the api one. Before this, we would get
a database name of nova_api_cell0 by default, intead of nova_cell0.
This was confusing because cell0 has "main" schema inside, not "api"
schema.

Closes-Bug: #1656673
Change-Id: I86797785f76c2c927a4db8fef72b8f8d986af6b9
This commit is contained in:
Dan Smith 2017-01-15 10:52:36 -08:00 committed by Matt Riedemann
parent a287c5f2b9
commit 5b44737e0c
5 changed files with 26 additions and 16 deletions

View File

@ -1120,7 +1120,7 @@ class CellV2Commands(object):
metavar='<database_connection>',
help='The database connection url for cell0. '
'This is optional. If not provided, a standard database '
'connection will be used based on the API database connection '
'connection will be used based on the main database connection '
'from the Nova configuration.'
)
def map_cell0(self, database_connection=None):
@ -1135,11 +1135,11 @@ class CellV2Commands(object):
"""
def cell0_default_connection():
# If no database connection is provided one is generated
# based on the API database connection url.
# based on the database connection url.
# The cell0 database will use the same database scheme and
# netloc as the API database, with a related path.
# netloc as the main database, with a related path.
scheme, netloc, path, query, fragment = \
urlparse.urlsplit(CONF.api_database.connection)
urlparse.urlsplit(CONF.database.connection)
root, ext = os.path.splitext(path)
path = root + "_cell0" + ext
return urlparse.urlunsplit((scheme, netloc, path, query,

View File

@ -1115,22 +1115,22 @@ class CellV2CommandsTestCase(test.NoDBTestCase):
def test_map_cell0_default_database(self):
CONF.set_default('connection',
'fake://netloc/nova_api',
group='api_database')
'fake://netloc/nova',
group='database')
ctxt = context.RequestContext()
self.commands.map_cell0()
cell_mapping = objects.CellMapping.get_by_uuid(ctxt,
objects.CellMapping.CELL0_UUID)
self.assertEqual('cell0', cell_mapping.name)
self.assertEqual('none:///', cell_mapping.transport_url)
self.assertEqual('fake://netloc/nova_api_cell0',
self.assertEqual('fake://netloc/nova_cell0',
cell_mapping.database_connection)
def _test_migrate_simple_command(self, cell0_sync_fail=False):
ctxt = context.RequestContext()
CONF.set_default('connection',
'fake://netloc/nova_api',
group='api_database')
'fake://netloc/nova',
group='database')
values = {
'vcpus': 4,
'memory_mb': 4096,
@ -1169,7 +1169,7 @@ class CellV2CommandsTestCase(test.NoDBTestCase):
objects.CellMapping.CELL0_UUID)
self.assertEqual('cell0', cell_mapping.name)
self.assertEqual('none:///', cell_mapping.transport_url)
self.assertEqual('fake://netloc/nova_api_cell0',
self.assertEqual('fake://netloc/nova_cell0',
cell_mapping.database_connection)
# Verify the cell mapping

View File

@ -12,7 +12,7 @@ upgrade:
where transport_url is the connection information for the current message
queue used by Nova. Operators must create a new database for cell0 before
running `cell_v2 simple_cell_setup`. The simple cell setup command expects
the name of the cell0 database to be `<API database name>_cell0` as it will
create a cell mapping for cell0 based on the API database connection, sync
the cell0 database, and associate existing hosts and instances with the
single cell.
the name of the cell0 database to be `<main database name>_cell0` as it
will create a cell mapping for cell0 based on the main database connection,
sync the cell0 database, and associate existing hosts and instances with
the single cell.

View File

@ -0,0 +1,10 @@
---
fixes:
- |
The ``nova-manage cell_v2 simple_cell_setup`` command now creates the
default cell0 database connection using the ``[database]`` connection
configuration option rather than the ``[api_database]`` connection. The
cell0 database schema is the `main` database, i.e. the `instances` table,
rather than the `api` database schema. In other words, the cell0 database
would be called something like ``nova_cell0`` rather than
``nova_api_cell0``.

View File

@ -6,7 +6,7 @@ upgrade:
will want to run `nova-manage cell_v2 simple_cell_setup`
on Newton before upgrading. Operators must create a new database for cell0
before running `cell_v2 simple_cell_setup`. The simple cell setup command
expects the name of the cell0 database to be `<API database name>_cell0` as
it will create a cell mapping for cell0 based on the API database
expects the name of the cell0 database to be `<main database name>_cell0`
as it will create a cell mapping for cell0 based on the main database
connection, sync the cell0 database, and associate existing hosts and
instances with the single cell.