From 1972c4692428a61fafc7e1290632395d5824a4d8 Mon Sep 17 00:00:00 2001 From: Marian Krcmarik Date: Fri, 20 Nov 2020 01:33:02 +0100 Subject: [PATCH] Copy created image into all available glance stores The openstack can have multiple glance stores deployed/available. It may be a proper thing to copy newly created signed image into all the available glance stores so barbican tempest tests can access image regardless on which compute and storage backend they are ran on and regardless on which glance store is local. Additionally there is a nova-compute conf parameter[1] which can even prevent instances being spawned from image which is not available in local glance store. The copy-image would happen only if import_image tempest cong option is available which indicates glance multistore is available. [1] https://review.opendev.org/#/c/657078/ Change-Id: I1f0d8be1b237da0c96e820c4b3dca09a83b29752 --- .../tests/scenario/manager.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/barbican_tempest_plugin/tests/scenario/manager.py b/barbican_tempest_plugin/tests/scenario/manager.py index 615e08b..8daf090 100644 --- a/barbican_tempest_plugin/tests/scenario/manager.py +++ b/barbican_tempest_plugin/tests/scenario/manager.py @@ -290,6 +290,27 @@ class ScenarioTest(manager.NetworkScenarioTest): self.image_client.update_image(image['id'], data=image_file) else: self.image_client.store_image_file(image['id'], image_file) + + if CONF.image_feature_enabled.import_image: + available_stores = [] + try: + available_stores = self.image_client.info_stores()['stores'] + except exceptions.NotFound: + pass + available_import_methods = self.image_client.info_import()[ + 'import-methods']['value'] + if ('copy-image' in available_import_methods and + len(available_stores) > 1): + self.image_client.image_import(image['id'], + method='copy-image', + all_stores=True, + all_stores_must_succeed=False) + failed_stores = waiters.wait_for_image_copied_to_stores( + self.image_client, image['id']) + self.assertEqual(0, len(failed_stores), + "Failed to copy the following stores: %s" % + str(failed_stores)) + return image['id'] def rebuild_server(self, server_id, image=None,