diff options
author | Doug Hellmann <doug.hellmann@dreamhost.com> | 2013-07-02 17:12:35 -0400 |
---|---|---|
committer | Doug Hellmann <doug.hellmann@dreamhost.com> | 2013-07-02 20:58:40 -0400 |
commit | 4437fb5f0b1820031d396a9ba39d50725d81d1eb (patch) | |
tree | c52935e36f377fa7210e491696166d13ba7243cd /ceilometer/image | |
parent | a10773e41388140126c38baad7bf88f909736923 (diff) | |
download | ceilometer-4437fb5f0b1820031d396a9ba39d50725d81d1eb.tar.gz |
Update glance pollster to use cache
Save the images being scanned by the glance
pollster to the cache.
blueprint one-meter-per-plugin
Change-Id: I7fc808e7b6f0c0ca93a10319574cbb865a69a424
Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
Diffstat (limited to 'ceilometer/image')
-rw-r--r-- | ceilometer/image/glance.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ceilometer/image/glance.py b/ceilometer/image/glance.py index e96a9a23..9efe2559 100644 --- a/ceilometer/image/glance.py +++ b/ceilometer/image/glance.py @@ -40,8 +40,7 @@ class _Base(plugin.PollsterBase): return glanceclient.Client('1', endpoint, token=ksclient.auth_token) - def iter_images(self, ksclient): - """Iterate over all images.""" + def _get_images(self, ksclient): client = self.get_glance_client(ksclient) #TODO(eglynn): use pagination to protect against unbounded # memory usage @@ -70,6 +69,12 @@ class _Base(plugin.PollsterBase): imageIdSet -= set([image.id]) yield image + def _iter_images(self, ksclient, cache): + """Iterate over all images.""" + if 'images' not in cache: + cache['images'] = list(self._get_images(ksclient)) + return iter(cache['images']) + @staticmethod def extract_image_metadata(image): return dict((k, getattr(image, k)) @@ -100,7 +105,7 @@ class ImagePollster(_Base): return ['image', 'image.size'] def get_counters(self, manager, cache): - for image in self.iter_images(manager.keystone): + for image in self._iter_images(manager.keystone, cache): yield counter.Counter( name='image', type=counter.TYPE_GAUGE, |