diff --git a/venus/cmd/task.py b/venus/cmd/task.py index 9de438b..5642a39 100644 --- a/venus/cmd/task.py +++ b/venus/cmd/task.py @@ -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") diff --git a/venus/conf/api.py b/venus/conf/api.py index 9693db5..596f596 100644 --- a/venus/conf/api.py +++ b/venus/conf/api.py @@ -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)'), diff --git a/venus/context.py b/venus/context.py index b406cee..abb665b 100644 --- a/venus/context.py +++ b/venus/context.py @@ -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"): diff --git a/venus/db/base.py b/venus/db/base.py index 9da40b1..dba168b 100644 --- a/venus/db/base.py +++ b/venus/db/base.py @@ -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() diff --git a/venus/manager.py b/venus/manager.py index 53a719e..250d97f 100644 --- a/venus/manager.py +++ b/venus/manager.py @@ -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) diff --git a/venus/service.py b/venus/service.py index 30f70da..bd677c7 100644 --- a/venus/service.py +++ b/venus/service.py @@ -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)