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:
committed by
Boris Pavlovic
parent
974864699a
commit
829e42e9be
@@ -641,6 +641,8 @@
|
|||||||
name: "m1.tiny"
|
name: "m1.tiny"
|
||||||
image:
|
image:
|
||||||
name: {{image_name}}
|
name: {{image_name}}
|
||||||
|
list_kwargs:
|
||||||
|
visibility: "public"
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
times: 1
|
times: 1
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import copy
|
|||||||
|
|
||||||
from rally.common.plugin import plugin
|
from rally.common.plugin import plugin
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
from rally.plugins.openstack.services.image import image
|
||||||
from rally.task import types
|
from rally.task import types
|
||||||
|
|
||||||
|
|
||||||
@@ -80,11 +81,12 @@ class GlanceImage(types.ResourceType):
|
|||||||
:returns: id matching resource
|
:returns: id matching resource
|
||||||
"""
|
"""
|
||||||
resource_id = resource_config.get("id")
|
resource_id = resource_config.get("id")
|
||||||
|
list_kwargs = resource_config.get("list_kwargs", {})
|
||||||
if not resource_id:
|
if not resource_id:
|
||||||
glanceclient = clients.glance()
|
images = list(image.Image(clients).list_images(**list_kwargs))
|
||||||
resource_id = types._id_from_name(
|
resource_id = types._id_from_name(
|
||||||
resource_config=resource_config,
|
resource_config=resource_config,
|
||||||
resources=list(glanceclient.images.list()),
|
resources=images,
|
||||||
typename="image")
|
typename="image")
|
||||||
return resource_id
|
return resource_id
|
||||||
|
|
||||||
|
|||||||
@@ -1036,8 +1036,9 @@ class FakeServiceCatalog(object):
|
|||||||
|
|
||||||
class FakeGlanceClient(object):
|
class FakeGlanceClient(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, version="1"):
|
||||||
self.images = FakeImageManager()
|
self.images = FakeImageManager()
|
||||||
|
self.version = version
|
||||||
|
|
||||||
|
|
||||||
class FakeMuranoClient(object):
|
class FakeMuranoClient(object):
|
||||||
@@ -1621,9 +1622,9 @@ class FakeClients(object):
|
|||||||
self._nova = FakeNovaClient()
|
self._nova = FakeNovaClient()
|
||||||
return self._nova
|
return self._nova
|
||||||
|
|
||||||
def glance(self):
|
def glance(self, version="1"):
|
||||||
if not self._glance:
|
if not self._glance:
|
||||||
self._glance = FakeGlanceClient()
|
self._glance = FakeGlanceClient(version)
|
||||||
return self._glance
|
return self._glance
|
||||||
|
|
||||||
def cinder(self):
|
def cinder(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user