From a565773e88f3e04d928d615490e2afc47caa6fa5 Mon Sep 17 00:00:00 2001 From: Andrey Kurilin Date: Mon, 11 Sep 2017 21:00:29 +0300 Subject: [PATCH] Fix listing images in Glance V2 The owner argument was not transmitted to glanceclient. Closes-bug: #1708484 Change-Id: If682e33bb20c110d83173a41352e841d39e6cc64 --- rally-jobs/rally.yaml | 6 +++--- rally/plugins/openstack/context/glance/images.py | 7 +++++++ rally/plugins/openstack/services/image/glance_v2.py | 3 ++- .../plugins/openstack/services/image/test_glance_v2.py | 7 +++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/rally-jobs/rally.yaml b/rally-jobs/rally.yaml index 06431911..43065158 100644 --- a/rally-jobs/rally.yaml +++ b/rally-jobs/rally.yaml @@ -442,13 +442,13 @@ concurrency: 5 context: users: - tenants: 1 - users_per_tenant: 2 + tenants: 2 + users_per_tenant: 1 images: image_url: "~/.rally/extra/fake-image.img" disk_format: "qcow2" container_format: "bare" - images_per_tenant: 1 + images_per_tenant: 2 sla: failure_rate: max: 100 diff --git a/rally/plugins/openstack/context/glance/images.py b/rally/plugins/openstack/context/glance/images.py index a15e3096..464a3d10 100644 --- a/rally/plugins/openstack/context/glance/images.py +++ b/rally/plugins/openstack/context/glance/images.py @@ -193,6 +193,13 @@ class ImageGenerator(context.Context): @logging.log_task_wrapper(LOG.info, _("Exit context: `Images`")) def cleanup(self): if self.context.get("admin", {}): + # NOTE(andreykurilin): Glance does not require the admin for + # listing tenant images, but the admin is required for + # discovering Cinder volumes which might be created for the + # purpose of caching. Removing such volumes are optional step, + # since Cinder should have own mechanism like garbage collector, + # but if we can, let's remove everything and make the cloud as + # close as possible to the original state. admin = self.context["admin"] admin_required = None else: diff --git a/rally/plugins/openstack/services/image/glance_v2.py b/rally/plugins/openstack/services/image/glance_v2.py index 2d6661c1..3af883c9 100644 --- a/rally/plugins/openstack/services/image/glance_v2.py +++ b/rally/plugins/openstack/services/image/glance_v2.py @@ -216,7 +216,8 @@ class UnifiedGlanceV2Service(glance_common.UnifiedGlanceMixin, image.Image): """ self._check_v2_visibility(visibility) - images = self._impl.list_images(status=status, visibility=visibility) + images = self._impl.list_images( + status=status, visibility=visibility, owner=owner) return [self._unify_image(i) for i in images] def set_visibility(self, image_id, visibility="shared"): diff --git a/tests/unit/plugins/openstack/services/image/test_glance_v2.py b/tests/unit/plugins/openstack/services/image/test_glance_v2.py index 8f3d7ca5..0866f562 100755 --- a/tests/unit/plugins/openstack/services/image/test_glance_v2.py +++ b/tests/unit/plugins/openstack/services/image/test_glance_v2.py @@ -199,10 +199,13 @@ class UnifiedGlanceV2ServiceTestCase(test.TestCase): status = "active" self.assertEqual([mock_image__unify_image.return_value], - self.service.list_images()) + self.service.list_images(owner="foo", + visibility="shared")) self.service._impl.list_images.assert_called_once_with( status=status, - visibility=None) + visibility="shared", + owner="foo" + ) def test_set_visibility(self): image_id = "image_id"