Merge "Add 'use_slave' to instance_get_all_by_filter in conductor"
This commit is contained in:
commit
0f4b6534d3
@ -87,12 +87,13 @@ class LocalAPI(object):
|
||||
def instance_get_all_by_filters(self, context, filters,
|
||||
sort_key='created_at',
|
||||
sort_dir='desc',
|
||||
columns_to_join=None):
|
||||
columns_to_join=None, use_slave=False):
|
||||
return self._manager.instance_get_all_by_filters(context,
|
||||
filters,
|
||||
sort_key,
|
||||
sort_dir,
|
||||
columns_to_join)
|
||||
columns_to_join,
|
||||
use_slave)
|
||||
|
||||
def instance_get_active_by_window_joined(self, context, begin, end=None,
|
||||
project_id=None, host=None):
|
||||
|
@ -76,7 +76,7 @@ class ConductorManager(manager.Manager):
|
||||
namespace. See the ComputeTaskManager class for details.
|
||||
"""
|
||||
|
||||
target = messaging.Target(version='1.63')
|
||||
target = messaging.Target(version='1.64')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ConductorManager, self).__init__(service_name='conductor',
|
||||
@ -342,10 +342,11 @@ class ConductorManager(manager.Manager):
|
||||
" invocation"))
|
||||
|
||||
def instance_get_all_by_filters(self, context, filters, sort_key,
|
||||
sort_dir, columns_to_join=None):
|
||||
sort_dir, columns_to_join=None,
|
||||
use_slave=False):
|
||||
result = self.db.instance_get_all_by_filters(
|
||||
context, filters, sort_key, sort_dir,
|
||||
columns_to_join=columns_to_join)
|
||||
columns_to_join=columns_to_join, use_slave=use_slave)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
# NOTE(hanlind): This method can be removed in v2.0 of the RPC API.
|
||||
|
@ -124,6 +124,7 @@ class ConductorAPI(object):
|
||||
1.62 - Added object_backport()
|
||||
1.63 - Changed the format of values['stats'] from a dict to a JSON string
|
||||
in compute_node_update()
|
||||
1.64 - Added use_slave to instance_get_all_filters()
|
||||
"""
|
||||
|
||||
VERSION_ALIASES = {
|
||||
@ -274,12 +275,20 @@ class ConductorAPI(object):
|
||||
volume_id=volume_id, device_name=device_name)
|
||||
|
||||
def instance_get_all_by_filters(self, context, filters, sort_key,
|
||||
sort_dir, columns_to_join=None):
|
||||
cctxt = self.client.prepare(version='1.47')
|
||||
return cctxt.call(context, 'instance_get_all_by_filters',
|
||||
filters=filters, sort_key=sort_key,
|
||||
sort_dir, columns_to_join=None,
|
||||
use_slave=False):
|
||||
msg_kwargs = dict(filters=filters, sort_key=sort_key,
|
||||
sort_dir=sort_dir, columns_to_join=columns_to_join)
|
||||
|
||||
if self.client.can_send_version('1.64'):
|
||||
version = '1.64'
|
||||
msg_kwargs['use_slave'] = use_slave
|
||||
else:
|
||||
version = '1.47'
|
||||
|
||||
cctxt = self.client.prepare(version=version)
|
||||
return cctxt.call(context, 'instance_get_all_by_filters', **msg_kwargs)
|
||||
|
||||
def instance_get_active_by_window_joined(self, context, begin, end=None,
|
||||
project_id=None, host=None):
|
||||
cctxt = self.client.prepare(version='1.35')
|
||||
|
@ -693,11 +693,22 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
||||
self.mox.StubOutWithMock(db, 'instance_get_all_by_filters')
|
||||
db.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
columns_to_join=None)
|
||||
columns_to_join=None, use_slave=False)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort')
|
||||
|
||||
def test_instance_get_all_by_filters_use_slave(self):
|
||||
filters = {'foo': 'bar'}
|
||||
self.mox.StubOutWithMock(db, 'instance_get_all_by_filters')
|
||||
db.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
columns_to_join=None, use_slave=True)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
use_slave=True)
|
||||
|
||||
def test_instance_get_all_by_host(self):
|
||||
self.mox.StubOutWithMock(db, 'instance_get_all_by_host')
|
||||
self.mox.StubOutWithMock(db, 'instance_get_all_by_host_and_node')
|
||||
@ -972,11 +983,22 @@ class ConductorRPCAPITestCase(_BaseTestCase, test.TestCase):
|
||||
self.mox.StubOutWithMock(db, 'instance_get_all_by_filters')
|
||||
db.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
columns_to_join=None)
|
||||
columns_to_join=None, use_slave=False)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort')
|
||||
|
||||
def test_instance_get_all_by_filters_use_slave(self):
|
||||
filters = {'foo': 'bar'}
|
||||
self.mox.StubOutWithMock(db, 'instance_get_all_by_filters')
|
||||
db.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
columns_to_join=None, use_slave=True)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
use_slave=True)
|
||||
|
||||
def _test_stubbed(self, name, dbargs, condargs,
|
||||
db_result_listified=False, db_exception=None):
|
||||
self.mox.StubOutWithMock(db, name)
|
||||
|
Loading…
Reference in New Issue
Block a user