Remove straggling use of main db flavors in cellsv1 code
This remaining use of the flavor query routine from the cellsv1 code
still looks at the main database. This patch converts it to use the
object which looks in the right place.
Closes-Bug: #1663729
Change-Id: I418988ae1d72d541ace867a22b2c9267164bf61b
(cherry picked from commit 6e5b1d289b
)
This commit is contained in:
parent
9d62d7588c
commit
681e377618
|
@ -298,12 +298,12 @@ class CellStateManager(base.Base):
|
|||
else:
|
||||
return 0
|
||||
|
||||
instance_types = self.db.flavor_get_all(ctxt)
|
||||
flavors = objects.FlavorList.get_all(ctxt)
|
||||
memory_mb_slots = frozenset(
|
||||
[inst_type['memory_mb'] for inst_type in instance_types])
|
||||
[flavor.memory_mb for flavor in flavors])
|
||||
disk_mb_slots = frozenset(
|
||||
[(inst_type['root_gb'] + inst_type['ephemeral_gb']) * units.Ki
|
||||
for inst_type in instance_types])
|
||||
[(flavor.root_gb + flavor.ephemeral_gb) * units.Ki
|
||||
for flavor in flavors])
|
||||
|
||||
for compute_values in compute_hosts.values():
|
||||
total_ram_mb_free += compute_values['free_ram_mb']
|
||||
|
|
|
@ -112,11 +112,11 @@ def _fake_cell_get_all(context):
|
|||
return []
|
||||
|
||||
|
||||
def _fake_instance_type_all(context):
|
||||
def _fake_instance_type_all(*args):
|
||||
def _type(mem, root, eph):
|
||||
return {'root_gb': root,
|
||||
'ephemeral_gb': eph,
|
||||
'memory_mb': mem}
|
||||
return objects.Flavor(root_gb=root,
|
||||
ephemeral_gb=eph,
|
||||
memory_mb=mem)
|
||||
|
||||
return [_type(*fake) for fake in FAKE_ITYPES]
|
||||
|
||||
|
@ -130,7 +130,8 @@ class TestCellsStateManager(test.NoDBTestCase):
|
|||
_fake_compute_node_get_all)
|
||||
self.stub_out('nova.objects.ServiceList.get_by_binary',
|
||||
_fake_service_get_all_by_binary)
|
||||
self.stub_out('nova.db.flavor_get_all', _fake_instance_type_all)
|
||||
self.stub_out('nova.objects.FlavorList.get_all',
|
||||
_fake_instance_type_all)
|
||||
self.stub_out('nova.db.cell_get_all', _fake_cell_get_all)
|
||||
|
||||
def test_cells_config_not_found(self):
|
||||
|
@ -268,7 +269,8 @@ class TestCellsStateManagerNodeDown(test.NoDBTestCase):
|
|||
_fake_compute_node_get_all)
|
||||
self.stub_out('nova.objects.ServiceList.get_by_binary',
|
||||
_fake_service_get_all_by_binary_nodedown)
|
||||
self.stub_out('nova.db.flavor_get_all', _fake_instance_type_all)
|
||||
self.stub_out('nova.objects.FlavorList.get_all',
|
||||
_fake_instance_type_all)
|
||||
self.stub_out('nova.db.cell_get_all', _fake_cell_get_all)
|
||||
|
||||
def test_capacity_no_reserve_nodedown(self):
|
||||
|
|
Loading…
Reference in New Issue