Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed GCE.ex_get_image to work on projects with > 500 images. #939

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions libcloud/compute/drivers/gce.py
Expand Up @@ -7326,16 +7326,18 @@ def _match_images(self, project, partial_name):
if no matching image is found.
:rtype: :class:`GCENodeImage` or ``None``
"""
project_images = self.list_images(ex_project=project,
ex_include_deprecated=True)
project_images_pages = self.ex_list(
self.list_images, ex_project=project, ex_include_deprecated=True)
partial_match = []
for image in project_images:
if image.name == partial_name:
return image
if image.name.startswith(partial_name):
ts = timestamp_to_datetime(image.extra['creationTimestamp'])
if not partial_match or partial_match[0] < ts:
partial_match = [ts, image]
for page in project_images_pages:
for image in page:
if image.name == partial_name:
return image
if image.name.startswith(partial_name):
ts = timestamp_to_datetime(
image.extra['creationTimestamp'])
if not partial_match or partial_match[0] < ts:
partial_match = [ts, image]

if partial_match:
return partial_match[1]
Expand Down