Merge "Only warn about hostmappings during ocata upgrade"

This commit is contained in:
Jenkins 2017-01-26 09:10:50 +00:00 committed by Gerrit Code Review
commit efb2dda346
2 changed files with 11 additions and 8 deletions

View File

@ -10,12 +10,15 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from sqlalchemy import MetaData, Table, func, select
from nova import exception
from nova.i18n import _
from nova.i18n import _, _LW
from nova import objects
LOG = logging.getLogger(__name__)
def upgrade(migrate_engine):
meta = MetaData()
@ -51,7 +54,7 @@ def upgrade(migrate_engine):
host_mappings = Table('host_mappings', meta, autoload=True)
count = select([func.count()]).select_from(host_mappings).scalar()
if count == 0:
msg = _('No host mappings were found, but are required for Ocata. '
'Please run nova-manage cell_v2 simple_cell_setup before '
'continuing.')
raise exception.ValidationError(detail=msg)
msg = _LW('No host mappings were found, but are required for Ocata. '
'Please run nova-manage cell_v2 simple_cell_setup before '
'continuing.')
LOG.warning(msg)

View File

@ -437,9 +437,9 @@ class TestNewtonCellsCheck(test.NoDBTestCase):
database_connection='fake')
cell1.create()
self.assertRaisesRegex(exception.ValidationError,
'host mappings',
self.migration.upgrade, self.engine)
with mock.patch.object(self.migration, 'LOG') as log:
self.migration.upgrade(self.engine)
self.assertTrue(log.warning.called)
def test_upgrade_with_required_mappings(self):
self._flavor_me()