diff --git a/config_tempest/services/image.py b/config_tempest/services/image.py index e7888e62..91543f19 100644 --- a/config_tempest/services/image.py +++ b/config_tempest/services/image.py @@ -17,6 +17,7 @@ import os import shutil import subprocess import time +import webob.exc from functools import wraps @@ -56,6 +57,10 @@ class ImageService(VersionedService): self.convert = convert def set_default_tempest_options(self, conf): + # set 'image-feature-enabled' only if multiple stores available + num_stores = self._get_number_of_stores() + if num_stores: + conf.set('image-feature-enabled', 'import_image', 'True') # When cirros is the image, set validation.image_ssh_user to cirros. # The option is heavily used in CI and it's also usefull for refstack, # because we don't have to specify overrides. @@ -77,6 +82,13 @@ class ImageService(VersionedService): # default value conf.set('image', 'http_image', C.DEFAULT_IMAGE) + def _get_number_of_stores(self): + try: + stores = self.client.info_stores()['stores'] + return len(stores) + except webob.exc.HTTPNotFound as e: + C.LOG.info("Cannot retrieve stores since '%s'", e.message) + def get_supported_versions(self): return ['v1', 'v2']