Move instance_get_*() to conductor
This patch adds conductor support for instance_get_all_by_filters(), and supports the following APIs through that method: - instance_get_all() - instance_get_all_by_host() - instance_get_all_by_filters() Further, it adds support for the following APIs: - instance_get_all_hung_in_rebooting() - instance_get_active_by_window() It also makes compute/manager use conductor for these operations, with one exception. Currently, ComputeManager.init_host () lists all instances associated with the host, which may happen before a conductor service is available. This will be handled separately due to the sequencing concerns. Related to bp/no-db-compute-manager Change-Id: I0dd346fd632aa15cd301386bc392502b95709529
This commit is contained in:
@@ -28,6 +28,7 @@ from nova import test
|
|||||||
|
|
||||||
from nova.compute import manager as compute_manager
|
from nova.compute import manager as compute_manager
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
|
from nova import conductor
|
||||||
from nova import db
|
from nova import db
|
||||||
from nova.openstack.common import cfg
|
from nova.openstack.common import cfg
|
||||||
from nova.openstack.common import importutils
|
from nova.openstack.common import importutils
|
||||||
@@ -929,7 +930,7 @@ class ImageCacheManagerTestCase(test.TestCase):
|
|||||||
def test_compute_manager(self):
|
def test_compute_manager(self):
|
||||||
was = {'called': False}
|
was = {'called': False}
|
||||||
|
|
||||||
def fake_get_all(context):
|
def fake_get_all(context, *args, **kwargs):
|
||||||
was['called'] = True
|
was['called'] = True
|
||||||
return [{'image_ref': '1',
|
return [{'image_ref': '1',
|
||||||
'host': CONF.host,
|
'host': CONF.host,
|
||||||
@@ -947,7 +948,9 @@ class ImageCacheManagerTestCase(test.TestCase):
|
|||||||
with utils.tempdir() as tmpdir:
|
with utils.tempdir() as tmpdir:
|
||||||
self.flags(instances_path=tmpdir)
|
self.flags(instances_path=tmpdir)
|
||||||
|
|
||||||
self.stubs.Set(db, 'instance_get_all', fake_get_all)
|
self.stubs.Set(db, 'instance_get_all_by_filters', fake_get_all)
|
||||||
compute = importutils.import_object(CONF.compute_manager)
|
compute = importutils.import_object(CONF.compute_manager)
|
||||||
|
self.flags(use_local=True, group='conductor')
|
||||||
|
compute.conductor_api = conductor.API()
|
||||||
compute._run_image_cache_manager_pass(None)
|
compute._run_image_cache_manager_pass(None)
|
||||||
self.assertTrue(was['called'])
|
self.assertTrue(was['called'])
|
||||||
|
|||||||
Reference in New Issue
Block a user