diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-01-12 09:19:05 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-01-12 09:19:05 +0000 |
commit | e2ea2873949091ca6737419eb0cd0c1268bc437c (patch) | |
tree | 3e7992a88d857beb5e21d959b774cbeafcfae7c9 | |
parent | 2e2a20285db20092540f0bc76c7f9576d22a68f3 (diff) | |
parent | 6f6d5bfccbf223c16dbbfc87d43e687fa9bb517c (diff) | |
download | nova-e2ea2873949091ca6737419eb0cd0c1268bc437c.tar.gz nova-e2ea2873949091ca6737419eb0cd0c1268bc437c.tar.xz nova-e2ea2873949091ca6737419eb0cd0c1268bc437c.zip |
Merge "Add service_destroy to conductor."
-rw-r--r-- | nova/conductor/api.py | 6 | ||||
-rw-r--r-- | nova/conductor/manager.py | 6 | ||||
-rw-r--r-- | nova/conductor/rpcapi.py | 5 | ||||
-rw-r--r-- | nova/service.py | 3 | ||||
-rw-r--r-- | nova/tests/conductor/test_conductor.py | 14 |
5 files changed, 30 insertions, 4 deletions
diff --git a/nova/conductor/api.py b/nova/conductor/api.py index 8cedd2036..c3459448d 100644 --- a/nova/conductor/api.py +++ b/nova/conductor/api.py @@ -262,6 +262,9 @@ class LocalAPI(object): def service_create(self, context, values): return self._manager.service_create(context, values) + def service_destroy(self, context, service_id): + return self._manager.service_destroy(context, service_id) + class API(object): """Conductor API that does updates via RPC to the ConductorManager.""" @@ -499,3 +502,6 @@ class API(object): def service_create(self, context, values): return self.conductor_rpcapi.service_create(context, values) + + def service_destroy(self, context, service_id): + return self.conductor_rpcapi.service_destroy(context, service_id) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index d3fab8122..8c52f292e 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.28' + RPC_API_VERSION = '1.29' def __init__(self, *args, **kwargs): super(ConductorManager, self).__init__(service_name='conductor', @@ -279,3 +279,7 @@ class ConductorManager(manager.SchedulerDependentManager): def service_create(self, context, values): svc = self.db.service_create(context, values) return jsonutils.to_primitive(svc) + + @rpc_common.client_exceptions(exception.ServiceNotFound) + def service_destroy(self, context, service_id): + self.db.service_destroy(context, service_id) diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py index 0c26506f8..4f1d6133f 100644 --- a/nova/conductor/rpcapi.py +++ b/nova/conductor/rpcapi.py @@ -61,6 +61,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): 1.26 - Added instance_info_cache_update 1.27 - Added service_create 1.28 - Added binary arg to service_get_all_by + 1.29 - Added service_destroy """ BASE_RPC_API_VERSION = '1.0' @@ -285,3 +286,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): def service_create(self, context, values): msg = self.make_msg('service_create', values=values) return self.call(context, msg, version='1.27') + + def service_destroy(self, context, service_id): + msg = self.make_msg('service_destroy', service_id=service_id) + return self.call(context, msg, version='1.29') diff --git a/nova/service.py b/nova/service.py index 8b4475afe..39e414eb6 100644 --- a/nova/service.py +++ b/nova/service.py @@ -531,7 +531,8 @@ class Service(object): """Destroy the service object in the datastore.""" self.stop() try: - db.service_destroy(context.get_admin_context(), self.service_id) + self.conductor_api.service_destroy(context.get_admin_context(), + self.service_id) except exception.NotFound: LOG.warn(_('Service killed that has no database entry')) diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index a5d0f7fba..e3ef6072a 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -633,12 +633,19 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase): {'name': 'fake-inst'}, 'updated_at', 'asc') - def _test_stubbed(self, name, *args): + def _test_stubbed(self, name, *args, **kwargs): self.mox.StubOutWithMock(db, name) getattr(db, name)(self.context, *args).AndReturn('fake-result') + if name == 'service_destroy': + # TODO(russellb) This is a hack ... SetUp() starts the conductor() + # service. There is a cleanup step that runs after this test which + # also deletes the associated service record. This involves a call + # to db.service_destroy(), which we have stubbed out. + db.service_destroy(mox.IgnoreArg(), mox.IgnoreArg()) self.mox.ReplayAll() result = getattr(self.conductor, name)(self.context, *args) - self.assertEqual(result, 'fake-result') + self.assertEqual( + result, 'fake-result' if kwargs.get('returns', True) else None) def test_service_get_all(self): self._test_stubbed('service_get_all') @@ -658,6 +665,9 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase): def test_service_create(self): self._test_stubbed('service_create', {}) + def test_service_destroy(self): + self._test_stubbed('service_destroy', '', returns=False) + def test_ping(self): timeouts = [] calls = dict(count=0) |