~cloudbuilders/nova/os-keypair-integration

« back to all changes in this revision

Viewing changes to nova/image/glance.py

  • Committer: Vishvananda Ishaya
  • Date: 2011-09-01 04:55:12 UTC
  • mfrom: (1455.1.62 nova)
  • Revision ID: vishvananda@gmail.com-20110901045512-ndwp9nu3alwbnnj8
merge trunk, fix tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
        """Paginate through results from glance server"""
142
142
        images = fetch_func(**kwargs)
143
143
 
144
 
        for image in images:
145
 
            yield image
146
 
        else:
 
144
        if not images:
147
145
            # break out of recursive loop to end pagination
148
146
            return
149
147
 
 
148
        for image in images:
 
149
            yield image
 
150
 
150
151
        try:
151
152
            # attempt to advance the marker in order to fetch next page
152
153
            kwargs['marker'] = images[-1]['id']
153
154
        except KeyError:
154
155
            raise exception.ImagePaginationFailed()
155
156
 
156
 
        self._fetch_images(fetch_func, **kwargs)
 
157
        try:
 
158
            kwargs['limit'] = kwargs['limit'] - len(images)
 
159
            # break if we have reached a provided limit
 
160
            if kwargs['limit'] <= 0:
 
161
                return
 
162
        except KeyError:
 
163
            # ignore missing limit, just proceed without it
 
164
            pass
 
165
 
 
166
        for image in self._fetch_images(fetch_func, **kwargs):
 
167
            yield image
157
168
 
158
169
    def show(self, context, image_id):
159
170
        """Returns a dict with image data for the given opaque image id."""