Fix Glance API pagination polling

Change-Id: I520563f195afc81cf3c9600ca1a8cafd97fa0940
This commit is contained in:
Swann Croiset 2017-03-06 17:51:37 +01:00
parent 5f4cab9047
commit 97201abd78
1 changed files with 8 additions and 11 deletions

View File

@ -351,21 +351,18 @@ class CollectdPlugin(base.Base):
_objects.extend(bulk_objs)
links = resp.get('{}_links'.format(object_name))
if links is None or self.pagination_limit is None:
# Either the pagination is not supported or there is
# no more data
# In both cases, we got at this stage all the data we
# can have.
if self.pagination_limit is None:
break
# if there is no 'next' link in the response, all data has
# been read.
if len([i for i in links if i.get('rel') == 'next']) == 0:
links = resp.get('{}_links'.format(object_name), [])
has_next = len(
[i for i in links if i.get('rel') == 'next']) > 0 or \
resp.get('next')
if has_next:
_opts['marker'] = bulk_objs[-1]['id']
else:
break
_opts['marker'] = bulk_objs[-1]['id']
if not has_failure:
self._last_run = last_run