Only warn about hostmappings during ocata upgrade

The check and subsequent hard failure for HostMapping records in
API migration 30 is inconvenient at times during a new setup where
we have flavors in place but no hosts yet. Since we can now check
for and warn about missing HostMapping records in our upgrade
status command, this patch lowers the lack of host mappings check
from a failure to a warning. This migration was really just to make
sure you ran the simple setup command, and the cell mapping check
does that for us.

Change-Id: I8b757fa7c805ec6f4d578ecb6f33d3f1ceff29fc
This commit is contained in:
Dan Smith 2017-01-23 08:49:59 -08:00
parent 35a42c5b12
commit f781409f36
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()