From 1a8ce18a4b09ecacf30efe6d3d67a185183e5459 Mon Sep 17 00:00:00 2001 From: peusterm Date: Mon, 6 Aug 2018 14:28:24 +0200 Subject: [PATCH] Fix: Made Glance-fake API more robust in environments with many registered Docker images. Change-Id: I27880b3530da088ab83a5bb5eb8d2946639d7ee0 Signed-off-by: peusterm --- src/emuvim/api/openstack/compute.py | 2 -- .../openstack/openstack_dummies/glance_dummy_api.py | 10 ++++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/emuvim/api/openstack/compute.py b/src/emuvim/api/openstack/compute.py index ce6f636..865b770 100755 --- a/src/emuvim/api/openstack/compute.py +++ b/src/emuvim/api/openstack/compute.py @@ -96,8 +96,6 @@ class OpenstackCompute(object): for image in self.dcli.images.list(): if len(image.tags) > 0: for t in image.tags: - # only use short tag names for OSM compatibility - t = t.replace(":latest", "") if t not in self._images: self._images[t] = Image(t) return self._images diff --git a/src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py index 16241e0..1b066f0 100755 --- a/src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py +++ b/src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py @@ -99,14 +99,15 @@ class GlanceListImagesApi(Resource): def get(self): LOG.debug("API CALL: %s GET" % str(self.__class__.__name__)) try: + img_list = self.api.compute.images.values() + LOG.debug("Found {} Docker images: {}".format( + len(img_list), [i.name for i in img_list])) resp = dict() # resp['next'] = None resp['first'] = "/v2/images" resp['schema'] = "/v2/schemas/images" resp['images'] = list() - limit = 18 - c = 0 - for image in self.api.compute.images.values(): + for image in img_list: f = dict() f['id'] = image.id f['name'] = str(image.name).replace(":latest", "") @@ -128,9 +129,6 @@ class GlanceListImagesApi(Resource): f['virtual_size'] = 1 f['marker'] = None resp['images'].append(f) - c += 1 - if c > limit: # ugly hack to stop buggy glance client to do infinite requests - break if "marker" in request.args: # ugly hack to fix pageination of openstack client resp['images'] = None return Response(json.dumps(resp), status=200, -- 2.25.1