summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-01-12 09:12:21 +0000
committerGerrit Code Review <review@openstack.org>2013-01-12 09:12:21 +0000
commit574fbf89da2ae9d0f6ff9e6bc98ecfcb45f5508c (patch)
tree38ccc17a51febeda77cb13b94b24f1fe48aaa11d
parent0d7c208abc4d55c2aabc2af4499cf65e978a6ca4 (diff)
parentfd78129b9fa76c008756f60412b1d066d1c21caf (diff)
downloadnova-574fbf89da2ae9d0f6ff9e6bc98ecfcb45f5508c.tar.gz
nova-574fbf89da2ae9d0f6ff9e6bc98ecfcb45f5508c.tar.xz
nova-574fbf89da2ae9d0f6ff9e6bc98ecfcb45f5508c.zip
Merge "Add service_create to conductor."
-rw-r--r--nova/conductor/api.py6
-rw-r--r--nova/conductor/manager.py6
-rw-r--r--nova/conductor/rpcapi.py5
-rw-r--r--nova/service.py14
-rw-r--r--nova/tests/conductor/test_conductor.py3
-rw-r--r--nova/tests/test_service.py4
6 files changed, 30 insertions, 8 deletions
diff --git a/nova/conductor/api.py b/nova/conductor/api.py
index 228876682..099f9a61d 100644
--- a/nova/conductor/api.py
+++ b/nova/conductor/api.py
@@ -255,6 +255,9 @@ class LocalAPI(object):
def action_event_finish(self, context, values):
return self._manager.action_event_finish(context, values)
+ def service_create(self, context, values):
+ return self._manager.service_create(context, values)
+
class API(object):
"""Conductor API that does updates via RPC to the ConductorManager."""
@@ -485,3 +488,6 @@ class API(object):
def action_event_finish(self, context, values):
return self.conductor_rpcapi.action_event_finish(context, values)
+
+ def service_create(self, context, values):
+ return self.conductor_rpcapi.service_create(context, values)
diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py
index a7bc08420..95831043a 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.26'
+ RPC_API_VERSION = '1.27'
def __init__(self, *args, **kwargs):
super(ConductorManager, self).__init__(service_name='conductor',
@@ -272,3 +272,7 @@ class ConductorManager(manager.SchedulerDependentManager):
def action_event_finish(self, context, values):
evt = self.db.action_event_finish(context, values)
return jsonutils.to_primitive(evt)
+
+ def service_create(self, context, values):
+ svc = self.db.service_create(context, values)
+ return jsonutils.to_primitive(svc)
diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py
index 8850bca01..de368418e 100644
--- a/nova/conductor/rpcapi.py
+++ b/nova/conductor/rpcapi.py
@@ -59,6 +59,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.24 - Added instance_get
1.25 - Added action_event_start and action_event_finish
1.26 - Added instance_info_cache_update
+ 1.27 - Added service_create
"""
BASE_RPC_API_VERSION = '1.0'
@@ -278,3 +279,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
instance=instance_p,
values=values)
return self.call(context, msg, version='1.26')
+
+ def service_create(self, context, values):
+ msg = self.make_msg('service_create', values=values)
+ return self.call(context, msg, version='1.27')
diff --git a/nova/service.py b/nova/service.py
index 05049d464..12c1725c3 100644
--- a/nova/service.py
+++ b/nova/service.py
@@ -472,12 +472,14 @@ class Service(object):
self.timers.append(periodic)
def _create_service_ref(self, context):
- service_ref = db.service_create(context,
- {'host': self.host,
- 'binary': self.binary,
- 'topic': self.topic,
- 'report_count': 0})
- self.service_id = service_ref['id']
+ svc_values = {
+ 'host': self.host,
+ 'binary': self.binary,
+ 'topic': self.topic,
+ 'report_count': 0
+ }
+ service = self.conductor_api.service_create(context, svc_values)
+ self.service_id = service['id']
def __getattr__(self, key):
manager = self.__dict__.get('manager', None)
diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py
index 909174fa9..885788187 100644
--- a/nova/tests/conductor/test_conductor.py
+++ b/nova/tests/conductor/test_conductor.py
@@ -650,6 +650,9 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase):
def test_service_get_all_compute_by_host(self):
self._test_stubbed('service_get_all_compute_by_host', 'host')
+ def test_service_create(self):
+ self._test_stubbed('service_create', {})
+
def test_ping(self):
timeouts = []
calls = dict(count=0)
diff --git a/nova/tests/test_service.py b/nova/tests/test_service.py
index 0bb57d542..8cc24cb1c 100644
--- a/nova/tests/test_service.py
+++ b/nova/tests/test_service.py
@@ -113,6 +113,8 @@ class ServiceTestCase(test.TestCase):
self.binary = 'nova-fake'
self.topic = 'fake'
self.mox.StubOutWithMock(service, 'db')
+ self.mox.StubOutWithMock(db, 'service_create')
+ self.flags(use_local=True, group='conductor')
def test_create(self):
@@ -136,7 +138,7 @@ class ServiceTestCase(test.TestCase):
service.db.service_get_by_args(mox.IgnoreArg(),
self.host, self.binary).AndRaise(exception.NotFound())
- service.db.service_create(mox.IgnoreArg(),
+ db.service_create(mox.IgnoreArg(),
service_create).AndReturn(service_ref)
return service_ref