From 16b9f9006a0250ce61a81c053536335af181a8bc Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 17 Sep 2012 12:08:19 +0200 Subject: [PATCH] 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 --- ceilometer/compute/manager.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ceilometer/compute/manager.py b/ceilometer/compute/manager.py index 9657f60f..b354734f 100644 --- a/ceilometer/compute/manager.py +++ b/ceilometer/compute/manager.py @@ -58,12 +58,9 @@ class AgentManager(manager.Manager): PLUGIN_NAMESPACE) return - 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): - for name, pollster in self.pollsters: + def poll_instance(self, context, instance): + """Poll one instance.""" + for name, pollster in self.pollsters: try: LOG.info('polling %s', name) for c in pollster.get_counters(self, instance): @@ -73,3 +70,10 @@ class AgentManager(manager.Manager): LOG.warning('Continuing after error from %s for %s: %s', name, instance.name, 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)