summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2012-12-12 13:14:56 -0800
committerDan Smith <danms@us.ibm.com>2012-12-15 08:19:57 -0800
commit2f8ffcc46db933ba27e14835c4448320bee5daa0 (patch)
treeef9cbad5a37abddb5ad406434b51a9a8ca08a505
parent20f0c601fe5bd59c2a2f07a8be428ddca995afc5 (diff)
downloadnova-2f8ffcc46db933ba27e14835c4448320bee5daa0.tar.gz
nova-2f8ffcc46db933ba27e14835c4448320bee5daa0.tar.xz
nova-2f8ffcc46db933ba27e14835c4448320bee5daa0.zip
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
-rw-r--r--nova/compute/manager.py6
-rw-r--r--nova/conductor/api.py10
-rw-r--r--nova/conductor/manager.py7
-rw-r--r--nova/conductor/rpcapi.py7
-rw-r--r--nova/tests/compute/test_virtapi.py29
-rw-r--r--nova/tests/conductor/test_conductor.py11
6 files changed, 39 insertions, 31 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 66e605477..6efc83fb9 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -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):
diff --git a/nova/conductor/api.py b/nova/conductor/api.py
index afbf24e3f..4c2f031e6 100644
--- a/nova/conductor/api.py
+++ b/nova/conductor/api.py
@@ -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)
diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py
index bbe36013f..712644738 100644
--- a/nova/conductor/manager.py
+++ b/nova/conductor/manager.py
@@ -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)
diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py
index 4f9fa9818..0beeb3d2f 100644
--- a/nova/conductor/rpcapi.py
+++ b/nova/conductor/rpcapi.py
@@ -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')
diff --git a/nova/tests/compute/test_virtapi.py b/nova/tests/compute/test_virtapi.py
index ceeacbc9d..568bf456d 100644
--- a/nova/tests/compute/test_virtapi.py
+++ b/nova/tests/compute/test_virtapi.py
@@ -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')
diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py
index 6acbe7ef6..734dba9ed 100644
--- a/nova/tests/conductor/test_conductor.py
+++ b/nova/tests/conductor/test_conductor.py
@@ -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"""