diff options
author | Vishvananda Ishaya <vishvananda@yahoo.com> | 2010-10-01 01:28:17 +0000 |
---|---|---|
committer | Tarmac <> | 2010-10-01 01:28:17 +0000 |
commit | c9cb22f87561fad4ba57865d8a614ca024393f13 (patch) | |
tree | d04a4ac2195d45e9c5f357039cab7d1c0cf40c3d /nova/service.py | |
parent | 30747bba76ddc2b51b5b0bf564557e86a5d634c3 (diff) | |
parent | 1dda065c53cbe11a34e7ae60e11e30dfaf6bf7ac (diff) | |
download | nova-c9cb22f87561fad4ba57865d8a614ca024393f13.tar.gz nova-c9cb22f87561fad4ba57865d8a614ca024393f13.tar.xz nova-c9cb22f87561fad4ba57865d8a614ca024393f13.zip |
Adds support for periodic_tasks on manager that are regularly called by the service and recovers fixed_ips that didn't get disassociated properly.
Diffstat (limited to 'nova/service.py')
-rw-r--r-- | nova/service.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/nova/service.py b/nova/service.py index dcd2a09ef..a6c186896 100644 --- a/nova/service.py +++ b/nova/service.py @@ -37,7 +37,11 @@ from nova import utils FLAGS = flags.FLAGS flags.DEFINE_integer('report_interval', 10, - 'seconds between nodes reporting state to cloud', + 'seconds between nodes reporting state to datastore', + lower_bound=1) + +flags.DEFINE_integer('periodic_interval', 60, + 'seconds between running periodic tasks', lower_bound=1) @@ -81,7 +85,8 @@ class Service(object, service.Service): binary=None, topic=None, manager=None, - report_interval=None): + report_interval=None, + periodic_interval=None): """Instantiates class and passes back application object. Args: @@ -90,6 +95,7 @@ class Service(object, service.Service): topic, defaults to bin_name - "nova-" part manager, defaults to FLAGS.<topic>_manager report_interval, defaults to FLAGS.report_interval + periodic_interval, defaults to FLAGS.periodic_interval """ if not host: host = FLAGS.host @@ -101,6 +107,8 @@ class Service(object, service.Service): manager = FLAGS.get('%s_manager' % topic, None) if not report_interval: report_interval = FLAGS.report_interval + if not periodic_interval: + periodic_interval = FLAGS.periodic_interval logging.warn("Starting %s node", topic) service_obj = cls(host, binary, topic, manager) conn = rpc.Connection.instance() @@ -113,11 +121,14 @@ class Service(object, service.Service): topic='%s.%s' % (topic, host), proxy=service_obj) + consumer_all.attach_to_twisted() + consumer_node.attach_to_twisted() + pulse = task.LoopingCall(service_obj.report_state) pulse.start(interval=report_interval, now=False) - consumer_all.attach_to_twisted() - consumer_node.attach_to_twisted() + pulse = task.LoopingCall(service_obj.periodic_tasks) + pulse.start(interval=periodic_interval, now=False) # This is the parent service that twistd will be looking for when it # parses this file, return it so that we can get it into globals. @@ -133,6 +144,11 @@ class Service(object, service.Service): logging.warn("Service killed that has no database entry") @defer.inlineCallbacks + def periodic_tasks(self, context=None): + """Tasks to be run at a periodic interval""" + yield self.manager.periodic_tasks(context) + + @defer.inlineCallbacks def report_state(self, context=None): """Update the state of this service in the datastore.""" try: |