Move agent_build_get_by_triple to conductor
This patch moves the final method in Compute's VirtAPI to using the conductor. Related to blueprint no-db-compute-manager Change-Id: Icaf8990e117c8de7198de2f26f0d77e56c129430
This commit is contained in:
parent
20f0c601fe
commit
2f8ffcc46d
@ -292,10 +292,8 @@ class ComputeVirtAPI(virtapi.VirtAPI):
|
||||
return self._compute.conductor_api.provider_fw_rule_get_all(context)
|
||||
|
||||
def agent_build_get_by_triple(self, context, hypervisor, os, architecture):
|
||||
return self._compute.db.agent_build_get_by_triple(context,
|
||||
hypervisor,
|
||||
os,
|
||||
architecture)
|
||||
return self._compute.conductor_api.agent_build_get_by_triple(
|
||||
context, hypervisor, os, architecture)
|
||||
|
||||
|
||||
class ComputeManager(manager.SchedulerDependentManager):
|
||||
|
@ -128,6 +128,10 @@ class LocalAPI(object):
|
||||
def provider_fw_rule_get_all(self, context):
|
||||
return self._manager.provider_fw_rule_get_all(context)
|
||||
|
||||
def agent_build_get_by_triple(self, context, hypervisor, os, architecture):
|
||||
return self._manager.agent_build_get_by_triple(context, hypervisor,
|
||||
os, architecture)
|
||||
|
||||
|
||||
class API(object):
|
||||
"""Conductor API that does updates via RPC to the ConductorManager"""
|
||||
@ -204,3 +208,9 @@ class API(object):
|
||||
|
||||
def provider_fw_rule_get_all(self, context):
|
||||
return self.conductor_rpcapi.provider_fw_rule_get_all(context)
|
||||
|
||||
def agent_build_get_by_triple(self, context, hypervisor, os, architecture):
|
||||
return self.conductor_rpcapi.agent_build_get_by_triple(context,
|
||||
hypervisor,
|
||||
os,
|
||||
architecture)
|
||||
|
@ -43,7 +43,7 @@ datetime_fields = ['launched_at', 'terminated_at']
|
||||
class ConductorManager(manager.SchedulerDependentManager):
|
||||
"""Mission: TBD"""
|
||||
|
||||
RPC_API_VERSION = '1.9'
|
||||
RPC_API_VERSION = '1.10'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ConductorManager, self).__init__(service_name='conductor',
|
||||
@ -144,3 +144,8 @@ class ConductorManager(manager.SchedulerDependentManager):
|
||||
def provider_fw_rule_get_all(self, context):
|
||||
rules = self.db.provider_fw_rule_get_all(context)
|
||||
return jsonutils.to_primitive(rules)
|
||||
|
||||
def agent_build_get_by_triple(self, context, hypervisor, os, architecture):
|
||||
info = self.db.agent_build_get_by_triple(context, hypervisor, os,
|
||||
architecture)
|
||||
return jsonutils.to_primitive(info)
|
||||
|
@ -38,6 +38,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
||||
1.8 - Added security_group_get_by_instance and
|
||||
security_group_rule_get_by_security_group
|
||||
1.9 - Added provider_fw_rule_get_all
|
||||
1.10 - Added agent_build_get_by_triple
|
||||
"""
|
||||
|
||||
BASE_RPC_API_VERSION = '1.0'
|
||||
@ -133,3 +134,9 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
||||
def provider_fw_rule_get_all(self, context):
|
||||
msg = self.make_msg('provider_fw_rule_get_all')
|
||||
return self.call(context, msg, version='1.9')
|
||||
|
||||
def agent_build_get_by_triple(self, context, hypervisor, os, architecture):
|
||||
msg = self.make_msg('agent_build_get_by_triple',
|
||||
hypervisor=hypervisor, os=os,
|
||||
architecture=architecture)
|
||||
return self.call(context, msg, version='1.10')
|
||||
|
@ -129,33 +129,10 @@ class ComputeVirtAPITest(VirtAPIBaseTest):
|
||||
self.compute = FakeCompute()
|
||||
self.virtapi = compute_manager.ComputeVirtAPI(self.compute)
|
||||
|
||||
def setUp(self):
|
||||
super(ComputeVirtAPITest, self).setUp()
|
||||
# NOTE(danms): Eventually these should all be migrated to the
|
||||
# conductor, but until then, dispatch appropriately.
|
||||
self.conductor_methods = ['instance_update', 'instance_get_by_uuid',
|
||||
'instance_get_all_by_host',
|
||||
'aggregate_get_by_host',
|
||||
'aggregate_metadata_add',
|
||||
'aggregate_metadata_delete',
|
||||
'security_group_get_by_instance',
|
||||
'security_group_rule_get_by_security_group',
|
||||
'provider_fw_rule_get_all',
|
||||
]
|
||||
self.db_methods = ['agent_build_get_by_triple',
|
||||
]
|
||||
|
||||
def assertExpected(self, method, *args, **kwargs):
|
||||
if method in self.conductor_methods:
|
||||
target = self.compute.conductor_api
|
||||
elif method in self.db_methods:
|
||||
target = self.compute.db
|
||||
else:
|
||||
raise Exception('Method "%s" not known to this test!')
|
||||
|
||||
self.mox.StubOutWithMock(target, method)
|
||||
getattr(target, method)(self.context, *args, **kwargs).AndReturn(
|
||||
'it worked')
|
||||
self.mox.StubOutWithMock(self.compute.conductor_api, method)
|
||||
getattr(self.compute.conductor_api, method)(
|
||||
self.context, *args, **kwargs).AndReturn('it worked')
|
||||
self.mox.ReplayAll()
|
||||
result = getattr(self.virtapi, method)(self.context, *args, **kwargs)
|
||||
self.assertEqual(result, 'it worked')
|
||||
|
@ -251,6 +251,17 @@ class _BaseTestCase(object):
|
||||
result = self.conductor.provider_fw_rule_get_all(self.context)
|
||||
self.assertEqual(result, fake_rules)
|
||||
|
||||
def test_agent_build_get_by_triple(self):
|
||||
self.mox.StubOutWithMock(db, 'agent_build_get_by_triple')
|
||||
db.agent_build_get_by_triple(self.context, 'fake-hv', 'fake-os',
|
||||
'fake-arch').AndReturn('it worked')
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.agent_build_get_by_triple(self.context,
|
||||
'fake-hv',
|
||||
'fake-os',
|
||||
'fake-arch')
|
||||
self.assertEqual(result, 'it worked')
|
||||
|
||||
|
||||
class ConductorTestCase(_BaseTestCase, test.TestCase):
|
||||
"""Conductor Manager Tests"""
|
||||
|
Loading…
Reference in New Issue
Block a user