diff --git a/config_tempest/services/base.py b/config_tempest/services/base.py index 61e68dec..234185e2 100644 --- a/config_tempest/services/base.py +++ b/config_tempest/services/base.py @@ -20,6 +20,10 @@ import urllib3 from six.moves import urllib from config_tempest.constants import LOG + +from tempest.lib import exceptions + + MULTIPLE_SLASH = re.compile(r'/+') @@ -62,6 +66,11 @@ class Service(object): self.s_type, url) raise e + if r.status == 403: + raise exceptions.Forbidden("Request on service '%s' with url '%s' " + "failed with code 403" % (self.s_type, + url)) + if r.status >= 400: raise ServiceError("Request on service '%s' with url '%s' failed" " with code %d" % (self.s_type, url, r.status)) diff --git a/config_tempest/services/share.py b/config_tempest/services/share.py index 5ae3eb78..8b98294c 100644 --- a/config_tempest/services/share.py +++ b/config_tempest/services/share.py @@ -13,17 +13,41 @@ # License for the specific language governing permissions and limitations # under the License. +import json + +from config_tempest import constants as C from config_tempest.services.base import VersionedService +from tempest.lib import exceptions + class ShareService(VersionedService): + def get_share_pools(self): + body = self.do_get(self.service_url + '/scheduler-stats/pools') + body = json.loads(body) + return body + def set_default_tempest_options(self, conf): if 'v2' in self.service_url: m_vs = self.filter_api_microversions() conf.set('share', 'min_api_microversion', m_vs['min_microversion']) conf.set('share', 'max_api_microversion', m_vs['max_microversion']) + try: + pools = self.get_share_pools()['pools'] + except exceptions.Forbidden: + C.LOG.warning("User has no permissions to list back-end storage " + "pools - storage back-ends can't be discovered.") + return + if pools: + backends = [ + pool['backend'] for pool in pools + ] + conf.set('share', 'backend_names', ','.join(backends)) + if len(backends) > 1: + conf.set('share', 'multi_backend', True) + def get_unversioned_service_type(self): return 'share' diff --git a/config_tempest/services/volume.py b/config_tempest/services/volume.py index 14db6a9e..0e88fa5c 100644 --- a/config_tempest/services/volume.py +++ b/config_tempest/services/volume.py @@ -14,6 +14,7 @@ # under the License. import json +import re from config_tempest import constants as C from config_tempest.services.base import VersionedService @@ -33,12 +34,32 @@ class VolumeService(VersionedService): self.versions_body = json.loads(body) self.versions = self.deserialize_versions(self.versions_body) + def get_volume_pools(self): + body = self.do_get(self.service_url + '/scheduler-stats/get_pools') + body = json.loads(body) + return body + def set_default_tempest_options(self, conf): if 'v3' in self.service_url: m_vs = self.filter_api_microversions() conf.set('volume', 'min_microversion', m_vs['min_microversion']) conf.set('volume', 'max_microversion', m_vs['max_microversion']) + try: + pools = self.get_volume_pools()['pools'] + except exceptions.Forbidden: + C.LOG.warning("User has no permissions to list back-end storage " + "pools - storage back-ends can't be discovered.") + return + if pools: + backends = [ + re.findall(r'(\w*)@(\w*)', pool['name'])[0][1] + for pool in pools + ] + conf.set('volume', 'backend_names', ','.join(backends)) + if len(backends) > 1: + conf.set('volume-feature-enabled', 'multi_backend', True) + def get_service_extension_key(self): return 'api_extensions'