Merge "Provide hints when nova-manage db sync fails to sync cell0"
This commit is contained in:
commit
2933f408ee
|
@ -732,9 +732,15 @@ class DbCommands(object):
|
||||||
except exception.CellMappingNotFound:
|
except exception.CellMappingNotFound:
|
||||||
print(_('WARNING: cell0 mapping not found - not'
|
print(_('WARNING: cell0 mapping not found - not'
|
||||||
' syncing cell0.'))
|
' syncing cell0.'))
|
||||||
except Exception:
|
except Exception as e:
|
||||||
print(_('ERROR: could not access cell mapping database - has'
|
print(_("""ERROR: Could not access cell0.
|
||||||
' api db been created?'))
|
Has the nova_api database been created?
|
||||||
|
Has the nova_cell0 database been created?
|
||||||
|
Has "nova-manage api_db sync" been run?
|
||||||
|
Has "nova-manage cell_v2 map_cell0" been run?
|
||||||
|
Is [api_database]/connection set in nova.conf?
|
||||||
|
Is the cell0 database connection URL correct?
|
||||||
|
Error: %s""") % six.text_type(e))
|
||||||
return migration.db_sync(version)
|
return migration.db_sync(version)
|
||||||
|
|
||||||
def version(self):
|
def version(self):
|
||||||
|
|
|
@ -567,6 +567,27 @@ Archiving.....stopped
|
||||||
]
|
]
|
||||||
mock_db_sync.assert_has_calls(db_sync_calls)
|
mock_db_sync.assert_has_calls(db_sync_calls)
|
||||||
|
|
||||||
|
@mock.patch.object(objects.CellMapping, 'get_by_uuid',
|
||||||
|
side_effect=test.TestingException('invalid connection'))
|
||||||
|
def test_sync_cell0_unknown_error(self, mock_get_by_uuid):
|
||||||
|
"""Asserts that a detailed error message is given when an unknown
|
||||||
|
error occurs trying to get the cell0 cell mapping.
|
||||||
|
"""
|
||||||
|
self.commands.sync()
|
||||||
|
mock_get_by_uuid.assert_called_once_with(
|
||||||
|
test.MatchType(context.RequestContext),
|
||||||
|
objects.CellMapping.CELL0_UUID)
|
||||||
|
expected = """ERROR: Could not access cell0.
|
||||||
|
Has the nova_api database been created?
|
||||||
|
Has the nova_cell0 database been created?
|
||||||
|
Has "nova-manage api_db sync" been run?
|
||||||
|
Has "nova-manage cell_v2 map_cell0" been run?
|
||||||
|
Is [api_database]/connection set in nova.conf?
|
||||||
|
Is the cell0 database connection URL correct?
|
||||||
|
Error: invalid connection
|
||||||
|
"""
|
||||||
|
self.assertEqual(expected, self.output.getvalue())
|
||||||
|
|
||||||
def _fake_db_command(self, migrations=None):
|
def _fake_db_command(self, migrations=None):
|
||||||
if migrations is None:
|
if migrations is None:
|
||||||
mock_mig_1 = mock.MagicMock(__name__="mock_mig_1")
|
mock_mig_1 = mock.MagicMock(__name__="mock_mig_1")
|
||||||
|
|
Loading…
Reference in New Issue