Merge "Switch glance wrapper to image service that cinder service calls"

This commit is contained in:
Jenkins 2017-04-05 00:11:55 +00:00 committed by Gerrit Code Review
commit a27078c085
2 changed files with 14 additions and 16 deletions

View File

@ -15,8 +15,8 @@
import random
from rally import exceptions
from rally.plugins.openstack.services.image import image
from rally.plugins.openstack.services.storage import block
from rally.plugins.openstack.wrappers import glance as glance_wrapper
from rally.task import atomic
from rally.task import utils as bench_utils
@ -189,20 +189,19 @@ class CinderMixin(object):
volume = self._wait_available_volume(volume)
image_id = img["os-volume_upload_image"]["image_id"]
# NOTE(chenhb): If we imported glance service, we should switch
# glance wrapper to service.
wrapper = glance_wrapper.wrap(self._clients.glance, self)
image = wrapper.client.images.get(image_id)
image = bench_utils.wait_for_status(
image,
glance = image.Image(self._clients)
image_inst = glance.get_image(image_id)
image_inst = bench_utils.wait_for_status(
image_inst,
ready_statuses=["active"],
update_resource=wrapper.get_image,
update_resource=glance.get_image,
timeout=CONF.benchmark.glance_image_create_timeout,
check_interval=(CONF.benchmark
.glance_image_create_poll_interval)
)
return image
return image_inst
def delete_snapshot(self, snapshot):
"""Delete the given snapshot.

View File

@ -195,13 +195,12 @@ class CinderMixinTestCase(test.ScenarioTestCase):
self.cinder.volumes.update_readonly_flag.assert_called_once_with(
fake_volume, "fake_flag")
@mock.patch("rally.plugins.openstack.wrappers.glance.wrap")
def test_upload_volume_to_image(self, mock_wrap):
@mock.patch("rally.plugins.openstack.services.image.image.Image")
def test_upload_volume_to_image(self, mock_image):
volume = mock.Mock()
image = {"os-volume_upload_image": {"image_id": 1}}
self.cinder.volumes.upload_to_image.return_value = (None, image)
glance_client = mock_wrap.return_value.client
glance_client.images.get.return_value = image
glance = mock_image.return_value
self.service.generate_random_name = mock.Mock(
return_value="test_vol")
@ -219,14 +218,14 @@ class CinderMixinTestCase(test.ScenarioTestCase):
check_interval=CONF.benchmark.
cinder_volume_create_poll_interval),
mock.call(
glance_client.images.get.return_value,
glance.get_image.return_value,
ready_statuses=["active"],
update_resource=mock_wrap.return_value.get_image,
update_resource=glance.get_image,
timeout=CONF.benchmark.glance_image_create_timeout,
check_interval=CONF.benchmark.
glance_image_create_poll_interval)
])
glance_client.images.get.assert_called_once_with(1)
glance.get_image.assert_called_once_with(1)
def test_delete_snapshot(self):
snapshot = mock.Mock()