From 39eefc1989ff4e51db8716dd7106967b14fee12a Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 26 May 2015 18:05:57 -0400 Subject: [PATCH] Make sure glance image list actually runs in Tasks images.list() does not actually talk to an API. So putting it in TaskManager actually takes an execution slot that it does not need. On the other hand, the follow up list expansion DOES talk to the API. So put it in the Task, since it's the evil thing. Change-Id: I7f30ba908552fbecaedd364ecf20b19e096b03d9 --- shade/__init__.py | 9 ++++++--- shade/_tasks.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/shade/__init__.py b/shade/__init__.py index 5427a6c21..59fa88611 100644 --- a/shade/__init__.py +++ b/shade/__init__.py @@ -953,11 +953,14 @@ class OpenStackCloud(object): # First, try to actually get images from glance, it's more efficient images = [] try: - # If the cloud does not expose the glance API publically - image_gen = self.manager.submitTask(_tasks.GlanceImageList()) + # Creates a generator - does not actually talk to the cloud API + # hardcoding page size for now. We'll have to get MUCH smarter + # if we want to deal with page size per unit of rate limiting + image_gen = self.glance_client.images.list(page_size=1000) # Deal with the generator to make a list - image_list = [image for image in image_gen] + image_list = self.manager.submitTask( + _tasks.GlanceImageList(image_gen=image_gen)) if image_list: if getattr(image_list[0], 'validate', None): diff --git a/shade/_tasks.py b/shade/_tasks.py index 49d6f7d67..3dc051c0f 100644 --- a/shade/_tasks.py +++ b/shade/_tasks.py @@ -124,7 +124,7 @@ class RouterDelete(task_manager.Task): class GlanceImageList(task_manager.Task): def main(self, client): - return client.glance_client.images.list() + return [image for image in self.args['image_gen']] class NovaImageList(task_manager.Task):