task connect rpc server
Change-Id: If4ba4b34e2fa3d43741af516453b49be7a605f94
This commit is contained in:
parent
bd3fb2a403
commit
1f595c3db6
@ -22,6 +22,7 @@ from oslo_reports import guru_meditation_report as gmr
|
||||
|
||||
from venus.conf import CONF
|
||||
from venus import i18n
|
||||
from venus import rpc
|
||||
from venus import service
|
||||
from venus import utils
|
||||
from venus import version
|
||||
@ -40,6 +41,7 @@ def main():
|
||||
utils.monkey_patch()
|
||||
|
||||
gmr.TextGuruMeditation.setup_autorun(version)
|
||||
rpc.init(CONF)
|
||||
|
||||
server = service.Service.create(binary='venus-task',
|
||||
topic="venus-task")
|
||||
|
@ -17,10 +17,10 @@ from oslo_config import cfg
|
||||
|
||||
service_opts = [
|
||||
cfg.IntOpt('periodic_interval',
|
||||
default=60,
|
||||
default=1,
|
||||
help='Interval, in seconds, between running periodic tasks'),
|
||||
cfg.IntOpt('periodic_fuzzy_delay',
|
||||
default=60,
|
||||
default=1,
|
||||
help='Range, in seconds, to randomly delay when starting the'
|
||||
' periodic task scheduler to reduce stampeding.'
|
||||
' (Disable by settings to 0)'),
|
||||
|
@ -139,21 +139,21 @@ class RequestContext(context.RequestContext):
|
||||
# project_id/user internally, so it is compatible with context-aware code
|
||||
# from openstack/common. We still need this shim for the rest of Venus's
|
||||
# code.
|
||||
@property
|
||||
def project_id(self):
|
||||
return self.tenant
|
||||
|
||||
@project_id.setter
|
||||
def project_id(self, value):
|
||||
self.tenant = value
|
||||
|
||||
@property
|
||||
def user_id(self):
|
||||
return self.user
|
||||
|
||||
@user_id.setter
|
||||
def user_id(self, value):
|
||||
self.user = value
|
||||
# @property
|
||||
# def project_id(self):
|
||||
# return self.project_id
|
||||
#
|
||||
# @project_id.setter
|
||||
# def project_id(self, value):
|
||||
# self.project_id = value
|
||||
#
|
||||
# @property
|
||||
# def user_id(self):
|
||||
# return self.user
|
||||
#
|
||||
# @user_id.setter
|
||||
# def user_id(self, value):
|
||||
# self.user = value
|
||||
|
||||
|
||||
def get_admin_context(read_deleted="no"):
|
||||
|
@ -27,4 +27,4 @@ class Base(object):
|
||||
if not db_driver:
|
||||
db_driver = CONF.db_driver
|
||||
self.db = importutils.import_module(db_driver) # pylint: disable=C0103
|
||||
self.db.dispose_engine()
|
||||
# self.db.dispose_engine()
|
||||
|
@ -91,3 +91,27 @@ class Manager(base.Base, PeriodicTasks):
|
||||
manager is working correctly.
|
||||
"""
|
||||
return True
|
||||
|
||||
@periodic_task.periodic_task
|
||||
def test_periodictask0(self, context):
|
||||
"""Ensure that instances are not stuck in build."""
|
||||
LOG.info("test_periodictask0")
|
||||
LOG.info(context)
|
||||
|
||||
@periodic_task.periodic_task
|
||||
def test_periodictask1(self, context):
|
||||
"""Ensure that instances are not stuck in build."""
|
||||
LOG.info("test_periodictask1")
|
||||
LOG.info(context)
|
||||
|
||||
@periodic_task.periodic_task
|
||||
def test_periodictask2(self, context):
|
||||
"""Ensure that instances are not stuck in build."""
|
||||
LOG.info("test_periodictask2")
|
||||
LOG.info(context)
|
||||
|
||||
@periodic_task.periodic_task
|
||||
def test_periodictask3(self, context):
|
||||
"""Ensure that instances are not stuck in build."""
|
||||
LOG.info("test_periodictask3")
|
||||
LOG.info(context)
|
||||
|
@ -93,10 +93,14 @@ class Service(service.Service):
|
||||
self.manager.init_host()
|
||||
LOG.debug("Creating RPC server for service %s", self.topic)
|
||||
|
||||
# target = messaging.Target(topic=self.topic, server=self.host)
|
||||
target = messaging.Target(topic=self.topic, server=self.host)
|
||||
endpoints = [self.manager]
|
||||
endpoints.extend(self.manager.additional_endpoints)
|
||||
# serializer = objects_base.VenusObjectSerializer()
|
||||
serializer = objects_base.VenusObjectSerializer()
|
||||
self.rpcserver = rpc.get_server(target, endpoints, serializer)
|
||||
self.rpcserver.start()
|
||||
|
||||
self.notifier = rpc.get_notifier("venus", self.host)
|
||||
|
||||
self.manager.init_host_with_rpc()
|
||||
|
||||
@ -134,8 +138,10 @@ class Service(service.Service):
|
||||
host = CONF.host
|
||||
if not binary:
|
||||
binary = os.path.basename(inspect.stack()[-1][1])
|
||||
LOG.info(binary)
|
||||
if not topic:
|
||||
topic = binary
|
||||
LOG.info(topic)
|
||||
if not manager:
|
||||
subtopic = topic.rpartition('venus-')[2]
|
||||
manager = CONF.get('%s_manager' % subtopic, None)
|
||||
|
Loading…
x
Reference in New Issue
Block a user