From 3f78ad0dc240b7c624bf25846978f088d2cad483 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Wed, 11 Sep 2019 10:15:19 +1200 Subject: [PATCH] Allow discover-tempest-config to run with no nova or glance endpoint The TripleO undercloud will soon have no nova or glance due to blueprint nova-less-deploy, however it is still required to run tempest tests via a discover-tempest-config generated config. Currently this fails due to always attempting to list existing flavors and images. This change only runs flavor and image code if those endpoints are available. Change-Id: Icffce84638e0db099626d5a86a84f44472943a69 Story: 2006527 Task: 36573 --- config_tempest/main.py | 28 ++++++++++++++---------- config_tempest/services/orchestration.py | 21 +++++++++++------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/config_tempest/main.py b/config_tempest/main.py index b0a9ee5d..14e3d80a 100755 --- a/config_tempest/main.py +++ b/config_tempest/main.py @@ -526,19 +526,23 @@ def config_tempest(**kwargs): if kwargs.get('create', False) and kwargs.get('test_accounts') is None: users = Users(clients.projects, clients.roles, clients.users, conf) users.create_tempest_users() - flavors = Flavors(clients.flavors, kwargs.get('create', False), conf, - kwargs.get('flavor_min_mem', C.DEFAULT_FLAVOR_RAM), - kwargs.get('flavor_min_disk', C.DEFAULT_FLAVOR_DISK), - no_rng=kwargs.get('no_rng', False)) - flavors.create_tempest_flavors() - image = services.get_service('image') - image.set_image_preferences(kwargs.get('image_disk_format', - C.DEFAULT_IMAGE_FORMAT), - kwargs.get('non_admin', False), - no_rng=kwargs.get('no_rng', False), - convert=kwargs.get('convert_to_raw', False)) - image.create_tempest_images(conf) + if services.is_service(**{"type": "compute"}): + flavors = Flavors(clients.flavors, kwargs.get('create', False), conf, + kwargs.get('flavor_min_mem', C.DEFAULT_FLAVOR_RAM), + kwargs.get('flavor_min_disk', C.DEFAULT_FLAVOR_DISK), + no_rng=kwargs.get('no_rng', False)) + flavors.create_tempest_flavors() + + if services.is_service(**{"type": "image"}): + image = services.get_service('image') + image.set_image_preferences(kwargs.get('image_disk_format', + C.DEFAULT_IMAGE_FORMAT), + kwargs.get('non_admin', False), + no_rng=kwargs.get('no_rng', False), + convert=kwargs.get('convert_to_raw', + False)) + image.create_tempest_images(conf) has_neutron = services.is_service(**{"type": "network"}) network = services.get_service("network") diff --git a/config_tempest/services/orchestration.py b/config_tempest/services/orchestration.py index 1cb99bcb..2ca4c770 100644 --- a/config_tempest/services/orchestration.py +++ b/config_tempest/services/orchestration.py @@ -65,11 +65,16 @@ class OrchestrationService(Service): "heat_tempest_plugin cannot be set!") def post_configuration(self, conf, is_service): - conf.set('heat_plugin', 'minimal_instance_type', - conf.get('compute', 'flavor_ref')) - conf.set('heat_plugin', 'instance_type', - conf.get('compute', 'flavor_ref_alt')) - conf.set('heat_plugin', 'minimal_image_ref', - conf.get('compute', 'image_ref')) - conf.set('heat_plugin', 'image_ref', - conf.get('compute', 'image_ref_alt')) + compute_options = conf.options('compute') + if 'flavor_ref' in compute_options: + conf.set('heat_plugin', 'minimal_instance_type', + conf.get('compute', 'flavor_ref')) + if 'flavor_ref_alt' in compute_options: + conf.set('heat_plugin', 'instance_type', + conf.get('compute', 'flavor_ref_alt')) + if 'image_ref' in compute_options: + conf.set('heat_plugin', 'minimal_image_ref', + conf.get('compute', 'image_ref')) + if 'image_ref_alt' in compute_options: + conf.set('heat_plugin', 'image_ref', + conf.get('compute', 'image_ref_alt'))