Conductor instance_get_all replaces _by_filters
Updates the Nova conductor so that it uses instance_get_all() and instance_get_all_by_host() from the Nova DB API to implement its own like named functions. This fixes a regression that occured ind22b0ca
where we switched from using the DB API's instance_get_all_by_host and instance_get_all methods over to the DB APIs instance_get_all_by_filters. This caused some subtle regressions due to the fact that instance_get_all_by_filters has different defaults for deleted records. The previously used (prior tod22b0ca
) instance_get_all() and instance_get_all_by_host() functions rely on the context.read_deleted and also handle the display of deleted and soft deleted records differently. Fixes LP Bug #1096972. Change-Id: Icb587ef169d1d7dd86cf6ee682e74bd4e84c37e2
This commit is contained in:
parent
e1c7b18c7f
commit
0ca44e9584
|
@ -82,10 +82,10 @@ class LocalAPI(object):
|
|||
return self._manager.instance_destroy(context, instance)
|
||||
|
||||
def instance_get_all(self, context):
|
||||
return self.instance_get_all_by_filters(context, {})
|
||||
return self._manager.instance_get_all(context)
|
||||
|
||||
def instance_get_all_by_host(self, context, host):
|
||||
return self.instance_get_all_by_filters(context, {'host': host})
|
||||
return self._manager.instance_get_all_by_host(context, host)
|
||||
|
||||
def instance_get_all_by_filters(self, context, filters,
|
||||
sort_key='created_at',
|
||||
|
@ -257,10 +257,10 @@ class API(object):
|
|||
instance_uuid)
|
||||
|
||||
def instance_get_all(self, context):
|
||||
return self.instance_get_all_by_filters(context, {})
|
||||
return self.conductor_rpcapi.instance_get_all(context)
|
||||
|
||||
def instance_get_all_by_host(self, context, host):
|
||||
return self.instance_get_all_by_filters(context, {'host': host})
|
||||
return self.conductor_rpcapi.instance_get_all_by_host(context, host)
|
||||
|
||||
def instance_get_all_by_filters(self, context, filters,
|
||||
sort_key='created_at',
|
||||
|
|
|
@ -43,7 +43,7 @@ datetime_fields = ['launched_at', 'terminated_at']
|
|||
class ConductorManager(manager.SchedulerDependentManager):
|
||||
"""Mission: TBD"""
|
||||
|
||||
RPC_API_VERSION = '1.22'
|
||||
RPC_API_VERSION = '1.23'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ConductorManager, self).__init__(service_name='conductor',
|
||||
|
@ -75,7 +75,9 @@ class ConductorManager(manager.SchedulerDependentManager):
|
|||
return jsonutils.to_primitive(
|
||||
self.db.instance_get_by_uuid(context, instance_uuid))
|
||||
|
||||
# NOTE(danms): This should go away in RPC version 2
|
||||
def instance_get_all(self, context):
|
||||
return jsonutils.to_primitive(self.db.instance_get_all(context))
|
||||
|
||||
def instance_get_all_by_host(self, context, host):
|
||||
return jsonutils.to_primitive(
|
||||
self.db.instance_get_all_by_host(context.elevated(), host))
|
||||
|
|
|
@ -54,6 +54,8 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
|||
1.20 - Added migration_get_unconfirmed_by_dest_compute
|
||||
1.21 - Added service_get_all_by
|
||||
1.22 - Added ping
|
||||
1.23 - Added instance_get_all
|
||||
Un-Deprecate instance_get_all_by_host
|
||||
"""
|
||||
|
||||
BASE_RPC_API_VERSION = '1.0'
|
||||
|
@ -245,3 +247,11 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
|||
def service_get_all_by(self, context, topic=None, host=None):
|
||||
msg = self.make_msg('service_get_all_by', topic=topic, host=host)
|
||||
return self.call(context, msg, version='1.21')
|
||||
|
||||
def instance_get_all(self, context):
|
||||
msg = self.make_msg('instance_get_all')
|
||||
return self.call(context, msg, version='1.23')
|
||||
|
||||
def instance_get_all_by_host(self, context, host):
|
||||
msg = self.make_msg('instance_get_all_by_host', host=host)
|
||||
return self.call(context, msg, version='1.23')
|
||||
|
|
|
@ -594,9 +594,8 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase):
|
|||
|
||||
def test_instance_get_all(self):
|
||||
self.mox.StubOutWithMock(db, 'instance_get_all_by_filters')
|
||||
db.instance_get_all_by_filters(self.context, {}, 'created_at', 'desc')
|
||||
db.instance_get_all_by_filters(self.context, {'host': 'fake-host'},
|
||||
'created_at', 'desc')
|
||||
db.instance_get_all(self.context)
|
||||
db.instance_get_all_by_host(self.context.elevated(), 'fake-host')
|
||||
db.instance_get_all_by_filters(self.context, {'name': 'fake-inst'},
|
||||
'updated_at', 'asc')
|
||||
self.mox.ReplayAll()
|
||||
|
|
|
@ -947,7 +947,7 @@ class ImageCacheManagerTestCase(test.TestCase):
|
|||
with utils.tempdir() as tmpdir:
|
||||
self.flags(instances_path=tmpdir)
|
||||
|
||||
self.stubs.Set(db, 'instance_get_all_by_filters', fake_get_all)
|
||||
self.stubs.Set(db, 'instance_get_all', fake_get_all)
|
||||
compute = importutils.import_object(CONF.compute_manager)
|
||||
self.flags(use_local=True, group='conductor')
|
||||
compute.conductor_api = conductor.API()
|
||||
|
|
Loading…
Reference in New Issue