Allow to pass list kwargs to image resource type

This can help when you have a lot of images to speed up list operations

(list queries can take over 5 minutes if there are plenty amount of images)

Change-Id: I50594576929a8b21462611feb042dd0db562ec0e
This commit is contained in:
Boris Pavlovic 2017-10-20 14:50:13 -07:00 committed by Boris Pavlovic
parent 974864699a
commit 829e42e9be
3 changed files with 10 additions and 5 deletions

View File

@ -641,6 +641,8 @@
name: "m1.tiny"
image:
name: {{image_name}}
list_kwargs:
visibility: "public"
runner:
type: "constant"
times: 1

View File

@ -16,6 +16,7 @@ import copy
from rally.common.plugin import plugin
from rally import exceptions
from rally.plugins.openstack.services.image import image
from rally.task import types
@ -80,11 +81,12 @@ class GlanceImage(types.ResourceType):
:returns: id matching resource
"""
resource_id = resource_config.get("id")
list_kwargs = resource_config.get("list_kwargs", {})
if not resource_id:
glanceclient = clients.glance()
images = list(image.Image(clients).list_images(**list_kwargs))
resource_id = types._id_from_name(
resource_config=resource_config,
resources=list(glanceclient.images.list()),
resources=images,
typename="image")
return resource_id

View File

@ -1036,8 +1036,9 @@ class FakeServiceCatalog(object):
class FakeGlanceClient(object):
def __init__(self):
def __init__(self, version="1"):
self.images = FakeImageManager()
self.version = version
class FakeMuranoClient(object):
@ -1621,9 +1622,9 @@ class FakeClients(object):
self._nova = FakeNovaClient()
return self._nova
def glance(self):
def glance(self, version="1"):
if not self._glance:
self._glance = FakeGlanceClient()
self._glance = FakeGlanceClient(version)
return self._glance
def cinder(self):