Split instance polling code
This just split the polling code for one instance out of the periodic task function to be able to use this code for only one instance. Change-Id: I4ec0ab3870410f0b6c7e44857a9dede60fb6d50b Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
06b2207ef7
commit
16b9f9006a
@ -58,11 +58,8 @@ class AgentManager(manager.Manager):
|
|||||||
PLUGIN_NAMESPACE)
|
PLUGIN_NAMESPACE)
|
||||||
return
|
return
|
||||||
|
|
||||||
def periodic_tasks(self, context, raise_on_error=False):
|
def poll_instance(self, context, instance):
|
||||||
"""Tasks to be run at a periodic interval."""
|
"""Poll one instance."""
|
||||||
# FIXME(dhellmann): How do we get a list of instances without
|
|
||||||
# talking directly to the database?
|
|
||||||
for instance in self.db.instance_get_all_by_host(context, self.host):
|
|
||||||
for name, pollster in self.pollsters:
|
for name, pollster in self.pollsters:
|
||||||
try:
|
try:
|
||||||
LOG.info('polling %s', name)
|
LOG.info('polling %s', name)
|
||||||
@ -73,3 +70,10 @@ class AgentManager(manager.Manager):
|
|||||||
LOG.warning('Continuing after error from %s for %s: %s',
|
LOG.warning('Continuing after error from %s for %s: %s',
|
||||||
name, instance.name, err)
|
name, instance.name, err)
|
||||||
LOG.exception(err)
|
LOG.exception(err)
|
||||||
|
|
||||||
|
def periodic_tasks(self, context, raise_on_error=False):
|
||||||
|
"""Tasks to be run at a periodic interval."""
|
||||||
|
# FIXME(dhellmann): How do we get a list of instances without
|
||||||
|
# talking directly to the database?
|
||||||
|
for instance in self.db.instance_get_all_by_host(context, self.host):
|
||||||
|
self.poll_instance(context, instance)
|
||||||
|
Loading…
Reference in New Issue
Block a user