Merge "Fix nova-status "_check_resource_providers" check" into stable/ocata

This commit is contained in:
Zuul 2018-10-02 21:30:20 +00:00 committed by Gerrit Code Review
commit 49ae986a62
2 changed files with 15 additions and 3 deletions

View File

@ -287,9 +287,10 @@ class UpgradeCommands(object):
cell_mappings = self._get_non_cell0_mappings()
ctxt = nova_context.get_admin_context()
num_computes = 0
for cell_mapping in cell_mappings:
with nova_context.target_cell(ctxt, cell_mapping):
num_computes += self._count_compute_nodes(ctxt)
if cell_mappings:
for cell_mapping in cell_mappings:
with nova_context.target_cell(ctxt, cell_mapping):
num_computes += self._count_compute_nodes(ctxt)
else:
# There are no cell mappings, cells v2 was maybe not deployed in
# Newton, but placement might have been, so let's check the single

View File

@ -632,6 +632,17 @@ class TestUpgradeCheckResourceProviders(test.NoDBTestCase):
# create an externally shared IP allocation pool resource provider
self._create_resource_provider(FAKE_IP_POOL_INVENTORY)
# Stub out _count_compute_nodes to make sure we never call it without
# a cell-targeted context.
original_count_compute_nodes = (
status.UpgradeCommands._count_compute_nodes)
def stub_count_compute_nodes(_self, context=None):
self.assertIsNotNone(context.db_connection)
return original_count_compute_nodes(_self, context=context)
self.stub_out('nova.cmd.status.UpgradeCommands._count_compute_nodes',
stub_count_compute_nodes)
result = self.cmd._check_resource_providers()
self.assertEqual(status.UpgradeCheckCode.SUCCESS, result.code)
self.assertIsNone(result.details)