Add support for storage pools

The patch set all back-end storage pools that are
known to the scheduler service for share and volume
services.

Change-Id: I9abb849cd28b8c4c7874919fb271d6506cb7a255
This commit is contained in:
lkuchlan 2020-02-16 15:08:11 +02:00
parent e7c69d2957
commit 12ec193b0f
3 changed files with 54 additions and 0 deletions

View File

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

View File

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

View File

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