diff options
author | Russell Bryant <rbryant@redhat.com> | 2013-01-14 18:31:31 -0500 |
---|---|---|
committer | Russell Bryant <rbryant@redhat.com> | 2013-01-18 11:16:20 -0600 |
commit | 102e761d8fc9791d80b733a5b39b51d840052d52 (patch) | |
tree | 0069f19eaebf8fb79acd1f0c0b537187be0c4247 | |
parent | e9d342637b78a4d2ef13852905ee4a2d88b48af2 (diff) | |
download | nova-102e761d8fc9791d80b733a5b39b51d840052d52.tar.gz nova-102e761d8fc9791d80b733a5b39b51d840052d52.tar.xz nova-102e761d8fc9791d80b733a5b39b51d840052d52.zip |
Add service_update to conductor.
Add a service_update method to the conductor API. This will be
necessary for removing direct db access from the servicegroup db driver.
Part of bp no-db-compute.
Change-Id: Ic9a205ed4e810ee3511378742f764b2b311174a7
-rw-r--r-- | nova/conductor/api.py | 6 | ||||
-rw-r--r-- | nova/conductor/manager.py | 7 | ||||
-rw-r--r-- | nova/conductor/rpcapi.py | 6 | ||||
-rw-r--r-- | nova/tests/conductor/test_conductor.py | 8 |
4 files changed, 26 insertions, 1 deletions
diff --git a/nova/conductor/api.py b/nova/conductor/api.py index 31ee19601..138e72f70 100644 --- a/nova/conductor/api.py +++ b/nova/conductor/api.py @@ -285,6 +285,9 @@ class LocalAPI(object): return self._manager.compute_node_update(context, node, values, prune_stats) + def service_update(self, context, service, values): + return self._manager.service_update(context, service, values) + class API(object): """Conductor API that does updates via RPC to the ConductorManager.""" @@ -548,3 +551,6 @@ class API(object): def compute_node_update(self, context, node, values, prune_stats=False): return self.conductor_rpcapi.compute_node_update(context, node, values, prune_stats) + + def service_update(self, context, service, values): + return self.conductor_rpcapi.service_update(context, service, values) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 9b18d1e00..0ff2e1400 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.33' + RPC_API_VERSION = '1.34' def __init__(self, *args, **kwargs): super(ConductorManager, self).__init__(service_name='conductor', @@ -310,3 +310,8 @@ class ConductorManager(manager.SchedulerDependentManager): result = self.db.compute_node_update(context, node['id'], values, prune_stats) return jsonutils.to_primitive(result) + + @rpc_common.client_exceptions(exception.ServiceNotFound) + def service_update(self, context, service, values): + svc = self.db.service_update(context, service['id'], values) + return jsonutils.to_primitive(svc) diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py index 95e332840..6dc8aef04 100644 --- a/nova/conductor/rpcapi.py +++ b/nova/conductor/rpcapi.py @@ -66,6 +66,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): 1.31 - Added migration_get_in_progress_by_host_and_node 1.32 - Added optional node to instance_get_all_by_host 1.33 - Added compute_node_create and compute_node_update + 1.34 - Added service_update """ BASE_RPC_API_VERSION = '1.0' @@ -316,3 +317,8 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): msg = self.make_msg('compute_node_update', node=node_p, values=values, prune_stats=prune_stats) return self.call(context, msg, version='1.33') + + def service_update(self, context, service, values): + service_p = jsonutils.to_primitive(service) + msg = self.make_msg('service_update', service=service_p, values=values) + return self.call(context, msg, version='1.34') diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index b29db92e7..d010b454f 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -747,6 +747,14 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase): def test_service_destroy(self): self._test_stubbed('service_destroy', '', returns=False) + def test_service_update(self): + ctxt = self.context + self.mox.StubOutWithMock(db, 'service_update') + db.service_update(ctxt, '', {}).AndReturn('fake-result') + self.mox.ReplayAll() + result = self.conductor.service_update(self.context, {'id': ''}, {}) + self.assertEqual(result, 'fake-result') + def test_instance_get_all_by_host(self): self._test_stubbed('instance_get_all_by_host', self.context.elevated(), 'host') |