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
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user