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
This commit is contained in:
Steve Baker 2019-09-11 10:15:19 +12:00
parent 594614fca5
commit 3f78ad0dc2
2 changed files with 29 additions and 20 deletions

View File

@ -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")

View File

@ -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'))